ANTLR Section Index | Page 6
How can I include line numbers in automatically generated ASTs?
Tree parsers are often used in type checkers. But useful error messages need the offending line number. So I have written:
import antlr.CommonAST;
import antlr.Token;
public class CommonASTWith...more
What's an elegant way to check whether a node is a PLUS node and then to lift its children to the parent PLUS node?
I'm trying to flatten trees of the form:
#(PLUS A #(PLUS B C) D)
into
#(PLUS A B C D).
What's an elegant way to check whether a node is a PLUS node and then to lift its children to the parent P...more
Can you explain more about ANTLR's tricky lexical lookahead issues related to seeing past the end of a token definition into the start of another?
Consider the following parser grammar:
class MyParser extends Parser;
sequence : (r1|r2)+ ;
r1 : A (B)? ;
r2 : B ;
ANTLR reports
m.g:3: warning: nondeterminism upon
m.g:3: k=...more
How can I handle characters with context-sensitive meanings such as in the case where single-quote is both a postfix operator (complete token) and the string delimiter (piece of a token)?
How can I handle characters with context-sensitive meanings such as in the
case where single-quote is both a postfix operator (complete token) and the
string delimiter (piece of a token)? For exam...more
How do you specify the "beginning-of-line" in the lexer? In lex, it is "^".
Here is a simple DEFINE rule that is only matched if the semantic predicate is true.
DEFINE
: {getColumn()==1}? "#define" ID
;
Semantic predicates on the left-edge of single-altern...more
Why do these two rules result in an infinite-recursion error from ANTLR?
Why do these two rules result in an infinite-recursion error from ANTLR?
a : b ;
b : a B
| C
;
How can I use ANTLR to generate C++ using only STL (standard templates libraries) in Visual C++ 5?
Apply sp3 to your VC++ 5.0 installation. Well this works for me!
Why do I get a run-time error message "Access violation - no RTTI data" when I run a C++ based parser compiled with MS Visual Studio 6.0? It compiled ok. What about g++?
In Visual Studio (Visual C++), you need to go to "Project|Settings..." on the menu bar and then on the Project Settings dialog, go to the "C/C++" tab. Then choose the "C++...more
Could you describe the architecture behind jGuru.com: JSP, Servlets, database, servers, transactions etc...?
[Updated Nov 20, 2002 to remove old description and point at some articles. TJP]
jGuru.com Case-Study.
Little Nybbles of Development Wisdom.more
How can I store the filename and line number in each AST node efficiently (esp for filename) in C++.
There are probably a number of ways to do this. One
way is to use a string table to store the strings. The
AST node has a reference to a type like STRING which
is an object that references (poi...more
How can you add member variables to the parser/lexer class definitions of ANTLR 2.x?
Member variables and methods can be added by including
a bracketed section after the options section that
follows the class definition. For example, for the
parser:
class JavaParser extends ...more
When will ANTLR support hoisting?
Sometime in the future when Ter gets so fed up with my pestering that he just has to implement hoisting so that I'll shut up. Or for ANTLR v3.0. :-)
How do you restrict assignments to semantically valid statements? In other words, how can I ignore syntactically valid, but semantically invalid sentences?
For a complex language like C semantic checking
must be done either after the statement is recognized in
the parser or in a later pass. Semantic checking will
usually involve creation of a symbo...more
Is it possible to compile ANTLR to an executable using Microsoft J++?
See Using Microsoft Java from the Command Line and Building a C++ ANTLR Parser (on Windows NT).
more
How can I suppress the generation of the variable "_saveIndex" in the C++ code? This variable is declared in a lot of lexer rules but not used.
I'm not sure you can turn off the generation of "_saveIndex" but you can turn off the warning message. I don't usually like to do this but in this limited scope it appears to be safe. Place the c...more