Questions tagged [antlr2]

Questions related about version 2 of ANother Tool for Language Recognition.

Questions related to version 2 of ANTLR.

"ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. ANTLR provides excellent support for tree construction, tree walking, translation, error recovery, and error reporting. ..." -- http://www.antlr.org

Related tags

29 questions
1
vote
0 answers

Why similar antrl2 grammar does not produce non-determenism warning?

I'm trying to create antlr grammar to parse javadoc comment. I use ANTLR v2. Why first grammar produces non-determinism warnings and second one does not? I thought that they are similar. First grammar: class TestParser extends Parser; options { …
baratali
  • 443
  • 7
  • 16
1
vote
0 answers

how to get AST in ANTLRworks

I am a new user of ANTLRworks so please bear with me. I have a small code which is as follows: grammar modelica1; options {output=AST;} tokens { MULT; } // imaginary token poly: term ('+'^ term)* ; term: INT ID -> ^(MULT["*"] INT ID) | INT exp…
1
vote
1 answer

ANTLR version2 grammar syntax?

My professor gave us an assignment about ANTLR, but I found that the given grammar file does not work with current ANTLR versions. Actually, it is an example code included in ANTLR v2, which there are few documents left I can find and has been…
Lyle
  • 1,238
  • 14
  • 16
0
votes
2 answers

antlr2 return multiple values

How to make a rule return multiple values in antlr2.For example: declSpecifiers returns [int mods] : ( storageClassSpecifier | typeQualifier | typeSpecifier)+ ; I have some other information besides 'mods'…
Fiary
  • 203
  • 2
  • 11
0
votes
1 answer

Error when trying to parse an edifact-file with antlr2 when an attribute value contains a keyword

I have the ungrateful task to fix a bug in an old antlr2 parser which is used to parse an edifact file. Unfortunatly I'm not very familar with antlr2 or parser at all and I can not get it to work. The edifact-files look like…
user1567896
  • 2,398
  • 2
  • 26
  • 43
0
votes
0 answers

ANTLR 2 does not generate AST file

I've been given a tarball of an abandoned proprietary Java codebase that uses ANTLR 2.7.6 to generate a lexer, parser, and AST. In the tarball there is a folder that contains amongst other…
Pepijn
  • 4,145
  • 5
  • 36
  • 64
0
votes
0 answers

Antlr "CASE" error path

I am using antlr 2.7.6. I am programming a parser for plc 61131-3 ST language and I can't resolve an issue with my grammar. The grammar is: case_Stmt : 'CASE' expression 'OF' case_Selection + ( 'ELSE' stmt_List )? 'END_CASE'; case_Selection :…
mfabruno
  • 131
  • 3
  • 12
0
votes
0 answers

ANTLR2 error reporting

When the parser/lexer encounters an error,it prints it to the console and recovers so that the parsing can happen. For the end-user, it is an API call, and I would like to inform him about the parse error, so that he can rectify. Currently, I am…
user2761431
  • 925
  • 2
  • 11
  • 26
0
votes
0 answers

ANTLR 2 SBT plugin dependencies

I have defined the following in the build.sbt libraryDependencies += "antlr" % "antlr" % "2.7.7" I have placed my sample.g file in src/main/antlr I also have my java files in src/main/java. I use activator compile to compile the files. The java…
user2761431
  • 925
  • 2
  • 11
  • 26
0
votes
1 answer

How to commit to antlr v2?

For a personal project I had to use ANTLR v2 ... and seeing its output I decided to do some code smell removing in the source. But now I just don't find any description on how I could commit back those changes. Does anyone know where the ANTLR v2…
0
votes
1 answer

ANTLRWorks Debugger

I have a small code for which I want to see the AST in ANTLRWorks. In the preferences, I have chosen the compiler as 'com.sun.tools.javac' and the debugger is set as port '49100' and the time out is '20 seconds'. The code is : grammar try; options…
0
votes
1 answer

ANTLR Grammar for while loop

Hi there, I need a C grammar for parsing the while loops. Say, for example, I need to parse the following code: A = 20 B = 1 WHILE(A < 30 ) //function call A = A + B ENDWHILE I would require to parse and evaluate the expressions. I have followed…
sh_ara
  • 1
  • 2
0
votes
1 answer

How to parse and split alphabet characters and numbers from a string using ANTLR grammar

I have a grammar which parses alphabet characters and numbers separately: grammar Demo; options { language = C; } program : process+ ; process : Alphanumeric {printf("\%s",$Alphanumeric.text->chars);} ; Alphanumeric :…
sh_ara
  • 1
  • 2
0
votes
1 answer

antlr 2 rule ambiguity

DECIMAL_LITERAL : ('0' | '1'..'9' ('0'..'9')*) (INTEGER_TYPE_SUFFIX)? ; FLOATING_POINT_LITERAL : ('0'..'9')+ ( DOT ('0'..'9')* (EXPONENT)? (FLOAT_TYPE_SUFFIX)? | EXPONENT (FLOAT_TYPE_SUFFIX)? | …
Fiary
  • 203
  • 2
  • 11
1
2