hzzc1987 / jnaerator

Automatically exported from code.google.com/p/jnaerator
0 stars 0 forks source link

Failed to match any alternative with token #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm trying to generate JNA interface using JNAerator for a C library but
I've got a lot of exception like this one:

line 1:10 Failed to match any alternative with token [@4,10:10='5',<4>,1:10]
         File: null:1
        Input: ( ( FEA_INT ) 5 )
         Rule: ()* loopback of 1407:3: (op= ( '<' | '<=' | '>' | '>=' ) f=
shift
Expr )*
        Stack: [expression, topLevelExprList, topLevelExpr, assignmentExpr,
inlineCondExpr, logOrExpr, logAndExpr, bitOrExpr, xorExpr, bitAndExpr,
equalExpr, compareExpr, shiftExpr, addExpr, multExpr, castExpr, unaryExpr,
postfixExpr, baseExpression, expression, topLevelExprList, topLevelExpr,
assignmentExpr, inlineCondExpr, logOrExpr, logAndExpr, bitOrExpr, xorExpr,
bitAndExpr, equalExpr, compareExpr]

Find attached the 3 header files and the stlib.dll if you want to reproduce.

My command line is:
java -jar ./lib/jna/jnaerator-v0.6-b367.jar -library stlib -o ./src
C:\FEA\lib\include\dllshare.h C:\FEA\lib\include\feaerror.h
C:\FEA\lib\include\stlib.h C:\FEA\lib\win32\stlib.dll

Original issue reported on code.google.com by frederic...@gmail.com on 30 May 2009 at 10:48

GoogleCodeExporter commented 8 years ago
Hi Frederic,

These "error" messages might be misleading, they might just be normal errors 
that occur during intermediate 
parsing passes within ANTLR (there is lots of work in trying to reduce this 
output).
Or it could indeed be a nasty parsing issue :-D 
Could you try and isolate the code that produces this error (doing a simple 
dichotomy : surround the second 
half of the main header with a #if 0... #endif block, then narrow down to first 
or second part...) ? It could boil 
down to a single faulty C declaration.

Thanks for the bug report :)

Original comment by olivier.chafik@gmail.com on 31 May 2009 at 9:02

GoogleCodeExporter commented 8 years ago

Original comment by olivier.chafik@gmail.com on 31 May 2009 at 9:03

GoogleCodeExporter commented 8 years ago
Thanks for your answer.

even with a simple Header file I have this "Failed to match any alternative with
token" error.

Input header:
#define MY_INT 10 

Generated JNA interface:

public interface StlibLibrary extends com.sun.jna.Library {
    StlibLibrary INSTANCE =
(StlibLibrary)com.sun.jna.Native.loadLibrary(com.ochafik.lang.jnaerator.runtime.
LibraryExtractor.getLibraryPath("stlib",
true, StlibLibrary.class), StlibLibrary.class,
com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);

    public static final int MY_INT = 10;
}

Command line:
java -jar .\lib\jna\jnaerator-v0.6-b367.jar -library stlib -o ./src/tmp
C:\Fdev\myheader.h

Error Log:
31-mai-2009 23:40:08 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_HOME=C:\Program Files\Microsoft Visual Studio
9.0
31-mai-2009 23:40:08 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] WINDOWS_SDK_HOME=C:\Program Files\Microsoft SDKs\Windows\v6.
0A
31-mai-2009 23:40:08 com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_INCLUDES=C:\Program Files\Microsoft Visual Stu
dio 9.0\VC\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
31-mai-2009 23:40:08 com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=C:\Program Files\Microsoft Visual
Studio 9.0\VC\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include;.
31-mai-2009 23:40:08 com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=/System/Library/Frameworks/CoreServic
es.framework/Versions/Current/Frameworks;/System/Library/Frameworks/ApplicationS
ervices.framework/Versions/Current/Frameworks;/System/Library/Frameworks;/Librar
y/Frameworks;C:\Documents and Settings\Fred/Library/Frameworks
os.arch = x86
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0
:-1]
         File: null:0
        Input:
         Rule: 1413:1: castExpr returns [Expression expr] : ( '(' tr= mutableTyp
eRef ')' inner= castExpr | e= unaryExpr );
        Stack: [expression, topLevelExprList, topLevelExpr, assignmentExpr, inli
neCondExpr, logOrExpr, logAndExpr, bitOrExpr, xorExpr, bitAndExpr, equalExpr, co
mpareExpr, shiftExpr, addExpr, multExpr, castExpr]

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0
:-1]
         File: null:0
        Input:
         Rule: 1413:1: castExpr returns [Expression expr] : ( '(' tr= mutableTyp
eRef ')' inner= castExpr | e= unaryExpr );
        Stack: [expression, topLevelExprList, topLevelExpr, assignmentExpr, inli
neCondExpr, logOrExpr, logAndExpr, bitOrExpr, xorExpr, bitAndExpr, equalExpr, co
mpareExpr, shiftExpr, addExpr, multExpr, castExpr]

Generating: (...)stlib\StlibLibrary.java

So it seems even the most basic "define" generate this error.

Fred

Original comment by frederic...@gmail.com on 31 May 2009 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by olivier.chafik@gmail.com on 3 Jun 2009 at 1:28

GoogleCodeExporter commented 8 years ago
Frederic,

Thanks for the update, I'll try to find a way to reduce the verbosity of ANTLR 
as soon as my pile of critical issues 
shrinks a bit :-)
Regards

Olivier

Original comment by olivier.chafik@gmail.com on 11 Jun 2009 at 6:20

GoogleCodeExporter commented 8 years ago
Hi,
This issue moved to Github :
https://github.com/ochafik/nativelibs4java/issues/117

Thanks for not updating this page anymore and adding further comments on Github.
Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 1 Sep 2011 at 7:23