ANTLR Section Index | Page 7
Can ANTLR generate a parser in a specified Java package?
Sure. Just put the package statement in the header action:
header {
package org.antlr.test;
}
class P extends Parser;
a : A;
You'll see that ANTLR generates the following output:
// $ANT...more
Is there a mailing list of antlr users [and maybe developers]?
Sure is. Join us at newsgroup comp.compilers.tools.pccts or subscribe to antlr-interest@onelist.com; go to
http://www.onelist.com/subscribe/antlr-interest to subscribe
http://www.onelist.com/a...more
Can I use ANTLR to build a parser written in Java language but which is capable of parsing another language (like C, C++ or Pascal...)?
You sure can. Don't confuse the language in which you implement the parser (Java) with the
language you want to parse (e.g., C++, C). The primary goal of a compiler is to translate one language
(i...more
How do I determine the ANTLR version of a given antlr.jar file?
The only way I can think of is to set it as your classpath for ANTLR and then run antlr:
java antlr.Tool
Is is possible to use ANTLR to provide lexical/syntax highlighting to, for instance, a swing edit panel?
Is is possible to use ANTLR to provide lexical/syntax highlighting to, for instance,
a swing edit panel?
How can I print the line number and of an offending tree node while walking the AST? What if I have '#include'(s) in my source language?
In C++ mode, here are the changes/additions that have to be done (using the example/cpp/treewalk example)
MyASTNode.hh:
typedef ANTLR_USE_NAMESPACE(antlr)RefCount ANTLR_USE_NAMESPACE(std)string...more
How can I handle languages where keywords can also be identifiers?
> From: kearneym@piercom.ie
>
>
> How can I handle the strings which can be token and identifier at the
> same time.
> I have been writting the parser for the SQL,
> and just found out that ...more
How can I avoid traversing a subtree while tree parsing? Is there an operator or command for this?
Use the wildcard "placeholder", which lets you label the subtree, but the tree parser does not descend into the subtree to parse it.
How can I deal with statements split across lines with a continuation character like Fortran or COBOL or the C preprocessor?
In COBOL, source statements are still restricted to 80 columns with
source sequence numbers in columns 1-6, then the indicator column in
column 7, etc. If you had a long statement, you would code...more
How can I handle '-' (minus sign) in my identifiers or keywords?
Think about how you would do it by
hand. You would have to know when there is a hyphen and then make sure
that if there is a hyphen you don't return an IDENTIFIER. Make a lexical rule that match...more
How to I create a list nodes instead of a two-dimensional tree?
Use null as first arg to list constructor.
What do "syntax" and "semantics" mean and how are they different?
A language is a set of valid sentences. What makes a sentence
valid? You can break validity down into two things: syntax and
semantics. The term syntax refers to grammatical structure
whereas t...more
What is the difference between a heterogeneous tree and a homogeneous tree; why would I want one over the other?
can use grammar to walk
handcoded use of heter trees
simpler
trick: allow both
Why can't I get my lexer to recognize 8-bit characters or binary bytes even though I set my character vocabulary to '\0'..'\377'?
It's probably the type of stream you are using. Check to make sure
you're creating a DataInputStream not a Reader:
DataLexer lexer = new DataLexer(new DataInputStream(System.in));
DataParser pa...more
Why do I get the following Java interpreter error: "Can't find antlr/Tool"?
Your CLASSPATH is set wrong. Make sure that antlr.jar or the main ANTLR directory is in your path.
watch out for cafe also; sets path wrong