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

ANTLR warning multiple alternatives, how to understand it and how to get rid of it?

fellow ANTLR experts, could you please explain me why this warning appears in ANTLWorks? How to understand this message and how to get rid of it in this particular case? Example of valid input: abc "xyz def" abc should be recognized as keywordExpr…
Ihor M.
  • 2,728
  • 3
  • 44
  • 70
0
votes
1 answer

ANTLR. How to exclude double quotes from AST?

I have a following grammar and I would like to avoid " from being displayed as a node in AST. To do that I'm ! suffix, but ANTLWorks still shows'em on a tree. What an I doing wrong? grammar BooleanExpr; options { output=AST; …
Ihor M.
  • 2,728
  • 3
  • 44
  • 70
0
votes
1 answer

Use antlr parse sentence

How to use ANTLR parse the natural sentence? Exp: John likes mary. In prolog, every thing is simple: s-->np, vp. np-->[john]. np-->[mary] vp-->v, np. v-->[likes]. I want to use ANTLR to build the program(in Java) that parse some sentence. I just…
Hien
  • 3
  • 1
0
votes
1 answer

Antlr 3 keywords and identifiers colliding

Surprise, I am building an SQL like language parser for a project. I had it mostly working, but when I started testing it against real requests it would be handling, I realized it was behaving differently on the inside than I thought. The main…
0
votes
1 answer

How to get the evaluation result from the parser expression when using antlr 3?

I'm using ANTLR 3.5. I would like to build a grammar that evaluates boolean expressions like x=true; b=false; c=true; a=x&&b||c; and get back the evaluation result via a Java call (like ExprParser.eval() of the above entry will return true.) I'll…
florins
  • 1,605
  • 1
  • 17
  • 33
0
votes
1 answer

How to handle arithmetic operator < and > in antlr grammar that removes html tags

Following is my antlr 3 grammar. I want to strip off content inside html tags. The problem arises when I have arithmetic operator < > inside the tag. How can this be handled? grammar T; options { output=AST; } tokens { ROOT; } parse : text+ …
0
votes
1 answer

Parsing ANTLRv3 tree doent not produce full tree

I'm using ANTLRv3. I've defined a grammar. Now I want to display Parse Tree (like in ANTLRWorks Parse Tree or STACK). I've tried http://www.antlr.org/wiki/display/ANTLR3/Interfacing+AST+with+Java (walking throuht children) but it ommits clauses in…
romsac
  • 67
  • 8
0
votes
1 answer

Building a parse tree in ANTLR with python target

I have a grammar for parsing SQL scripts. The lexer for the grammar works fine with the following code: with open("/path/to/sql/script.sql") as f: query = f.read().upper() tokenStream = antlr3.StringStream(query) lexer =…
Always Asking
  • 243
  • 2
  • 8
0
votes
1 answer

copy nodes of trees using ANTLR tree grammars

I need some guidance on trying to solve a problem I ran across using tree grammars. Basically, I want to be able to do is replace/copy statements around that may be found in the tree. It is probably best to explain through an example. Here is a…
Andy M
  • 119
  • 9
0
votes
2 answers

extract grammar features from sentence on Google App Engine

For my GAE app I need to do some natural language processing to extract the subject and object from an input sentence. Apparently NLTK can't be installed (easily) on GAE so I am looking for another solution. I noticed GAE comes with Antlr3 but from…
hoju
  • 28,392
  • 37
  • 134
  • 178
0
votes
1 answer

Parsing issues in Antlr3 for Linux and Windows

I am trying to parse a piece of trigger code using antlr. While I was able to parse it successfully on Windows, it results in an exception in Linux for the function MATCHT() (which is in turn calling the match() function). What is the difference…
user1616699
  • 81
  • 1
  • 2
  • 4
0
votes
1 answer

Custom initialization/cleanup in ANTLR3

I need to do custom initialization & cleanup in most of my rules. Is there any way to avoid duplication in @init/finally blocks? Currently my rules look like: rule @init { int mark = init(); } // Don't want to duplicate this! ... ; finally {…
Ivan Dubrov
  • 4,778
  • 2
  • 29
  • 41
0
votes
1 answer

The following sets of rules are mutually left-recursive TREE GRAMMAR

I have a complete parser grammer than generates an AST which i could say is correct using the rewrite rules and tree operators. At the moment i am stuck at the phase of creating a tree grammar.I have this error: The following sets of rules are…
Undisputed007
  • 639
  • 1
  • 10
  • 31
0
votes
1 answer

What does cause Antlr to create a large tokenstream resulting in out of memory

One of our web applications regulary dies because its out of memory. The sparse data we gathered from memory dumps suggests there is an issue in our antlr parsing implementation. What we see is a antlr tokenstream containing more than a million…
Th 00 mÄ s
  • 3,776
  • 1
  • 27
  • 46
0
votes
1 answer

How to use ANTLR to parse "vector(10)"?

I'm trying to use ANTLR3 to parse some C++ codes. I want to parse template in C++. But I got some troubles when I am trying to parse this: vector(10) I found this is a legal input without template syntax, because my parse thought this code was…
curimit
  • 25
  • 1
  • 3