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
268
votes
5 answers

ANTLR: Is there a simple example?

I'd like to get started with ANTLR, but after spending a few hours reviewing the examples at the antlr.org site, I still can't get a clear understanding of the grammar to Java process. Is there some simple example, something like a four-operations…
Eli
  • 6,353
  • 9
  • 30
  • 25
107
votes
2 answers

What is a 'semantic predicate' in ANTLR?

What is a semantic predicate in ANTLR?
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
43
votes
2 answers

Building a library using autotools from cmake

This is my first try with cmake and I would like to have, if possible, some feedbacks about what I did since some problems remain. In the CMakeLists.txt of the library folder, I created two makefile targets: configure-antlr3c and antlr3c. The first…
Julio Guerra
  • 5,523
  • 9
  • 51
  • 75
28
votes
6 answers

Scala parser combinators vs ANTLR/Java generated parser?

I am writing an expression parser for an app written mostly in Scala. I have built AST objects in Scala, and now need to write the parser. I have heard of Scala's built-in parser combinators, and also of ANTLR3, and am wondering: which would provide…
Nathan Moos
  • 3,563
  • 2
  • 22
  • 27
22
votes
6 answers

How to match a string, but case-insensitively?

Let's say that I want to match "beer", but don't care about case sensitivity. Currently I am defining a token to be ('b'|'B' 'e'|'E' 'e'|'E' 'r'|'R') but I have a lot of such and don't really want to handle…
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
21
votes
1 answer

Negating inside lexer- and parser rules

How can the negation meta-character, ~, be used in ANTLR's lexer- and parser rules?
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
20
votes
5 answers

Assembly's manifest definition does not match assembly reference

I updated all the packages of my MVC project and I got the following error: Could not load file or assembly 'Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f' or one of its dependencies. The located assembly's…
galdin
  • 12,411
  • 7
  • 56
  • 71
19
votes
3 answers

Can Xtext be used for parsing general purpose programming languages?

I'm currently developing a general-purpose agent-based programming language (its syntaxt will be somewhat inspired by Java, and we are also using object in this language). Since the beginning of the project we were doubtful about the fact of using…
18
votes
6 answers

Are there any LL Parser Generators for Functional Languages such as Haskell or Scala?

I've noticed a distinct lack of LL parsers that create parsers in functional languages. The ideal find for what I've been looking for without success is something to generate a Haskell parser for an ANTLR-style LL(*) grammar (modulo minor…
18
votes
2 answers

Nested Boolean Expression Parser using ANTLR

I'm trying to parse a Nested Boolean Expression and get the individual conditions within the expression separately. For e.g., if the input string is: (A = a OR B = b OR C = c AND ((D = d AND E = e) OR (F = f AND G = g))) I would like to get the…
Sud
  • 183
  • 1
  • 1
  • 7
18
votes
3 answers

How to resolve Antlr3 dependency hell

I have a asp.net MVC 4 project with MEF and RavenBD. When the project loads it throws this exception : Could not load file or assembly Antlr3.Runtime.dll I have found that both RavenDB and WebGrease (installed with MVC 4) use Antlr3. But WebGrease…
16
votes
2 answers

ANTLR 4 tree inject/rewrite operator

In ANTLR 3 you could just do the following: andExpression : (andnotExpression -> andnotExpression) (AND? a=andnotExpression -> ^(AndNode $andExpression $a))* ; Any idea how to do it in the new version?
NeatNerd
  • 2,305
  • 3
  • 26
  • 49
14
votes
1 answer

Why are antlr3 c# parser methods private?

I'm building a parser in antlr which compiles to a working java target. When I retarget for c#2 it produces a parser in which all of the parse methods are private but marked with a [GrammarRule("rulename")] attribute. What is the approved means to…
Andy Bisson
  • 580
  • 5
  • 19
12
votes
1 answer

Can I add Antlr tokens at runtime?

I have a situation where my language contains some words that aren't known at build time but will be known at run time causing the need to constantly rebuild / redeploy the program to take into account new words. I was wandering if it was possible…
probably at the beach
  • 14,489
  • 16
  • 75
  • 116
12
votes
2 answers

Extending simple ANTLR grammar to support input variables

I'm still on my quest for a really simple language and I know now that there are none. So I'm writing one myself using ANTLR3. I found a really great example in this answer: Exp.g: grammar Exp; eval returns [double value] : exp=additionExp…
arturh
  • 6,056
  • 4
  • 39
  • 48
1
2 3
60 61