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
4
votes
1 answer

Convert ANTLR grammar to Bison / EBNF

Is there a tool for converting an ANTLR grammar to a Bison grmmar?
Aivar
  • 6,814
  • 5
  • 46
  • 78
4
votes
1 answer

ANTLR - Implicit AND Tokens In Tree

I’m trying to build a grammar that interprets user-entered text, search-engine style. It will support the AND, OR, NOT and ANDNOT Boolean operators. I have pretty much everything working, but I want to add a rule that two adjacent keywords outside…
user409108
  • 53
  • 2
4
votes
1 answer

Trouble migrating antlr grammar

I have never used antlr in past, but now have to migrate grammar for an older version to the latest. I am trying to generate lexer and parser for c# target. I am stuck on migrating the start rule seen below. grammar expr; DQUOTE: '\"'; SQUOTE:…
VikasGNS
  • 41
  • 4
4
votes
2 answers

How do I exclude characters / symbols using ANTLR grammar?

I'm trying to write a grammar for various time formats (12:30, 0945, 1:30-2:45, ...) using ANTLR. So far it works like a charm as long as I don't type in characters that haven't been defined in the grammar file. I'm using the following JUnit test…
black666
  • 2,997
  • 7
  • 25
  • 40
4
votes
1 answer

How can I get a parser generated by ANTLR3.5 in C to work in an MVS EBCDIC environment?

We are using ANTLR 3.5.2 on linux to generate a parser in C. We have been able to compile and link the generated C parser and the ANTLR C runtime on z/OS with the LE C compiler. Of course, we'd like the parser to be able to work in the EBCDIC…
4
votes
1 answer

How do I change the parent class in ANTLR-3?

By default, a parser generated using ANTLR-3 extends from org.antlr.runtime.Parser. How do I have it extend my custom class instead?
etheros
  • 2,733
  • 2
  • 24
  • 25
4
votes
2 answers

How do I correctly parse generic types with ANTLR?

I am using ANTLR v3 and I want to correctly parse template expressions like: List> The problem is that the two closing greater than signs conflict with the shift right operator. I've seen a few solutions, but most of them look like…
Pieter van Ginkel
  • 29,160
  • 8
  • 71
  • 111
4
votes
1 answer

ANTLR : rules with arguments?

I am new to ANTLR. I started exploring ANTLR tutorials. I have seen example where return type have been defined for perticular rule(see below example ). Can I pass argument to rule as well ? I just have throught in my mind, i wanted to change the…
Sanjiv
  • 1,795
  • 1
  • 29
  • 45
4
votes
1 answer

Parsing Java Source code using plyj in Python

I am trying to parse Java source to get the method names, their invocations, variable names, etc. I was looking for a pre-built or extensible module in Python and stumbled upon plyj (https://github.com/musiKk/plyj). I want to find out a method, then…
krish7919
  • 892
  • 2
  • 13
  • 30
4
votes
1 answer

How do I make a TreeParser in ANTLR3?

I'm attemping to learn language parsing for fun... I've created a ANTLR grammar which I believe will match a simple language I am hoping to implement. It will have the following syntax: ( +) { …
Richard Walton
  • 4,789
  • 3
  • 38
  • 49
4
votes
1 answer

Status of Javascript in antlr 3.4 or 3.5

What is the status of the JavaScript target in ANTLR 3.4 or 3.5? I have been looking online for an answer to this question but so far I have found nothing. I know that it was broken in v3.2 and then it was fixed in v3.3, but it's not listed in the…
kchadha
  • 61
  • 4
4
votes
2 answers

ANTLR parser hanging at proxy.handshake call

I am attempting to get a basic ECMAScript parser working, and found a complete ANTLR grammar for ECMAScript 3, which appears to compile ok and produces the appropriate Lexer/Parser/Walker Java files. (Running inside ANTLR IDE plugin for Eclipse…
Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
4
votes
2 answers

ANTLRWorks warning 'no start rule'

please help a newbie to understand this warning in ANTLWorks: [11:10:15] warning(138): BooleanExpr.g:0:1: grammar BooleanExpr: no start rule (no rule can obviously be followed by EOF) This is how definition of my grammar looks like: grammar…
Ihor M.
  • 2,728
  • 3
  • 44
  • 70
4
votes
1 answer

DFA predict and scope

Starting from this grammar: https://stackoverflow.com/a/14287002/1082002 I would realize a simple grammar that accepts and evaluates simple language like this: { if a==c { a if a==b { b } else { c …
marka.thore
  • 2,795
  • 2
  • 20
  • 35
4
votes
1 answer

Left recursive ANTLR grammar

I have written a grammar but getting a left recursive error. grammar Lang; options { output = AST; language = C; ASTLabelType= pANTLR3_BASE_TREE; backtrack = true; } start : primary_expression+ ; primary_expression …