repository
stringclasses
156 values
issue title
stringlengths
1
1.01k
labels
stringclasses
8 values
body
stringlengths
1
270k
antlrantlr4
antrl4 source jar do not contain source for runtime
Bug
the source artifact for org antlr antlr4 do not contain source for the contain antr4 runtime dependent on the order of the classpath read maven import this prevent eclipse from show javadoc source for the runtime class please include all source in the source artifact for antlr4
antlrantlr4
miss token when parse
Question
I be currently try to parse preprocessor define in c file with antlr currently I just want to fetch the define name and value if any this be aproximately how my current code look like statement ppdefine linebreak defvalue defvalue definevalue ppdefine preprocess definevalue value preprocess ppdefine ppdefine pp ws definer ws value some basic type text value star lettersign ws skip linebreak r n skip pp skip definer define value letter number skip several more line that look similar when I run this on my file I only receive define its name as a token and be miss the value if there be one how can I receive the value in another token if you want an example file try this define def1 1 define def2 2
antlrantlr4
implement a visitor
Question
hello currently I m work in a large application with an attribute grammar in antlr4 I have my parser file separate from my lexer file and I want to clean the grammar and pass the logic to a visitor my question be how can I generate the visitor with the combine file I have to clean the attribute of the grammar too or I can access they in the visitor
antlrantlr4
fix nameerror in lexeratnsimulator reset
Bug
without this line one get nameerror name lexer be not define when call reset this be the same way init assign self mode
antlrantlr4
antlr doesn t check all alternative
Invalid
first the link minimal grammar minimal program the link grammar be reduce to a minimal working example so it should hopefully be quite understandable it seperate string in string prefix and string content the problem be encounter when an expression contain a variable which be name like a string prefix here r e g python r x antlr seemingly always want to parse this as a string and produce an error like line 2 1 mismatch input expect str but when you remove the string prefix from the string rule it use the rule for a variable and parse correctly as far as I understand antlr should accept any grammar as long as it do not contain indirect left recursion so either there be something fundamental which I have not yet understand about antlr or this be a bug fyi I also encounter a similar problem for a different parser rule in version 4 4 which disappear in version 4 5 so I assume that it be a fix bug and a bit of context in case it help the describe grammar extract belong to a python compiler I have be develop as a project at our university the compiler be mainly do for learn purpose so the grammar be self write and not the official python grammar it include semicolon because python indentation be handle by preprocesse
antlrantlr4
fetchedeof field hold true even after call on reset in bufferedtokenstream
Duplicate
bufferedtokenstream reset leave boolean field fetchedeof intact make it impossible to reuse the stream object after the first eof be hit
antlrantlr4
antlr4 throw noviablealtexception instead of report miss token
Invalid
example grammar expr parenthesis parenthesis parenthesis parenthesis i d i d a z a z while parse next input x parser throw noviablealtexception if I remove parenthesis parenthesis rule it report miss token error line 1 2 miss at even if I rewrite 2 nd rule just to ignore it via semantic predicate false parenthesis parenthesis I still get noviablealtexception find a temporary solution next grammar work fine expr parenthesis temp fix parenthesis parenthesis temp fix
antlrantlr4
template error attribute parser isn t define
Bug
grammar grammar language lexer member var blah true p t t t a z blah init p eof generate an error below when use javascript target antlr4 dlanguage javascript language g4 warning 22 template error context lexerfile lexer dumpaction rulesempredfunction 1 4 attribute parser isn t define
antlrantlr4
xpath java use xpathlexer but it be not in the project
Invalid
I be maintain a fork w o graphic for android and currently I be see that xpath java be require xpathlexer to compile be I miss something I admit I be use a modify pom xml file to compile the runtime jar instead of use bild
antlrantlr4
crash on add an argument to a rule
Bug
on a fairly large grammar combine lexer and parser which work fine I add a parameter to a parser rule term boolean ispre and add an argument to every place that the rule be invoke e g term ispre or term true now run anltr on the grammar cause a crash java lang reflect invocationtargetexception at sun reflect nativemethodaccessorimpl invoke0 native method at sun reflect nativemethodaccessorimpl invoke unknown source at sun reflect delegatingmethodaccessorimpl invoke unknown source at java lang reflect method invoke unknown source at org antlr v4 parse grammartreevisitor visit grammartreevisitor java 207 at org antlr v4 parse grammartreevisitor visitgrammar grammartreevisitor java 201 at org antlr v4 semantic symbolcollector process symbolcollector java 76 at org antlr v4 semantic semanticpipeline process semanticpipeline java 103 at org antlr v4 tool processnoncombinedgrammar tool java 397 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190 cause by java lang arrayindexoutofboundsexception 2 at org antlr v4 semantic symbolcollector discoverouteralt symbolcollector java 111 at org antlr v4 parse grammartreevisitor outeralternative grammartreevisitor java 2285 at org antlr v4 parse grammartreevisitor ruleblock grammartreevisitor java 2198 at org antlr v4 parse grammartreevisitor rule grammartreevisitor java 1664 at org antlr v4 parse grammartreevisitor rule grammartreevisitor java 1242 at org antlr v4 parse grammartreevisitor grammarspec grammartreevisitor java 481 12 more exception in thread main java lang nullpointerexception at org antlr v4 tool rule getaltlabel rule java 217 at org antlr v4 tool rule hasaltspecificcontexts rule java 200 at org antlr v4 semantic symbolcheck checkforlabelconflict symbolcheck java 157 at org antlr v4 semantic symbolcheck process symbolcheck java 105 at org antlr v4 semantic semanticpipeline process semanticpipeline java 107 at org antlr v4 tool processnoncombinedgrammar tool java 397 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190 I m dead in the water now so help would be appreciate
antlrantlr4
swift target
Question
I do a quick search and I didn t see anything write about this yet what s the likelihood of a swift target for antlr there be c javascript and python target at the moment what do it take to implement a target give that swift be more java like it seem like it should be possible maybe start with a code translator if there be one for java to swift and iterate towards a more idiomatic implementation
antlrantlr4
parser not able to load lexer
Invalid
I have to two lexer g4 and parser g4 file error show unable to find or load grammer sqllexer kindly provide solution antlr4
antlrantlr4
miss manifest for out of the box call of bild py
Bug
base on instruction for build antlr from scratch I use the following command in bash mkdir tmp cd tmp git clone cd antlr4 bild py debug mkjar but when it get to make the jar I get build mkjar complete 04 28 15 04 47 03 require bild py 91 bilder py 430 build mkjar complete traceback most recent call last file home g2graman desktop translatejs tmp antlr4 bilder py line 857 in processargs target file bild py line 435 in all mkjar file bild py line 165 in mkjar mkjar complete file bild py line 103 in mkjar complete manif manif version os getlogin oserror errno 2 no such file or directory 04 28 15 04 47 03 processarg bild py 444 bilder py 860 errno 2 no such file or directory bild succeed be there a miss step to generate the accord manifest file for mkjar
antlrantlr4
complex hql order by statement be invalid
Invalid
age from shipment as t where 1 1 and exist select sr i d from shipmentroute sr where sr shipment i d t i d and sr rdc i d t operaterdc i d and sr shiptime be null and sr rdc i d 11111 and sr arrivaltime be null and t businesstype pickup or t operaterdc i d 11111 and sr arrivaltime be null and t businesstype pickup or t operaterdc i d 11111 and t status deliver and t status pod and t businesstype pickup order by t weight asc blow hql order by statement be invalid
antlrantlr4
classcastexception on split parser lexer grammar
Invalid
I have a relatively simple split parser and lexer grammar which be cause a classcastexception grun someparser layout exception in thread main java lang classcastexception class someparser at java lang class assubclass class java 3404 at org antlr v4 runtime misc testrig process testrig java 159 at org antlr v4 runtime misc testrig main testrig java 143 parser lexer
antlrantlr4
why do the antlr pom have a antlr4 and antlr3 runtime dependency
Invalid
hi I be wonder why the main antlr pom xml as a antlr4 and a antlr3 runtime dependency can the antlr3 dependency be exclude without side effect xml org antlr antlr4 runtime 4 5 org antlr antlr runtime 3 5 2 compile
antlrantlr4
issue with non greedy rule
Invalid
hey I would like to have the follow grammar part of it antlr expression expression and expression expression or expression stringsequence stringsequence stringcharacter fragment stringcharacter stringcharact fragment stringcharacter escapesequence it should match thing like a b c d f as well as thing like a and b and c the problem be that my rule stringsequence be greedy and consume the or and as well I ve try different approach but couldn t get my grammar to work in the correct way be this possible with antlr 4 note that I don t want to put quote around every string put quote work fine because the rule become non greedy I e antlr stringsequence stringcharacter thank
antlrantlr4
os getlogin be not valid in window
Bug
I use os getenv username in window 7 instead
antlrantlr4
error when use language other than english
Invalid
I be play with the hello g4 from the getting start page here change hello with any arabic word for example crash it it seem that antlr do not support unicode any idea how to overcome this
antlrantlr4
grun hello r gui doesn t show up any dialog box and error
Invalid
I have do git clone and run python script bild all to build the antlr 4 5 complete jar file and follow the below step and example everything work fine but at last step grun hello r gui it doesn t show up dialog and any error after provide the input to it and ctrl d please guide I already waste couple of day to resolve this unix 0 install java version 1 6 or high 1 download cd usr local lib curl o or just download in browser from website and put it somewhere rational like usr local lib 2 add antlr 4 5 complete jar to your classpath export classpath usr local lib antlr 4 5 complete jar classpath it s also a good idea to put this in your bash profile or whatever your startup script be 3 create alias for the antlr tool and testrig alias antlr4 java xmx500 m cp usr local lib antlr 4 5 complete jar classpath org antlr v4 tool alia grun java org antlr v4 runtime misc testrig test the installation either launch org antlr v4 tool directly java org antlr v4 tool antlr parser generator version 4 5 o specify output directory where all output be generate lib specify location of tokens file or use jar option on java java jar usr local lib antlr 4 5 complete jar antlr parser generator version 4 5 o specify output directory where all output be generate lib specify location of tokens file a first example in a temporary directory put the follow grammar inside file hello g4 hello g4 define a grammar call hello grammar hello r hello i d match keyword hello follow by an identifi i d a z match low case identifier ws t r n skip skip space tab newline then run antlr the tool on it cd tmp antlr4 hello g4 javac hello java now test it grun hello r tree hello parrt d r hello parrt that d mean eof on unix it s z in window the tree option print the parse tree in lisp notation it s nice to look at parse tree visually grun hello r gui hello parrt d that pop up a dialog box show that rule r match keyword hello follow by identifier parrt
antlrantlr4
parse error not throw for invalid input
Invalid
I m not receive a parse error when my input be invalid I can reproduce behavior with modify hello g4 from the book change this r hello i d to this r greeting greeting greeting hello i d I do get an error if the first input line do not start with hello joe grun hello r tree send the follow error to the console line 1 0 miss hello at joe but I do not get an error for this next input hello joe bob instead the follow syntax tree be get print r greeting hello joe it s show the syntax tree for the first greeting but it s not provide any information that the second greeting be invalid because it didn t start with hello I dig into the antlr4 java code and parseratnsimulator execatn enter the if d error block but it do not throw e instead it return alt as 2 if d error if any config in previous dip into outer context that mean that input up to t actually finish entry rule at least for sll decision full ll doesn t dip into outer so don t need special case we will get an error no matter what so delay until after decision well error message also no reachable target atn states in sll imply ll will also get nowhere if conflict in state that dip out choose min since we will get error no matter what noviablealtexception e noviablealt input outercontext previousd config startindex input seek startindex int alt getsynvalidorseminvalidaltthatfinisheddecisionentryrule previousd config outercontext if alt atn invalid alt number return alt throw e when the code return back into hellopars r it doesn t go into the while loop because alt be 2 and the code then exit the rule without any info about the invalid second greeting public final rcontext r throw recognitionexception alt getinterpreter adaptivepredict input 0 ctx while alt 2 alt org antlr v4 runtime atn atn invalid alt number be this behavior by design shouldn t antlr complain about the second invalid greeting or be there a bug in my grammar that s cause the second invalid greeting to get silently ignore thank for any help larry
antlrantlr4
unuse import warning in generate listener file
Duplicate
every listener and baselistener java file generate in my project contain the line java import org antlr v4 runtime misc notnull without any reference to notnull appear in the file this generate a ton of warning in eclipse here be an example generate method in one of the baselisten file java inheritdoc the default implementation do nothing override public void enterbrace clause juniperparser braced clausecontext ctx I note that in some forum post the function signature contain notnull after the open parenthesis this be not occur in my generate class any idea I just switch to antlr 4 5 form antlr 4 4 and I don t recall this happen before edit I should point out that this occur use java 1 8 my project can be test by check out then source batfish tool batfish function sh and run batfish build in a posix shell after build once the project in batfish project batfish can be open in eclipse
antlrantlr4
why do grun xml tokens tokens t xml work for xmllexer g4
Invalid
the grammar file be xml lexer g4 so why would the follow example from the antlr book work grun xml tokens tokens t xml this work as expect grun xmllexer tokens tokens t xml this do not work as expect grun xmllex tokens tokens t xml
antlrantlr4
separate lexer parser grammar file seem to have their token number non synchronize c
Invalid
hi I write the follow small grammar for the matrix in matlab use a separate parser and lexer grammar file antlr parser grammar file matricesparsergrammar g4 grammar matricesparsergrammar option tokenvocab matriceslexergrammar matrixdef matrixdef semicolon matrixdef openbracket matrixrow closebracket matrixrow matrixrow rowbreak matrixrow matrixrow space number columnbreak number rowbreak space eol semicolon r columnbreak space space comma space antlr lexer grammar file matriceslexergrammar g4 lexer grammar matriceslexergrammar openbracket mode matrix space t r n skip semicolon mode matrix number 0 9 semicolon r comma space t eol r n closebracket mode default mode I compile the grammar use visual studio 2013 with c output the problem arise if I write the grammar like in the following where I substitute token comma with the corresponding character I get the message line 1 9 no viable alternative at input 1 line 1 9 extraneous input expect number semicolon r space eol parser grammar file matricesparsergrammar g4 grammar matricesparsergrammar option tokenvocab matriceslexergrammar matrixdef matrixdef semicolon matrixdef matrixrow matrixrow matrixrow rowbreak matrixrow matrixrow space number columnbreak number rowbreak space eol columnbreak space space space I also quote the skeleton program and the test file csharp use system use system io use system collection generic use system linq use system text use system threading task use antlr4 runtime use antlr4 runtime tree namespace matlab matrix grammar1 class program static void main string args iparsetree tree streamreader astream new streamreader args 0 antlrinputstream astream new antlrinputstream astream readtoend matriceslexergrammar lexer new matriceslexergrammar astream commontokenstream tokens new commontokenstream lexer matricesparsergrammarparser parser new matricesparsergrammarparser token tree parser matrixdef console writeline tree tostringtree test file 1 1 1 1 1 1 1 1 1 1 1 1 be this a bug or be I do something wrong
antlrantlr4
use a rule in another one change parse behavior for this rule
Duplicate
hi first thank for your great work on antlr it s a fantastic tool d I get a problem with the version 4 4 I make a rule a which work perfectly I make some test with testrig and the output be fine then I make a rule b which use the rule a this change the behavior of a parsing in a bad way the parse result be buggue the follow grammar show an example of the bug antlr grammar bug antlr lexer part keyword implementation implementation symbol semicolon comma colon dot field intro inline decl intro comparison operator equal comp not equal less or equal greate or equal strict less strict great condition combination cond and cond or affectation operator equal affect open par close par open bracket close bracket open brace close brace single quote backslash at fragment minus fragment plus fragment divide fragment time question mark operator minus plus divide time fragment d letter d fragment number 0 9 fragment letter a za z fragment alphanum letter 0 9 date single quote d letter colon number number number number minus number number minus number number single quote block and identifier fragment escape quote string escape quote n r double minus number dot number integer number i d letter alphanum we skip the whitespace ws r t n skip comment n r skip freetext semicolon eof parser rule identifier i d colon i d field field intro optionname identifier value value nonarithmeticvalue arithmeticexpression nonarithmeticvalue double string date chainedcall instanciationvariable question mark identifier expression identifi functioncall instanciationvariable functioncall identifi open par functionargument comma functionargument close par functionargument argkey i d colon value chainedcall expression dot expression inlineoperation leftexpression value operator identifier rightexpression value complexrule instanciationcondition conditionblock instanciationcondition inlineoperation foreachinstanciation variable value comma iterateditem value fullcomplexrule conditionblock complexrule comparison combinedcomparison open par combinedcomparison close par leftcondition combinedcomparison cond and rightcondition combinedcomparison leftcondition combinedcomparison cond or rightcondition combinedcomparison comparison comparison leftvalue value comparisonoperator rightvalue value comparisonoperator equal comp not equal less or equal greate or equal strict less strict great conditionblock combinedcomparison arithmeticexpression open par parenthizedexpression arithmeticexpression close par leftexpression arithmeticexpression infixedoperator operator rightexpression arithmeticexpression prefixedoperator operator arithmeticexpression nonarithmeticvalue existentialoperator operator identifier open par fullcomplexrule close par existentialoperator operator identifier open par conditionblock complexrule close par classimplementation implementation classname identifi option field freetext and the exemple to parse be the follow blob in blop blob color getdata data1 data2 blab in blab blab height null blab size getdata blip blap when we ask for a fullcomplexrule the result should be 2 complexrule but the parser lose itself and find 3 complexrule with some parse error but if we change the existentialoperator rule by remove the fullcomplexrule and put instead the content of a fullcontextrule conditionblock complexrule the parsing be correct two complex rule find the mystery become even big when we let the first existential operator definition the one which use a fullcomplexrule but we comment the classimplementationrule the parse result be also correct thank in advance babcool
antlrantlr4
two window issue
Invalid
I think I find two interesting issue when use antlr 4 5 on window 1 utf 8 support for tree dialog box when I use portuguese keyword with letter like and they aren t show correctly it can be a window cp 1252 encode issue or something else 2 confusion about and window use the former I name a package test at grammar s header use it after o tool option use it in testrig first argument like test grammartest and I get noclassdeffounderror test grammar wrong name test grammartestlexer
antlrantlr4
c target
Invalid
with the low hang fruit like javascript and c target do let s get the really useful one do a c target for antlr4 there s be a few attempt the current one embark on a dead end approach use machine translation of the java source base the target should imo generate a c 14 parser lexer with lambda callback for listener action for unicode support an icu dependency be reasonable have an issue be a start
antlrantlr4
xpathlexer not regenerate during bild properly
Bug
antlr tool version 4 4 use for code generation do not match the current runtime version 4 5
antlrantlr4
vocabulary java and vocabularyimpl java miss from new build
Invalid
I have download all three complete distribution and run time and all three be miss these two java file prevent I from compile my generate file
antlrantlr4
use of override for base visitor and listener class method cause compiler ide problem
Invalid
the generate basevisitor java and baselistener java include override annotation for all method as there be no superclass implementation of these method the various checker will generate error for every method so mark prevent eclipse from compile the source however the 1 5678 compiler will still compile the generate file in a maven build I m use eclipse 4 4 luna with the antlr 4 4 sdk version 0 3 5 on a maven project the maven plugin and dependency be all from the com tunnelvisionlabs group and be version 4 4 accord to jsr 175 section v override indicate that a method declaration be intend to override a concrete method declaration in a superclass emphasis be mine if a method be annotate with this type but do not override a superclass method compiler be require to generate an error message as an interface method be not a concrete method declaration in a superclass the use of the annotation on a method declare only in an interface should generate an error so I believe the eclipse checker be behave correctly jsr 175 appendix ii design faq semantic address the issue more directly 2 why doesn t the override annotation let you confirm that you ve overridden a method in an interface as well as a superclass the compiler already tell you if you ve fail to override an interface method assume you implement the interface it would be redundant and confusing to offer similar functionality with the override annotation I believe the correct fix be to remove the override annotation from the generate base class method
antlrantlr4
parameter initialisation
Duplicate
antlr sequence int n local int I 1 le i ne s initialise pas correctement avec 1 il prend toutjour 0 I n int system out println I I I think that all person who read the book antlr4 have see this code I try it but he doesn t initialise the i to 1 but it take 0 and increment it I print out to confirm and the result be 0 1 2 where n 2 so it take the 0 and to fix it very simple antlr sequence int n local int I 1 le i ne s initialise pas correctement avec 1 il prend toutjour 0 I 1 n int system out println I I but I would know if it s a bug or a kind of configuration thx
antlrantlr4
add way to notify error listener about semantic error with no reasonable location
Invalid
after do visit the parse tree during the semantic phase one might want to perform other error check like emit an error if a particular element be not present in that case there be no reasonable location for the error except perhaps end of file I would like to show a well error message in the error listener show eof or error instead of the location but there be no way to get a message to the error listener that do not include location information a workaround could be to directly tell the error listener that eof have be reach and to ignore the location information when print error after that
antlrantlr4
can not mix leave recursive rule with rule argument
Duplicate
the follow grammar fail to compile with the error below grammar test a b c b ctx a b b x c parserrulecontext context y error 50 2 45 syntax error come as a complete surprise to I while look for rule element org antlr v4 parse grammartreevisitor g node from after line 2 26 mismatch tree node 2 45 resync c expect org antlr v4 parse grammartreevisitor g node from line 6 9 mismatched tree node expect org antlr v4 parse grammartreevisitor g node from after line 2 26 mismatch tree node 2 45 resync c expect org antlr v4 parse grammartreevisitor g node from line 6 9 mismatched tree node expect org antlr v4 parse grammartreevisitor g node from after line 2 26 mismatch tree node 2 45 resync c expect org antlr v4 parse grammartreevisitor g node from line 6 9 mismatched tree node expect it work if I factor out b c b ctx into a separate rule or if I remove the left recursion from a grammar test a d a b b x c parserrulecontext context y d b c b ctx
antlrantlr4
stackoverflowerror with non left factored term
Invalid
the follow grammar grammar test expression numeric primary numeric numeric comparison numeric between numeric and numeric between numeric number atom numeric numeric multiplicative numeric numeric additive numeric negative expression nest number 0 9 ws r n t channel hide result in a stackoverflowerror when use like this java import com google common base joiner import org antlr v4 runtime antlrinputstream import org antlr v4 runtime commontokenstream import java util collection public class test public static void main string args parse joiner on join collection ncopie 1000 1 parse joiner on join collection ncopie 1001 1 parse joiner on join collection ncopie 1002 1 private static void parse string expression testlexer lexer new testlexer new antlrinputstream expression testparser parser new testparser new commontokenstream lexer parser expression exception in thread main java lang stackoverflowerror at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 at org antlr v4 runtime atn predictioncontext mergearray predictioncontext java 420 at org antlr v4 runtime atn predictioncontext merge predictioncontext java 199 I can get around the issue if I leave factor numeric in expression like this expression numeric numeric between numeric and numeric but I lose the ability to label alternative which make process the result parse tree much hard I m use antlr 4 3 by the way
antlrantlr4
python 2 target generate buggy grammar parser
Invalid
hello I ve create a rather simple grammar for parse some part of sshd config file and unfortunately I have to use python2 as target language I generate python parser lexer with the follow command java jar antlr 4 4 complete jar dlanguage python2 sshdgrammar g4 and then try to ran it with the code I take from here python parser py exmpl txt traceback most recent call last file parser py line 14 in main sys argv file parser py line 11 in main tree parser match block file home artemz document sshd config parser sshdgrammarparser py line 123 in match block self match file home artemz document sshd config parser sshdgrammarparser py line 189 in match self match self match keyword typeerror match take exactly 1 argument 2 give seem like the generate parser be buggy
antlrantlr4
include javac or jbc emit visitor with antlr runtime
Invalid
currently the expect consumption model for antlr involve participation from a pre build step such that the grammar be turn into generate code for use on the application this put a stress on antlr user as it require they to have an understanding of a consumption model significantly more complex than any other library they re likely use while also require user to have the dicipline and organization to avoid edit the generate code my first encounter with generate code be with a visual studio generate c soap proxy for sprint telecom webservice I hadn t yet hear of codinghorror com but that be exactly the face I make generate code be a really difficult thing to new developer and imho should be avoid if at all possible I believe it would be a boon to the antlr library to skip the generate source code portion entirely and simply allow user to supply gammar file at run time and get back ready to use parser object this could presumably be hack in fairly simply by include the tool jar and use toolprovider getsystemjavacompiler as part of your distributable I have no idea if this be sanction by oracle s license of tool jar or if its technically feasible under toolprovider s fairly explicit class loader code a more elegant solution would be to simply include a byte code generating visitor instead of a source code generating visitor as part of the antlr package this be beyond my skill however it be implement I would suggest expose such an api similarly to how java expose its regex engine the expect consumption model be that you statically build the pattern object ask it for matcher s on source string java step one compile the pattern to an automata generator I believe thus do the bulk of computation around parse and code generation public static final pattern assignment pattern pattern compile w 0 9 w 0 9 0 9 0 9 the equivalent antlr statement might be public static final parser assignment parser parser compiledfor path to grammar gr public void consumermethod string documenttomatchongammar step two ask the automata generator for a machine whose input be point at this string matcher matcher assignment pattern match documenttomatchongrammar step three use the machine to iterate through the string to find interesting bit while matcher find string assignee matcher group 0 string assigner matcher group 1 do some business logic on the match string thank for reading and I hope I m not waste your time
antlrantlr4
javadoc issue with jdk1 8 and maven
Duplicate
for reason know only to oracle but most likely they do not think it through the javadoc command in jdk 8 operate as follow xdoclint be on by default which mean it spit out lot of warning and error this option seem to treat warning in the same way as error when the javadoc command see error and warning it exit with an error code on the face of it this be no big deal and the javadoc should in fact be keep nicely however when build with maven and probably other system this present a problem because an error exit code from the javadoc command cause the build to fail the javadoc plugin can be configure like this org apache maven plugins maven javadoc plugin 2 9 1 xdoclint none but that cause other problem if you want your build to support jdk1 7 as well as 1 8 this be because the jdk1 7 version of the javadoc command do not support the xdoclint none option and so the build then fail with an invalid option on jdk1 7 there be one final option which be to add the false option however this do not always work so a catch 22 situation so the only real option here be to fix the javadoc annotation and this be why it be relevant to antlr4 the issue be that antlr 4 generate a lot of invalid javadoc with the default jdk1 8 javadoc option at least in the main a few invalid html element within the generate listener and elsewhere create tag in the listener to rule in the parser that do not exist when an alt be tag the main invalid element be the use of self closing element be not allow and this should be just I have not generate every possible code combination to test it all use of self closing attribute xparserbaselistener java inheritdoc the default implementation do nothing override public void enterparen notnull xparser parenscontext ctx link to a non existent superclass method xparserlistener java exit a parse tree produce by link xparser arith param ctx the parse tree void exitarith notnull xparser arithcontext ctx the above be generate from a parser rule such as andexp somerule somerule arithexp arith the documentation should link to the parser method andexp and not to the non existent arith method I can submit patch for this annoyance by the jdk 1 8 javadoc config but I be not sure when I will get the time if anyone have time for a quick fix
antlrantlr4
grammar doesn t generate local variable declaration
Duplicate
relate stackoverflow question the problem be that parser contain line with public hashmap name with miss new hashmap I spend hour on debug that I hope this isn t feature instead of a bug in that case I apologize for spam
antlrantlr4
xml grammar not work
Invalid
I generate xml parser and lexer from xml grammar file in grammar v4 when I try to parse xml file I always get the follow error line 1 0 no viable alternative at input be this a bug
antlrantlr4
unexpected code generation location behavior
Bug
on window antlr 4 4 might be relate to 638 the follow work as expect grammar exist in the parent directory parser all generate file wind up in the current directory gen cd d d devfile java jsoneditor src net certiv json parser gen java org antlr v4 tool jsonlexer g4 jsonparser g4 the follow fail cd d d devfile java jsoneditor src net certiv json parser gen java org antlr v4 tool jsonlexer g4 jsonparser g4 jsonlexer java and jsonlexer token be generate in the parent directory parser and the compile of the jsonparser g4 fail say that it can not find the jsonlexer token in the current directory gen note the difference in the slash in the grammar path work completely as expect but work sufficiently for the tool to find the grammar but generate in the wrong directory add o and lib option in various combination don t affect the result this problem be encounter while rebuild an early antlr4 project so use apparently work as expect way back then
antlrantlr4
parsetreevisitor call visit method for child
Duplicate
allow subclass to override visit if they want to be call for each visit to a child
antlrantlr4
wrong javadoc for label alternative
Duplicate
when use label alternative mylangpars mylabelcontext class for each label be create which the javadoc in the generate mylanglistener reference however the link be for mylangpars mylabel instead of mylangpars mylabelcontext which lead to warning when javadoc validation be enable
antlrantlr4
visitchildren visitor be not work
Invalid
I create a grammar that mixed lexer and parser and use a visitor class to visit each node of the parse tree it work very well in my customize visitor class I create separate visiteachnode method to get all the value for each node then I modify the grammar create separate lexer and parser in the lexer I create a new mode besides the default mode when I use the same customized visitor class again all visiteachnode method stop work except the root visitroot method be execute because it be explicitly call what confuse I be that why other visiteachnode method be not work the sample code I use be java grammernameparser parser new grammernameparser grammernamecontext tree parser grammername visitor visitor new visitor string result visitor visitgrammername tree here visitroot be equal to visitgrammarname in the customize visitor class it have visitgrammername visitnode1 vistinode2 do you have any idea why it be not work thank nan
antlrantlr4
leave recursive grammar rule cause slow performance in sll mode
Invalid
the grammar and script contain here perform very poorly even in sll mode it seem cause and this be how far I be able to go as some bad interaction between these rule in the grammar anonfunctiondef prefixexp the left recursive operator declare in exp it s not clear to I how anonfunctiondef could have an effect as it start with a sequence of two literal token which do not appear in sequence in the script file this issue be originally report on google group here topic antlr discussion ue v9l6pfwe I still have doubt that it could be a bug in the grammar due to the interaction of those rule but honestly I don t know how to go far in analysis and suspect some strange behavior of antlr might be cause the issue but I m not sure at all as I m no expert in this field
antlrantlr4
regard antlr 4 4 version on maven central repository
Duplicate
antlr 4 4 have be release for some month but I still can not get it from maven central repository only antlr 4 3 be available xml org antlr4 antlr4 runtime 4 3 another way I find an antlr 4 4 under com tunnelvisionlabs xml com tunnelvisionlabs antlr4 runtime 4 4 do you change the groupid for antlr4 be it an offical maven release
antlrantlr4
token recognition error at 1
Invalid
lexer java 387 java string msg token recognition error at geterrordisplay text do not return quot token recognition error at lt eof gt quot as plan because it create a java string msg token recognition error at geterrordisplay geterrordisplay 1 in 396 line
antlrantlr4
error when build into eclipse plugin classnotfoundexception org antlr v4 runtime charstream
Duplicate
hello I have successfully create a listener class to parse file use a modified java g4 for java 1 7 grammar all unit test run from within eclipse successfully now I want to incorporate the listener into an eclipse plugin I have a successful plugin to which I be attempt to add the functionality of the listener all compile fine and unit test be still successful but when execute the eclipse plugin the stacktrace below I have google d quite a bit but haven t yet find a solution I have antlr on my classpath I have include it in the project as a user library I be open to any suggestion regard todd configuration antlr 4 4 complete jar mac os x 10 9 4 eclipse kepler junit 4 11 0 org eclipse e4 core di injectionexception java lang noclassdeffounderror org antlr v4 runtime charstream at org eclipse e4 core internal di methodrequestor execute methodrequestor java 63 at org eclipse e4 core internal di injectorimpl invokeusingclass injectorimpl java 243 at org eclipse e4 core internal di injectorimpl invoke injectorimpl java 224 at org eclipse e4 core contexts contextinjectionfactory invoke contextinjectionfactory java 132 at org eclipse e4 core command internal handlerservicehandler execute handlerservicehandler java 167 at org eclipse core command command executewithcheck command java 499 at org eclipse core command parameterizedcommand executewithcheck parameterizedcommand java 508 at org eclipse e4 core command internal handlerserviceimpl executehandler handlerserviceimpl java 213 at org eclipse e4 ui workbench renderer swt handledcontributionitem executeitem handledcontributionitem java 850 at org eclipse e4 ui workbench renderer swt handledcontributionitem handlewidgetselection handledcontributionitem java 743 at org eclipse e4 ui workbench renderer swt handledcontributionitem access 7 handledcontributionitem java 727 at org eclipse e4 ui workbench renderer swt handledcontributionitem 4 handleevent handledcontributionitem java 662 at org eclipse swt widget eventtable sendevent eventtable java 84 at org eclipse swt widget display sendevent display java 4166 at org eclipse swt widget widget sendevent widget java 1466 at org eclipse swt widget widget sendevent widget java 1489 at org eclipse swt widget widget sendevent widget java 1474 at org eclipse swt widget widget notifylistener widget java 1279 at org eclipse swt widget display rundeferredevent display java 4012 at org eclipse swt widget display readanddispatch display java 3651 at org eclipse e4 ui internal workbench swt partrenderingengine 9 run partrenderingengine java 1113 at org eclipse core databinde observable realm runwithdefault realm java 332 at org eclipse e4 ui internal workbench swt partrenderingengine run partrenderingengine java 997 at org eclipse e4 ui internal workbench e4workbench createandrunui e4workbench java 140 at org eclipse ui internal workbench 5 run workbench java 611 at org eclipse core databinde observable realm runwithdefault realm java 332 at org eclipse ui internal workbench createandrunworkbench workbench java 567 at org eclipse ui platformui createandrunworkbench platformui java 150 at org eclipse ui internal ide application ideapplication start ideapplication java 124 at org eclipse equinox internal app eclipseapphandle run eclipseapphandle java 196 at org eclipse core runtime internal adaptor eclipseapplauncher runapplication eclipseapplauncher java 110 at org eclipse core runtime internal adaptor eclipseapplauncher start eclipseapplauncher java 79 at org eclipse core runtime adaptor eclipsestarter run eclipsestarter java 354 at org eclipse core runtime adaptor eclipsestarter run eclipsestarter java 181 at sun reflect nativemethodaccessorimpl invoke0 native method at sun reflect nativemethodaccessorimpl invoke nativemethodaccessorimpl java 57 at sun reflect delegatingmethodaccessorimpl invoke delegatingmethodaccessorimpl java 43 at java lang reflect method invoke method java 606 at org eclipse equinox launcher main invokeframework main java 636 at org eclipse equinox launcher main basicrun main java 591 at org eclipse equinox launcher main run main java 1450 at org eclipse equinox launcher main main main java 1426 cause by java lang noclassdeffounderror org antlr v4 runtime charstream at com myorg yyy analyzer eclipse handler xxx convertjavaresource xxx java 91 at com myorg yyy analyzer eclipse handler xxx execute xxx java 60 at org eclipse ui internal handler handlerproxy execute handlerproxy java 290 at org eclipse ui internal handler e4handlerproxy execute e4handlerproxy java 90 at sun reflect nativemethodaccessorimpl invoke0 native method at sun reflect nativemethodaccessorimpl invoke nativemethodaccessorimpl java 57 at sun reflect delegatingmethodaccessorimpl invoke delegatingmethodaccessorimpl java 43 at java lang reflect method invoke method java 606 at org eclipse e4 core internal di methodrequestor execute methodrequestor java 56 41 more cause by java lang classnotfoundexception org antlr v4 runtime charstream can not be find by xxx 1 0 0 qualifier at org eclipse osgi internal loader bundleloader findclassinternal bundleloader java 501 at org eclipse osgi internal loader bundleloader findclass bundleloader java 421 at org eclipse osgi internal loader bundleloader findclass bundleloader java 412 at org eclipse osgi internal baseadaptor defaultclassloader loadclass defaultclassloader java 107 at java lang classloader loadclass classloader java 357
antlrantlr4
segfault import antlr4 cygwin
Invalid
I be have difficulty use antlr4 under cygwin be there a workaround for this uname a cygwin nt 6 1 tmc002 1 7 31 0 272 5 3 2014 07 25 11 26 x86 64 cygwin gunzip c antlr4 python2 runtime 4 4 1 tar gz tar xf cd antlr4 python2 runtime 4 4 1 python setup py build python setup py install python python 2 7 8 default jul 25 2014 14 04 36 gcc 4 8 3 on cygwin type help copyright credit or license for more information import antlr4 segmentation fault core dump
antlrantlr4
mismatchedtokenexception consider overriding fillinstacktrace to speed thing up
Invalid
we ve notice thousand of call to mismatchedtokenexception constructor during our script compilation please consider suppress stack collection in mismatchedtokenexception class that can be do by override mismatchedtokenexception fillinstacktrace with empty method thank in advance we re use antlr that be part of groovy 2 3 0
antlrantlr4
can t use quote token in non combine grammar
Invalid
I be write combine grammar and when it become big enought I decide to split it on parser and lexer now I can t build project due to lot of error as for example can not create implicit token for string literal in non combine grammar now I have to rewrite my rule comparisonoperator twoargslist expression expression like this comparisonoperator equal great equal less equal great notoperator equal great great twoargslist leftparenthesis expression comma expression rightparenthesis the first example be short and more understandable so I don t want to rewrite my grammar as it show in the second example there be the possibility in antlr v3 to use quote token in non combine grammar why this feature be remove as a workaround I can use combine grammar and declare rule only for parser unfortunately this solution not suitable for I because of issue 699
antlrantlr4
c compiler can t compile generate lexer
Invalid
csc give I follow error without name of the file line and column only project name error 4 an expression be too long or complex to compile I find the reason for this error unfortunately there s not much we can do here without isolate the issue far usually this error result from a deeply chain expression in your source such as a long chain of string concatenation aaaa bbbb such expression be parse and bind recursively in the compiler and there be a depth at which the compiler will run out of stack space to continue parse the exact expression complexity support depend on the datum stash in the compiler s stack frame which can vary subtly between update if an expression in your solution be right at the boundary before it may have tip over there be a huge string in generate lexer over 5000 line which look like this csharp public static readonly string serializedatn x3 xaf6f x8320 x479d xb75c x4880 x1605 x191c xab37 x2 x37d x2d79 b x1 x4 x2 t x2 x4 x3 t x3 x4 x4 t x4 x4 x5 t x5 x4 x6 t x6 x4 a t a x4 b t b x4 t t t x4 n t n x4 v t v x4 f t f x4 r t r x4 xe t xe x4 xf t xf x4 x10 t x10 x4 x11 t x11 x4 x12 t x12 x4 x13 t x13 x4 x14 t x14 x4 x15 t x15 x4 x16 t x16 x4 x17 t x17 x4 x18 t x18 x4 x19 t x19 x4 x1a t x1a x4 x1b t x1b x4 x1c t x1c x4 x1d t x1d x4 x1e t x1e x4 x1f t x1f x4 t x4 t x4 t x4 t x4 t x4 t x4 t x4 t x4 t x4 t any workaround would be very helpful
antlrantlr4
antlr 4 do not like grammar file with block comment start with
Duplicate
antlr 4 4 fail to parse antlr grammar file contain 2 successive javadoc style comment for instance the follow grammar fail to parse with error 50 syntax error n comment block2 n come as a complete surprise to I antlr grammar mygrammar comment block 1 comment block2 xxx xxx however the follow work fine antlr grammar mygrammar comment block 1 comment block2 xxx xxx the only difference be that a character be remove at the begining of the second comment
antlrantlr4
gethashline for c
Invalid
aaaa only support for c please copy paste into c generator
antlrantlr4
tool issue output directory must assume package structure
Duplicate
run the antlr4 tool target language be java as below org antlr v4 tool o antlr generate package antlr generate foo g4 run this result in build error the generate file be place in the default package I can get around this by specify the package structure in my file output argument like this org antlr v4 tool o antlr generate antlr generate package antlr generate foo g4 be there a particular reason that tool do not create this package structure for I
antlrantlr4
work on parse tree antlr4 c
Invalid
I have just start work on antlr4 with mathematical equation program that apply some operator on they I create the grammar as follow antlr prog expr expr multexpr op multexpr addsub multexpr powerexpr op powerexpr muldiv fun powerexpr function powerexpr unaryexpr unaryexpr unaryexpr atom minus atom posative fun atom function atom num rational int int var variable expr paren num int int compileunit eof lexer rule fun sin cos tan var a z a z int 0 9 mul div add sub pow dot after build the project I have get the class of the lexer and the parser but I didn t find the function that return the parse tree would you help I to access it
antlrantlr4
label for group address only first item
Invalid
I find this question on stackoverflow after investigate the problem I find out that in the follow part of a rule the label content refer only to the first or maybe last non semicolon token instead of the complete group this be why the type of somerulecontext content be commontoken constraintname alter table constraint name check content altertableaddcheck imho it should refer to the complete group
antlrantlr4
transmit token on different channel in python lexer
Duplicate
when generate a java lexer for c g4 as with antlr4 c g4 transmit token on a different channel can be accomplish with e g lexer member public static final int whitespace 1 public static final int comment 2 however when generate a python2 lexer as with antlr4 dlanguage python2 c g4 and lexer member whitespace 1 comment 2 the result clexer py contain python code like def whitespace action self localctx actionindex if actionindex 2 channel whitespace whereby whitespace be thus assume to be a global symbol and not a class variable and so lexe fail with nameerror global name whitespace be not define a workaround be to change lexer member to be lexer member global whitespace whitespace 1 global comment comment 2 or simply to use e g channel 1 instead of channel whitespace in the grammar or to edit the generate code to use self whitespace be there mean to be a clean solution though perhaps relate in spirit to 309 many thank
antlrantlr4
grammar not allow in superclass fully qualified class name in antlr 4 3
Invalid
the following be illegal but probably shouldn t be option superclass batfish grammar batfishlexer since I didn t want to rename my grammar package I resort to option superclass batfish util dummylexer where dummylexer trivially extend batfish grammar batfishlexer
antlrantlr4
check the existance of the token when use tokenvokab option
Invalid
if I use undeclared token in the grammar antlr doesn t show any error I think it be well to show an error or warning
antlrantlr4
predicate in the parser without obvious reason
Invalid
predicate in the rule namewithdatabase the only way to get rid of the predicate be to remove the left recursion in the rule expression somehow it lead to the predicate my combined grammar parser rule binaryoperator unaryoperator namewithdatabase identifi identifi identifi expression expression binaryoperator expression unaryoperator expression expression opendatasource string string namewithdatabase variable string int hex decimal null default false true lexer rule ws t r n channel hide comment r n channel hide string delimeter dot int 0 9 hex 0x number a f a f decimal number number variable letter identifi letter letter number z fragment letter a z a z fragment number 0 9
antlrantlr4
parser rule no long accessible
Invalid
change from antlr 4 2 2 complete jar to antlr 4 3 complete jar and 4 4 break access to parser rule dot start parser value init logger enter classname value value start somerule error 65 sqlpars g4 164 49 unknown attribute start for rule value in value start 1 error s it still work for lexer rule set assignment expression this arraydimension settingsblock util notsupporte getsourcename this set block this not implement yet getcontext gettext
antlrantlr4
nullpointerexception in org antlr v4 runtime parser notifyerrorlistener offendingtoken be null
Invalid
I don t really understand what the actual cause of this problem be but I attach a project which illustrate the issue
antlrantlr4
antlr4 go lang target
Invalid
be there any plan or ongoing effort for a go lang target
antlrantlr4
c not properly document
Invalid
I consider it a bug when at the top of the antlr4 4 3 june 18 2014 download page it say that c be a support target but below in the c target section you click on antlr 4 c target late release and it bring you to a page who s late article be v4 2 2 alpha001 date april 8th similarly on the download page there s a link to c antlr 4 target at github that have a date of april 28th so I really don t know exactly what to do to generate a c base parser etc do I download the main java code and find that it s there do I need special runtime routine presumably but if so where exactly be they and what be they and so on have anything change since april if so what if not say so in either case point to definitive 4 3 document code whatever for the c target yes I know sam be busy yes I know this he s essentially do this out of the goodness of his heart but dammit if you re go to do something do it right can terrence and sam get on the same page when they announce a new release and why do I have the fear that you ll have exactly the same problem when you release new target the python javascript c target you mention
antlrantlr4
compile seperate lexer and parser in subdirectory fail
Bug
if one define a seperate parser and lexer as such lexer g4 lexer grammar lexer token indent dedent int 0 9 parser g4 parser grammar parser option tokenvocab lexer main int eof with the follow directory layout project src lexer g4 parser g4 build antlr4 2 2 complete jar compile from the project directory with the follow command java jar antlr 4 2 2 complete jar o build src g4 fail with error 3 can not find token file build lexer token lexer token be correctly generate but be in build src lexer token as expect this work fine if the grammar file be in the current directory when compile they ie one run java jar antlr 4 2 2 complete jar o build g4 or if an extra lib build src option be use it seem this shouldn t be require and antlr should know where to find the tokens file it generate update here be some additional detail about the propose feature for the follow assume this directory layout project src foo lexer g4 metarparser g4 tafparser g4 bar notamparser g4 build with the follow dependency between the grammar lexer g4 metarparser g4 lexer g4 notamparser g4 lexer g4 tafparser g4 notamparser g4 in all the follow case it be assume that all of the grammar file be compile in a single invocation of antlr and that we want the generate file to be in the build directory optionally in sub folder 1st case all grammar in work directory we wish to compile metarparser g4 our work directory be project src foo run command antlr g4 o build observe behavior antlr compile lexer g4 lexer g4 have a relative path of the generate token file be therefore in build antlr add the build directory to it s lib search path antlr compile meterparser g4 antlr search the lib directory for the require lexer token antlr correctly find the lexer token file in build desire behavior same 2nd case all grammar be in a give subdirectory we wish to compile metarparser g4 our work directory be project run command antlr src foo g4 o build observe behavior antlr compile lexer g4 lexer g4 have a relative path of src foo the generate token file be therefore in build src foo antlr add the build directory to it s lib search path antlr compile metarparser g4 antlr search the lib directory for the require lexer token antlr faile to find lexer token as build src foo be not it s search path desire behavior antlr compile lexer g4 lexer g4 have a relative path of src foo the generate token file be therefore in build src foo antlr add the build src foor directory to it s lib search path antlr compile metarparser g4 antlr search the lib directory for the require lexer token antlr correctly find the lexer token file in build src foo 3rd case all grammar be in potentially different subdirectory we wish to compile tafparser g4 our work directory be project run command antlr src foo g4 src bar tafparser g4 o build observe behavior antlr compile lexer g4 lexer g4 have a relative path of src foo the generate token file be therefore in build src foo antlr add the build directory to it s lib search path antlr compile notamparser g4 antlr search the lib directory for the require lexer token antlr faile to find lexer token as build src foo be not it s search path desire behavior antlr compile lexer g4 lexer g4 have a relative path of src foo the generate token file be therefore in build src foo antlr add the build src foo directory to it s lib search path antlr compile notamparser g4 notamparser g4 have a relative path of src bar the generate token file be therefore in build src bar antlr add the build src bar directory to it s lib search path antlr search the lib directory for the require lexer token antlr correctly find the lexer token file in build src foo antlr compile tafparser g4 antlr search the lib directory for the required notamparser token antlr correctly find the notamparser token file in build src bar for the last two case all that be require be to keep track of the actual output directory ie the directory specify with o switch or the work directory with the correct subdirectory for every file and to search those
antlrantlr4
no viable alternative at input
Duplicate
the follow grammar grammar expr expr expr expr int int 0 9 with the input 42 it throw line 1 1 no viable alternative at input eof only add a rule as expr it start to work fine
antlrantlr4
whitespace skip accept 3 3 as expr 3
Duplicate
a very simple grammar to understand grammar expr expr int int 0 9 ws t r n skip accept 3 3 and it parse the string as expr 3 fortunately if one try with one as the example in the home page grammar expr expr expr expr expr expr int expr int 0 9 ws t r n skip it return the error line 1 2 extraneous input 3 expect and seem to work but despite of that with the strategy bailerrorstrategy no error be throw thank you antlr4 it s very powerful and simple
antlrantlr4
reportattemptingfullcontext didn t get conflict alt unless decision
Duplicate
have predicate
antlrantlr4
crash during normal use of antlrv4 2 2
Duplicate
just compile a grammar give this though at least the generate file be produce line 7 be just the grammar declaration element option and right do not appear in the file antlr tool v4 2 2 c user dcok appdata local temp antlr 4 2 2 complete jar acsl g4 o c cygwin home sb bj trunk nasa speedy annotationeditor target generate source antlr4 speedy acsl antlr listener no visitor encode utf 8 org antlr v4 parse atnbuilder g node from line 7 10 no viable alternative at input element option org antlr v4 parse atnbuilder g node from line 7 17 no viable alternative at input right exception in thread main java lang nullpointerexception at org antlr v4 automata parseratnfactory elemlist parseratnfactory java 484 at org antlr v4 automata parseratnfactory alt parseratnfactory java 473 at org antlr v4 parse atnbuilder alternative atnbuilder java 568 at org antlr v4 parse atnbuilder ruleblock atnbuilder java 290 at org antlr v4 automata parseratnfactory createatn parseratnfactory java 184 at org antlr v4 automata parseratnfactory createatn parseratnfactory java 134 at org antlr v4 tool processnoncombinedgrammar tool java 405 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190
antlrantlr4
how to get a phrase in a sentence
Invalid
for example if a b then 1 else 2 I have define if then and else as keyword in grammar be there any way to define the grammar so that I can get a b thank
antlrantlr4
error when generate parser from grammar
Duplicate
when attempt to generate a parser for a grammar I m write I m leave with a number of exception and be have trouble figure out what the problem be can t find rule grammarspec or tree structure error combine grammar java lang reflect invocationtargetexception at sun reflect nativemethodaccessorimpl invoke0 native method at sun reflect nativemethodaccessorimpl invoke nativemethodaccessorimpl java 57 at sun reflect delegatingmethodaccessorimpl invoke delegatingmethodaccessorimpl java 43 at java lang reflect method invoke method java 606 at org antlr v4 parse grammartreevisitor visit grammartreevisitor java 207 at org antlr v4 parse grammartreevisitor visitgrammar grammartreevisitor java 201 at org antlr v4 semantic symbolcollector process symbolcollector java 76 at org antlr v4 semantic semanticpipeline process semanticpipeline java 103 at org antlr v4 tool processnoncombinedgrammar tool java 397 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190 cause by java lang arrayindexoutofboundsexception 2 at org antlr v4 semantic symbolcollector discoverouteralt symbolcollector java 111 at org antlr v4 parse grammartreevisitor outeralternative grammartreevisitor java 2285 at org antlr v4 parse grammartreevisitor ruleblock grammartreevisitor java 2198 at org antlr v4 parse grammartreevisitor rule grammartreevisitor java 1664 at org antlr v4 parse grammartreevisitor rule grammartreevisitor java 1242 at org antlr v4 parse grammartreevisitor grammarspec grammartreevisitor java 481 12 more exception in thread main java lang nullpointerexception at org antlr v4 tool rule getaltlabel rule java 217 at org antlr v4 tool rule hasaltspecificcontexts rule java 200 at org antlr v4 semantic symbolcheck checkforlabelconflict symbolcheck java 157 at org antlr v4 semantic symbolcheck process symbolcheck java 105 at org antlr v4 semantic semanticpipeline process semanticpipeline java 107 at org antlr v4 tool processnoncombinedgrammar tool java 397 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190 the tree it be output and go from what appear to be the top from the bottom look through the code and the generate tree it look like there be no grammarspec rule that be define which be cause the the failure at line 103 of grammartreevisitor g I ve see mention of this error in case with left recursion on google but I don t see any reporting from antlr that there be any issue can someone point I in the right direction as to what be happen and how to resolve this or if it be just a bug in antlr I m use antlr 4 2 2 from the official jar on the website on os x 10 9 2 with java 1 7 0 51 b13
antlrantlr4
antlr4 lexer parser
Invalid
I have be have problem with this for a while now and can t seem to solve so it would be great if some of you could help basically I be use the late antlr 4 2 2 and keep get this problem can t load as lexer or parser everytime I try to run the test rig on my grammar to show I the tree I have be able to compile my java file so I now have class file but I can not get pass this stage I be use the command below to try and use the testrig on my grammar java org antlr v4 runtime misc testrig c user wuffle desktop antlr pas pas program tree and the follow for my classpath set classpath c user wuffle desktop antlr antlr 4 2 2 complete jar classpath anyone able to solve this or be more information require
antlrantlr4
tokenstreamrewriter doesn t preserve override order
Bug
output order differ when many override be insert with the same index I use tokenstreamrewriter in listener when a placeholder rule be enter I put tag into rewriter with insertbefore when the placeholder be exit I put tag into rewriter with insertafter everything be fine with call sequence but rewriter gettext return something like the following when placeholder be side by side and not separate with some other lexer token placeholder1 placeholder1
antlrantlr4
error range
Duplicate
hello I ve a problem I think form deep of library grammar grammar regular start regex regex a z and I can not compile it error log I m use antlr 4 2 2 complete jar
antlrantlr4
x x x y sometimes cause no viable alternative
Duplicate
feed the follow grammar antlr grammar demo x x x y with the input yy like this bash echo n yy java cp antlr jar org antlr v4 runtime misc testrig demo x gui produce the correct tree but with the follow message line 1 2 no viable alternative at input if I slightly adapt the grammar like this antlr grammar demo s x x x x y the exact same call to testrig will cease to emit the error message note that I don t even use the rule s anywhere in both case I specify x as the start rule I believe that the insertion deletion of an unused rule should not have such an effect
antlrantlr4
part of the input ignore in create parse tree in intellij plugin
Invalid
here be a grammar where I accidentally misdefine variable name rule nimi so that it doesn t allow single character name to my surprise when I test rule avaldis in antrl4 intellij plugin plugin version 1 0 2 intellij version 13 1 1 with input 1 a 2 2 it give I nice and wrong parse tree which be simply miss the a parsetree
antlrantlr4
lexer rule information require
Invalid
I have the follow lexer rule asc a s c a s c e n d I n g a s a s etc be like fragment s s s I be use this rule in a parser rule sortspecification sortkey sortorder nullorder sortorder asc desc in my java visitor then I have a code to use it sortorder so sortorder valueof sortitemctx sortorder gettext sortorder be an enum of asc desc the problem be that when the asc rule be match by as or ascend it be no possible to convert it the enum I be wonder whether there be a way to get the rule name info object from the context sortitemctx so that regardless of the alternative I have asc to rely on something like sortitemctx getrule return the asc rule object getrulename return asc string
antlrantlr4
why target language when we can have target format
Invalid
yo I be wonder why not support ast generation in a common format like xml json I think it would be quite helpful for all those who wanna write their dsls implementation cheer
antlrantlr4
pick up java installation via environment variable
Invalid
I create a c project that use antlr4 use the antlr4 c vs extension in vs20120 everything build fine on the local machine now I be try to hook up the solution to my company s automate build system when the build run I get the follow error package antlr4 4 1 0 alpha003 build antlr4 target 132 5 error ac1000 unknown build error could not locate a java installation it appear that have java instal on the machine be require however I need to be able to have the java installation pick up by an environment variable java home or path how can I get that to work
antlrantlr4
antlr v4 2 give warning when static int use as channel
Duplicate
I have this lexer member lexer member public static final int whitespace 1 public static final int linebreak 2 public static final int comment 3 public static final int ppdir 4 and some rule that use the static constant as channel number e g ml comment channel comment this work well in antlr v4 1 but in v4 2 the code generation tool give I warn java cp antlr4 antlr 4 2 complete jar org antlr v4 tool o work parsersrc no listener visitor cppdefine g4 warn 155 cppdefine g4 204 37 rule ml comment contain a lexer command with an unrecognized constant value lexer interpreter may produce incorrect output what be wrong with this
antlrantlr4
need action when match a fragment lexer rule
Duplicate
I need to translate a token that be a fragment token before send it to the parser I begin a v4 2 antlr grammar because it do support lexer mode I don t know if I should come back to the v3 antlr grammar from which I do have the documentation translate the final token would mean 2nd level parsing of a long string for performance reason I need the translation to be do in the lexer at the level of the fragment rule
antlrantlr4
allow super class with generic in superclass option
Invalid
superclass option parse rule do not support and symbol so one can not specify a super class with generic option superclass mysuperclass syntax error mismatch input expect semi
antlrantlr4
compile the grammar with antlr 4 2 cause a lexer error
Invalid
I have upgrade to java 8 and antlr 4 2 snapshot now when I generate my grammar the lexer parser listener visitor and token file be create but there be a suppresswarning all warning unchecked unused cast on the lexer class xqtlexer in my case which netbean 7 3 on java 8 do not like it it show the message annotation type not applicable to this type of declaration when I remove it it nag that duplicate class the grammar be fine and work with antlr 4 1 java 7 this be the command I issue to compile the grammar java cp d tool ide antlr antlr4 antlr 4 2 complete jar org antlr v4 tool d sciql src xqt lang src xqt lang grammar source xqt g4 o d sciql src xqt lang src xqt lang grammar listener visitor package xqt lang grammar also the antlrworks 2 1 on nb 7 4 do not generate java file anymore
antlrantlr4
download link return 404 error
Invalid
bring up a github 404
antlrantlr4
nullpointerexception use jre8
Duplicate
run java org antlr v4 tool tour expr g4 throw this exception in thread main java lang indexoutofboundsexception index 0 size 0 at java util arraylist rangecheck unknown source at java util arraylist get unknown source at org antlr v4 misc orderedhashmap getelement orderedhashmap java 46 at org antlr v4 analysis leftrecursiveruletransformer setaltastpointer leftrecursiveruletransformer java 241 at org antlr v4 analysis leftrecursiveruletransformer translateleftrecursiverule leftrecursiveruletransformer java 162 at org antlr v4 analysis leftrecursiveruletransformer translateleftrecursiverule leftrecursiveruletransformer java 89 at org antlr v4 semantic semanticpipeline process semanticpipeline java 94 at org antlr v4 tool processnoncombinedgrammar tool java 399 at org antlr v4 tool process tool java 384 at org antlr v4 tool processgrammarsoncommandline tool java 343 at org antlr v4 tool main tool java 190 the problem be the java version I use jre 8 java version 1 8 0 ea java tm se runtime environment build 1 8 0 ea b121 java hotspot tm 64 bit server vm build 25 0 b63 mixed mode when run java version 1 7 org antlr v4 tool tour expr g4 no problem tour expr g4 code be in thank
antlrantlr4
parse a gzipped text file
Invalid
hi everyone I m try to implement a program that read from a gzipped text file and pass the content of the file to an antlrinputstream object this be an example of what I m try to do fileinputstream fis new fileinputstream new file a file gz gzipinputstream gis new gzipinputstream fis inputstreamreader decoder new inputstreamreader gis utf 8 antlrinputstream input new antlrinputstream decoder thelexer lexer new thelexer input commontokenstream token new commontokenstream lexer theparser parser new theparser token parsetree tree parser start when I run this code I get a series of line 36941 45 token recognition error at error and I can not understand the reason I ve also try to read my imputstreamreader object inside a char and everithing have go fine I don t know what to do do anyone have any idea thank in advance giovanni
antlrantlr4
antlr v4 1 for c sorely need
Invalid
I be wonder why there be no progress on the c version of antlr for about four month now it appear that the c version doesn t implement v4 1 yet either that or there be a bug on the download page on the antlr website do you need help with the c version
antlrantlr4
single charater problem
Invalid
I think this be a problem with antlr4 although it might very well be a problem with my grammar concern the parsing of single character I think antlr4 have an issue parse single character as I get the follow error line 1 12 extraneous input expect eof binary selector identifi separator comment parse this line protoobject object yet be define as a binary selector and when I change the to all work ok this be the rule and lexer rule antlr binarytail binarymessage binarytail binarymessage ws binary selector ws unarysend operand binary selector I also get the problem when parse identifier of 1 character use this lexer rule antlr identifier a za z a za z0 9 hopefully I m the one be silly and not antlr
antlrantlr4
I want to parse comment in struct and ignore all other position but fail
Invalid
antlr 4 grammar file usercstructtype g4 antlr grammar usercstructtype userstructtypedef userstructtypedef userstructtypedef typedef struct structfielddecl name structfielddecl primitivetype name fieldcomment primitivefielddecl arrayelementtype name dim1 fieldcomment array1dfielddecl arrayelementtype name dim1 dim2 fieldcomment array2dfielddecl usertype name fieldcomment usertypefielddecl arrayelementtype primitivetype primitivearrayelementtype usertype userarrayelementtype dim1 number dim2 number primitivetype int double char char bool dword usertype name ws t r n skip fieldcomment n n comment n n skip number 0 9 name a z a z a z a z0 9 in the above code I duplicate a lexer fieldcomment node and place it before comment but antlr 4 can not parse the datum like below typedef struct int datum this be comment datatype and the error info be very ambiguous line 3 0 missing fieldcomment at userstructtypedef userstructtypedef typedef struct structfielddecl primitivetype int datum datatype
antlrantlr4
unrecognized derivation
Invalid
this simple antlr v4 0 grammar accept the word aabyx but if you decomment the last alternative on the t rule then this word be no more accepted this seem a bug to I in particular extend the language recognize by t should not restrict the language recognize by s grammar bug axiom s t s a s x ab s y t aa t x if you decomment the above alternative then the word aabyx be no more accepted other lexer rule whitespace t r n u000c
antlrantlr4
bailerrorstrategy bail out on proper input
Invalid
hi I believe this be a bug with the follow grammar antlr4 grammar ara file item semicolon item semicolon eof item a b semicolon a a a b b b ws r t n skip and follow test case java7 test public void aralexer lexer new aralexer new antlrinputstream a araparser parser new araparser new commontokenstream lexer parser seterrorhandler new bailerrorstrategy parser file I get org antlr v4 runtime misc parsecancellationexception at org antlr v4 runtime bailerrorstrategy recover bailerrorstrategy java 51 at adipe translate araparser file araparser java 101 snip cause by org antlr v4 runtime noviablealtexception at org antlr v4 runtime atn parseratnsimulator noviablealt parseratnsimulator java 1532 at org antlr v4 runtime atn parseratnsimulator execatn parseratnsimulator java 608 at org antlr v4 runtime atn parseratnsimulator predictatn parseratnsimulator java 389 at org antlr v4 runtime atn parseratnsimulator adaptivepredict parseratnsimulator java 346 at adipe translate araparser file araparser java 73 25 more while I think a should be recognize by the grammar be I right to believe this a bug how could I work around it good regard
antlrantlr4
type initializer exception when create lexer
Invalid
hi I be use antlr4 0 with c target for a simple calculator grammar everything be ok for generate the c code e g lexer parser listener vistor but when start pare in the follow code I get exception when create the calculatorlexer string s a 3 2 antlrinputstream input new antlrinputstream s calculatorlexer lexer new calculatorlexer input exception throw from here commontokenstream tokens new commontokenstream lexer the exception information be as follow an unhandled exception of type system typeinitializationexception occur in myapp exe additional information the type initializer for calculator calculatorlexer throw an exception anybody can help thank
antlrantlr4
download do not contain an antlrinputstream that implement charstream
Bug
hey I have download late version of antlr 4 and I be able to complete the simple example a first example the generate class hellolexer java seem to expect some class implement a charstream as input import org antlr v4 runtime charstream public hellolexer charstream input super input interp new lexeratnsimulator this atn decisiontodfa sharedcontextcache the example I have find indicate that antlrinputstream should implement charstream and be use as parameter for the lexer constructor that s not the case in the download jar antlr 4 1 complete jar cheer peter
antlrantlr4
uncaught exception in listener silently ignore modify parse
Bug
encounter this when work with the xml grammer and use a listener to process the input uncaught exception which be generate within the body of the listener method appear to be catch somewhere in the antlr internal and be not display to the user but do appear to change the internal parse structure the error message produce can make it extremely difficult to track down the actual error for example use the xml example grammer with the follow method in the listener java override public void enterelement xmlparser elementcontext ctx print enter element ctx gettext throw new nullpointerexception override public void exitelement xmlparser elementcontext ctx print everything work fine print exit element ctx name 0 gettext the actual output be generate be enter element everything work fine exception in thread main java lang nullpointerexception at org homedns kintoshmalae lang xml xmlprintlistener exitelement xmlprintlistener java 41 at org homedns kintoshmalae lang xml xmlparser elementcontext exitrule xmlparser java 346 at org antlr v4 runtime parser triggerexitruleevent parser java 398 at org antlr v4 runtime parser exitrule parser java 547 at org homedns kintoshmalae lang xml xmlparser document xmlparser java 130 at org homedns kintoshmalae lang xml testxmlparser main testxmlparser java 30 java result 1 it appear that the first exception be cause the context in this case elementcontext to be improperly construct which result in the error be generate when we attempt to access the name from the context perhaps we could just get the call to the listener method to be wrap so that the exception be report and not allow to propagate out into somewhere in the middle of the parser even if it didn t actually stop the parser have the error in the output would have make track down the bug which be cause this to be significantly easy if nothing else I would have be look in the right place
antlrantlr4
use sll with testrig give syntax error but it shiws ok on gui
Invalid
use sll with testrig give syntax error but it show ok on gui I be have a long time to run the parser with ll and I try this sll with ll I have no error with sll it show syntax error however seem to recover if it show syntax error how do I know if they be recover error or true syntax error wihtout run full ll which be take too much time to run
antlrantlr4
inconsistent lexer error msg for action
Invalid
if I change the rule characterliteral in antlr grammar v4 java g4 l895 thus characterliteral singlecharacter r n notifyerrorlistener unclosed character literal I get the antlr error message error 132 c java g4 897 21 action in lexer rule characterliteral must be last element of single outermost alt yet the follow program succeed and generate the java file grammar charexperiment 02 stat start characterliteral end eof lexer characterliteral singlecharacter r n notifyerrorlistener unclosed character literal fragment singlecharacter r n ws r t n skip
antlrantlr4
labelling alternative token do not work with assoc right option
Invalid
use antlr 4 1 osx 10 6 8 netbean 7 2 antlr maven plugin when I try to assign a label to alternative which have the assoc option like this assignment i d op assign timeseq diveq modeq pluseq minuseq expression antlr give the follow error processing grammar org jaitool jiffle parser jiffle g4 message errortype label block not a set args op e null filename user michael code jiffle spike src main antlr4 org jaitool jiffle parser jiffle g4 line 125 charposition 18 labelling without the assoc option work fine
antlrantlr4
warn 125 implicit definition of token in parser be display where not appropriate
Bug
I have a separate lexer and parser grammar derive from the sample modetagslexer modetagsparser and get a warning in antlrwork 2 that I don t understand warn 125 implicit definition of token open in parser if I replace the open rule with the warning go away I wonder what the difference between open and close ist which get s no warning I m use antlr 4 1 complete jar and 2013 01 22 antlrwork 2 0 lexer stlexer g4 antlr lexer grammar stlexer default mode rule the sea open pushmode island switch to island mode text clump all text together mode island close popmode back to sea mode slash i d a za z0 9 match send i d in tag to parser ws t channel hide parser stparser g4 antlr parser grammar stparser option tokenvocab stlexer use token from stlexer g4 unit tag text tag open i d close open slash i d close it even persist if I rename the rule slightly and remove the additional mode lexer modify antlr lexer grammar stlexer default mode rule the sea oppen pushmode island switch to island mode text clump all text together mode island close popmode back to sea mode slash i d a za z0 9 match send i d in tag to parser ws t channel hide parser modify antlr parser grammar stparser option tokenvocab stlexer use token from stlexer g4 unit tag text tag i d oppen i d close i d oppen slash i d close accord to sam harwell this be a bug in antlr4 not antlrworks2 see
antlrantlr4
encounter problem when modify tree in visit model
Bug
dear all I use visit model to modify the parse tree and encounter a problem when I replace some child node while visit the parent node I think the problem be due to the loop style in visitchildren method as follow java public t visitchildren notnull rulenode node t result defaultresult int n node getchildcount for int I 0 I n I if shouldvisitnextchild node result break parsetree c node getchild I t childresult c accept this result aggregateresult result childresult return result the for loop will be interfere when I change the child node can this loop be change to more robust loop style like while
antlrantlr4
precedence break if one alternative contain rule only
Bug
when parse the follow statement with the rule expression see below the precedence of a multiplicative expression over an equality expression break while n I 0 factor add I n I expression primary primaryexpression expression dot identifier expressiondot0 expression dot this expressiondot1 expression dot new nonwildcardtypeargument innercreator expressiondot2 expression dot super supersuffix expressiondot3 expression dot explicitgenericinvocation expressiondot4 expression expression arrayaccess expression expressionlist methodinvocation new creator typecreationexpression type expression castexpression expression postfixexpression expression prefixexpression expression unaryexpression expression multiplicativeop expression multiplicativeexpression expression add sub expression additiveexpression expression expression shiftexpression expression le ge gt lt expression relationalexpression expression equalityop expression equalityexpression expression instanceof type instanceofexpression expression expression binexpression0 expression expression binexpression1 expression expression binexpression2 expression expression logicalexpression0 expression expression logicalexpression1 expression expression expression ternaryexpression expression assignmentop expression assignment multiplicativeop mul div mod equalityop equal notequal in this example the alternative multiplicativeexpression and equalityexpression use the rule multiplicativeop and respectively equalityop for the correspond operator thus by visit the parse tree we get visitmultiplicativeexpression n I 0 visitequalityexpression I 0 when replace the rule by its body and therefore use the token directly in the expression rule we get the expected result visitequalityexpression n I 0 visitmultiplicativeexpression n I perhaps specify at least one token in each alternative be intend and necessary for antlr to correctly produce a left recursive grammar however it be not intuitively understandable could you please consider to print out a warning or a hint in such case or just do something different than not report anything