ochafik/nativelibs4java — Issue #207: Unable to process Python 2.6: "Failed to match any alternative with token"
Author: yang
Created: 2011-12-09 20:13:53+00:00
State: open

I'm simply trying to process the [standard Python 2.6 headers on Ubuntu 10.04](http://packages.ubuntu.com/lucid/python2.6-dev). Transcript:

```
$ java -jar jnaerator-0.9.8-shaded.jar -library python26 /usr/include/python2.6/Python.h -o dst -v -noJar -noComp 2>&1 -I /usr/lib/gcc/x86_64-linux-gnu/4.4/include/
Auto-configuring parser...
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=.:/usr/include:/usr/include/c++/4.4.3
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks:/Library/Frameworks:/Local/Library/Frameworks/:/home/yang/Library/Frameworks
os.arch = amd64
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAerator jnaerate
INFO: Include path :
/usr/lib/gcc/x86_64-linux-gnu/4.4/include
.
/usr/include
/usr/include/c++/4.4.3
Parsing native headers...
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );

...

Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 1:0 Failed to match any alternative with token [@0,0:5='return',<55>,1:0]
File: null:1
Input: return Py_INCREF ( Py_True )
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 1:18 extraneous input [@5,18:18='2',<4>,1:18] expecting ')'
line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='',<-1>,0:-1]
File: null:0
Input:
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

line 1:0 Failed to match any alternative with token [@0,0:5='return',<55>,1:0]
File: null:1
Input: return Py_INCREF ( Py_None )
Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
Stack: []

Now parsing 439 text blocks
Normalizing parsed code...
Writing raw parsed sources to '_jnaerator.rawParsed.cpp'
Writing normalized parsed sources to '_jnaerator.normalizedParsed.cpp'
Generating libraries...
Generating Python26Library.java
JNAeration completed !
/home/yang/tmp/dst

$ cat dst/python26/Python26Library.java
package python26;
import com.ochafik.lang.jnaerator.runtime.LibraryExtractor;
import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper;
import com.ochafik.lang.jnaerator.runtime.Mangling;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import com.sun.jna.Pointer;
/**
* JNA Wrapper for library python26

* This file was autogenerated by JNAerator,

* a tool written by Olivier Chafik that uses a few opensource projects..

* For help, please visit NativeLibs4Java , Rococoa, or JNA.
*/
public interface Python26Library extends Library {
public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("python26", true, python26.Python26Library.class);
public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(python26.Python26Library.JNA_LIBRARY_NAME, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
public static final Python26Library INSTANCE = (Python26Library)Native.loadLibrary(python26.Python26Library.JNA_LIBRARY_NAME, python26.Python26Library.class, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
/// native declaration : /usr/include/python2.6/Python.h
public static final int WITH_CYCLE_GC = (int)1;
/// native declaration : /usr/include/python2.6/Python.h
public static final int Py_file_input = (int)257;
/// native declaration : /usr/include/python2.6/Python.h
public static final int Py_single_input = (int)256;
/// native declaration : /usr/include/python2.6/Python.h
public static final int Py_eval_input = (int)258;
/**
* _Py_Mangle is defined in compile.c

* Original signature : PyObject* _Py_Mangle(PyObject*, PyObject*)

* native declaration : /usr/include/python2.6/Python.h:4
*/
@Mangling({"_Z10_Py_MangleP8PyObjectP8PyObject", "?_Py_Mangle@@YAPA8PyObjectPA8PyObjectPA8PyObject@Z"})
Pointer _Py_Mangle(Pointer p, Pointer name);
/// Undefined type
public static interface PyObject {

};
}
```