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
11
votes
2 answers

Does logical AND and NOT exists in ANTLR?

Is there NOT logic in ANTLR? Im basically trying to negate a rule that i have and was wondering if its possible, also is there AND logic?
Victor
  • 1,305
  • 2
  • 11
  • 15
11
votes
1 answer

Antlr rule priorities

Firstly I know this grammar doesn't make sense but it was created to test out the ANTLR rule priority behaviour grammar test; options { output=AST; backtrack=true; memoize=true; } rule_list_in_order : ( first_rule | second_rule …
probably at the beach
  • 14,489
  • 16
  • 75
  • 116
11
votes
1 answer

Using @header in ANTLR

I'm having trouble getting the "@header" or any other @ rule to work in ANTLR. With a very basic grammer, like this: grammar test; options { language = CSharp2; } @header { using System.Collections.Generic; } tokens { …
Moxen
  • 233
  • 3
  • 10
10
votes
1 answer

Rule reference is not currently supported in a set in ANTLR4 Grammar

I am trying to port Chris Lambro's ANTLR3 Javascript Grammar to ANTLR4 I am getting the following error, Rule reference 'LT' is not currently supported in a set in the following code ~(LT)* LineComment : '//' ~(LT)* -> skip ; LT : '\n' …
Gautam
  • 7,868
  • 12
  • 64
  • 105
9
votes
1 answer

C#, ANTLR, ECMAScript grammar troubles

I'm trying to parse JavaScript (ECMASCript) with C#. I found the following instruction on how to create new project: http://www.antlr.org/wiki/pages/viewpage.action?pageId=557075 So I've downloaded ANTLRWorks, ANTLR v3, unpacked ANTLR, created a…
Alex Netkachov
  • 13,172
  • 6
  • 53
  • 85
9
votes
2 answers

ANTLR for C# and CLSCompliant attribute

I'm using ANTLR V3 to produce C# code for DSL language. The produced code contain the attribute CLSCompliant on both laxer and parser classes which cause a warning to be generated because my project is not CLS compliant. How can I make ANTLR…
Ido Ran
  • 10,584
  • 17
  • 80
  • 143
9
votes
2 answers

How to match a fixed number of characters in ANTLR 3?

I want to parse ISO 8601 dates in my ANTLR grammar. 2001-05-03 I have the following entries in my grammar file: date : FOUR_DIGIT ('-')? TWO_DIGIT ('-')? TWO_DIGIT ; FOUR_DIGIT : TWO_DIGIT TWO_DIGIT ; TWO_DIGIT : DIGIT DIGIT ; DIGIT …
user177800
9
votes
2 answers

Editor generator for ANTLR grammars?

I'm using ANTLR for creating a new general purpose programming language and I'm quite happy with it. Due to the fact that I would like to provide good tools for ease the development of programs written with my language I'm starting to thinking on…
9
votes
2 answers

What is the equivalent for epsilon in ANTLR BNF grammar notation?

During taking advantage of ANTLR 3.3, I'm changing the current grammar to support inputs without parenthesis too. Here's the first version of my grammar : grammar PropLogic; NOT : '!' ; OR : '+' ; AND : '.' ; …
Amirh
  • 443
  • 1
  • 6
  • 13
9
votes
4 answers

ANTLR grammar: parser- and lexer literals

What's the difference between this grammar: ... if_statement : 'if' condition 'then' statement 'else' statement 'end_if'; ... and this: ... if_statement : IF condition THEN statement ELSE statement END_IF; ... IF : 'if'; THEN: 'then'; ELSE:…
BB.
  • 113
  • 3
9
votes
3 answers

Using ANTLR to analyze and modify source code; am I doing it wrong?

I'm writing a program where I need to parse a JavaScript source file, extract some facts, and insert/replace portions of the code. A simplified description of the sorts of things I'd need to do is, given this code: foo(['a', 'b', 'c']); Extract…
Jacob
  • 77,566
  • 24
  • 149
  • 228
8
votes
1 answer

Parser and Lexer Files Not Auto Generated by Eclipse

I'm using the antlr-3.4-complete-no-antlrv2.jar version of ANTLR on Eclipse Indigo. I have installed the ANTLR IDE plugin along with ZEST and GEF. When I generate a combined grammar file and add a header, lexer header and a rule, Eclipse doesn't…
c12
  • 9,557
  • 48
  • 157
  • 253
8
votes
2 answers

Can I remove ANTLR dependencies from generated code?

ANTLR generates java source from the grammar file. Generated source has dependency to ANTLR classes. Can I generate 'clean' java sources using ANTLR, that do not have any antlr - dependecy? If not, can someone recommend some java parser that excels…
igr
  • 10,199
  • 13
  • 65
  • 111
8
votes
1 answer

ANTLR Decision can match input using multiple alternatives

I have this simple grammer: expr: factor; factor: atom (('*' ^ | '/'^) atom)*; atom: INT | ':' expr; INT: ('0'..'9')+ when I run it it says : Decision can match input such as '*' using multiple alternatives 1,2 Decision can match input such…
John Retallack
  • 1,498
  • 2
  • 19
  • 31
8
votes
1 answer

antlr global rule scope declaration vs @members declaration

Which one would you prefer to declare a variable in which case, global scope or @members declaration? It seems to me that they can serve for same purpose? UPDATE here is a grammar to explain what i mean. grammar GlobalVsScope; scope global{ int…
mert inan
  • 1,537
  • 2
  • 15
  • 26
1
2
3
60 61