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

Definitive Antlr Reference - Chapter 3 and AntlrWorks

I am new to Antlr and my setup is as follows: Windows 7, Java JDK 1.7.0_17, AntlrWorks 1.5, Antlr 3.5. The AntlrWorks Help-About shows the following information: ANTLRWorks 1.5 ANTLR 3.5 StringTemplate v3 3.2.1 StringTemplate v4 …
dotNetMark
  • 23
  • 3
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

How to express multiple nodes in an ANTLR 3 tree parser

Updated: Is there any way to re-use the rule in the parser grammer? Maybe my understanding of ANTLR tree parser is not correct. I think ANTLR tree parser is another kind of parser. I still need to create the right rule to meet my request. If so,…
phyerbarte
  • 199
  • 3
  • 12
0
votes
1 answer

code too large in specialStateTransition(int s, IntStream _input) method of Lexer.java in antlrworks

I am newbie to Antlrworks. I am writing combined grammar file to parse XML file. XML file is pretty big and complex. There are many lexer rules defined in grammar. Antlrworks 1.4.3 is generating code without any problem. But when i debug the code…
Pan
  • 25
  • 2
  • 9
0
votes
1 answer

ANTLR - StringTemplate - CamelCase

What is the best pattern (language independent, for retargetable generation code) to translate antlr token to camel case StringTemplate attribute in a tree conversion? Example: My DSL has MY_FIELD definition and in the StringTemplate output I need…
0
votes
1 answer

antlr parsing using c#

I want to write a simple CSS parser that will extract identifiers from css file. I have a grammar, I compiled it to .cs file and now I need to write Main function. For now I have something like this: var lex = new css21Lexer(new…
Tomasz Grobelny
  • 2,666
  • 3
  • 33
  • 43
0
votes
1 answer

antlr ide producing buggy parser/lexer

I'm using antlr IDE for eclipse with antlr 3.4 and have created the following combined grammar to use on propositional logic grammar Propositional; options { language = Java; } @header { package antlr; } @lexer::header { package…
John Walker
  • 291
  • 1
  • 5
  • 16
0
votes
1 answer

ANTLR rule with multiple elements

I need some help with ANTLR. I have the following rule: datasource @init{boolean joinexpr = false;} : (s1=datasourceelement (joinclause1=joinclause joinelement1=datasourceelement onclause1=onclause (multijoinexpression)* {joinexpr=true;})?) …
Balazs Gunics
  • 2,017
  • 2
  • 17
  • 24
0
votes
2 answers

antlr: how to [sometimes] parse things in quotes?

I have a situation where my language allows quotes strings but sometimes I want to interpret the contents of the quoted string as language constructs. Think of it as, say, eval function. So to support quoted strings i need a lexer rule and it…
MK.
  • 33,605
  • 18
  • 74
  • 111
0
votes
1 answer

Manipulate AST to change input text

I have a question of the more general kind. I'm currently working on a project using ANTLR v3.4 - here's our idea: Parse some input and store important parts of it during the process in a Map. Display the parsed input in a form (please see this…
codebat
  • 186
  • 1
  • 13
0
votes
1 answer

ANTLR Android log grammar. Parsing application parameters

I'm trying to parse Android log system file. Everything is going OK but it doesn't work when I try to parse parameters from log content. My grammar which provides parsing log content logcontent : ( …
0
votes
2 answers

How to build a date/hour grammar with ANTLR v3?

I would like to parse a string of French dates using Antlr. I have three types of date : date_day : 3 Octobre 2004 (the hour/minutes is midnight) date_time : 12h (the day, month and year are completed with the current date) date_complete : 3…
Name is carl
  • 5,961
  • 3
  • 29
  • 44
0
votes
0 answers

Emit token depending on context

I am using antlr 2.7.4 to create a lexer. I am stuck at the following case: if Colon (':') is followed by characters from class C1, COLON token should be emitted followed by token C1 if Colon is followed by Character from character class C2, colon…
Jamil
  • 2,150
  • 1
  • 19
  • 20
0
votes
1 answer

AntLR multiple alternatives

I guess there is something rather fundamental that I'm not understanding. The following grammar seems to me to be quite simple. Starting from the rule 'parse' there doesn't appear to me to be much that could be ambiguous. But I get the errors…
user1686620
  • 2,801
  • 4
  • 18
  • 21
0
votes
1 answer

How to replace text in AST (ANTLR) with C#

Can anyone help me with this problem. I need to traverse an Abstract Syntax Tree to replace all the Children's Text in C#
hienvd
  • 346
  • 1
  • 5
  • 17