Questions tagged [antlr3]

Version 3 of ANTLR (ANother Tool for Language Recognition) created and written by Dr. Terrence Parr

Version 3 of ANTLR.

What is 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

Updated links

On January 24th 2013, the www.antlr.org address was changed from pointing at site for ANTLR version 3 (www.antlr3.org) to ANTLR version 4 (www.antlr4.org). So questions and answers that used www.antlr.org were correct for ANTLR 3.x before this date. The links should be updated to www.antlr3.org for ANTLR 3.x or www.antlr4.org for ATNLR 4.x.

Useful ANTLR links

Examples and/or useful posts on SO

Related links

Code at Git

Related tags

911 questions
0
votes
1 answer

Q&A: ANTLRWorks 3.0 mac os version some symbol (like vertical bar '|' ) disappear/not show correctly issue

Someone just like me found that it is hard to use ANTLRWorks 3.0 under Mac OS, some symbols typically vertical bar '|' is invisible . it is because default mac front is not compatible in this IDE,this is the way to fix this issue: see answer
Yank
  • 718
  • 6
  • 17
0
votes
0 answers

ANTLR The following alternatives cant be matched

I have been looking at the already existing questions about this problem but still cannot seem to understand it. I have a part of my grammar /* Variable Declaration */ var_decl_list : var_decl (var_decl_tail) ; var_decl : var_type…
McSick
  • 116
  • 1
  • 1
  • 6
0
votes
0 answers

Match to a default token when none of the specified match

I want to match a list of well known identifiers and if there's no well known identifier I want it to become something like a default token. It would be something like: TOKEN1: 'Token1' ; TOKEN2: 'Token2' ; DEFAULT:…
rpvilao
  • 1,116
  • 2
  • 14
  • 31
0
votes
1 answer

ANTLR: required (...)+ loop did not match anything at character

I'm getting: line n:m required (...)+ loop did not match anything at character u'#' But the parser finishes with 0 = parser.getNumberOfSyntaxErrors(), and produces an AST that is correct. Further checks confirm that the error message is being…
Apalala
  • 9,017
  • 3
  • 30
  • 48
0
votes
2 answers

Antlr StringTemplate

How can I prevent new lines in StringTemplate? For example myAssigns(isConst, myType, myName,exp1,exp2) ::= << const []= ; >> works and keeps the translation on one line, but it…
Pinsickle
  • 623
  • 2
  • 10
  • 20
0
votes
1 answer

antlr - C target : how to use vector

I am using antlr v3.4 C target, here is how I add the data into a vector: options { language = 'C'; } scope Common_Param_Vec { pANTLR3_VECTOR common_params; } bus @init { printf("In bus init"); …
my_question
  • 3,075
  • 2
  • 27
  • 44
0
votes
1 answer

Issues with ANTLR rewrite statement (simple?)

I keep getting MissingTokenException, NullPointerException, and if I remember correctly NoViableAlterativeException. The logfile / console output from ANTLRWorks is not helpful enough for me. What I'm after is a rewrite such as the…
Chellsie
  • 11
  • 3
0
votes
2 answers

ANTLR Grammar and generated code problems

I'm trying to create an expression parser using ANTLR The expression will go inside an if statement so its root is a condition. I have the following grammar, which "compiles" to parser/lexer files with no problems, however the generated code itself…
LK SF
  • 1
0
votes
0 answers

How does one escape left/right braces in ANTLR3 header sections?

I have an ANTLR3 tree grammar with C as the target language. This tree grammar actually generates C++ objects and thus needs to include the header(s) for these classes. I use the @header section for this. However, in the output, there is an extern C…
Sion Sheevok
  • 4,057
  • 2
  • 21
  • 37
0
votes
1 answer

node from line 0:0 mismatched tree node: UNIT expecting UNIT

What does this error mean? Notice it expected a UNIT node and got what it was expecting... Phase_2.g: node from line 0:0 mismatched tree node: UNIT expecting UNIT
pedro
  • 43
  • 1
  • 7
0
votes
1 answer

antlr difference between two rewrite rules ID INT and ^(INT ID)

In the antlr documentation, I see the two following rules but their description sounds exactly the same. What is the difference between these two rules... a : INT ID -> ID INT ; // reorder nodes a : ^(ID INT) -> ^(INT ID) ; // flip order of nodes…
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
0
votes
1 answer

I can't get StringTemplate to indent

I have the following StringTemplate group group RPInstr; before(firstStat) ::= << <{<[beforeEnteringInstr(),firstStat]; anchor, separator="\n">}; anchor> >> beforeEnteringInstr() ::= "before();" I am trying to make the first statement of a…
0
votes
1 answer

Generated Antlr Parser in Java: Not all inputs are read

I am working on my Antlr grammar to parse polynomial functions in multiple variables using Java. Examples for legal input are 42; X; +42X; Y^42; 1337HelloWorld; 13,37X^42; The following grammar does compile without warnings or errors: grammar…
Skrodde
  • 41
  • 10
0
votes
0 answers

Grammar for the Chef Language

I'm just starting to use antlr, with antlr for ruby. The version is 3.2.1 I'm trying to create a parser for the chef language, and the grammar is giving me a real headache :P I'm sure I'm missing some fundamental concept, but I just couldn't figure…
marcelog
  • 7,062
  • 1
  • 33
  • 46
0
votes
1 answer

ANTLR the input matches with the grammar but the program can't realize

I'm writing a parser for SML messages. Input: a file with many SML messages. Ouput: a queue of messages with identified elements. This is my code: grammar SML; options {language = Java;} @header { package SECSParser; import…