ANTLR Section Index | Page 4
Can ANTLR-generated Java classes be made non-public so they are not visible outside the package?
Currently (antlr 2.7.1) there is no way to prevent ANTLR from putting the "public" on the class def that I can remember. You could easily modify the source, of course, in JavaCodeGenera...more
Understanding ANTLR's mysterious error messages.
Understanding ANTLR's mysterious error messages.
I am getting this exception...
ANTLR Parser Generator Version 2.7.1a4 1989-2000 jGuru.com
error: Token stream error reading
grammar(s):antlr.T...more
How do I turn off #line directive generation for the C++ code generator?
use Parser option "genHashLines"
class MyParser extends Parser;
options {
genHashLines=false;
}
How can I allow single-line comments with EOF on the end instead of a newline?
Here is a simple example that works for me.
class CL extends Lexer;
options {
charVocabulary = 'u0000'..'u007f';
}
{
public static void main(String[] args) throws Exception {
C...more
How do I recognize tokens defined as "from here to end of line" such as in a "print" command where the argument is everything after the "print" to end of line?
You should be able to do a "while not end-of-line" loop like:
/** Match print then anything until eol */
PRINT : "print" (~'
')* '
'! ;
Note that the PRINT token returned ...more
Is it possible to have antlr generate parsers from more than one grammar file at one time?
No. ANTLR will only generate parsers from grammars in a single file. If you need multiple grammars across multiple files to share vocabularies, then use importVocab and exportVocab options to pe...more
Is it safe to invoke rules from within actions? Could this ever upset the flow of the parser?
Is it safe to invoke rules from within actions? Could this ever upset the flow of the parser?
rule:
anotherRule { if( condition ) rule(); }
;
Is there a reasonable C++ grammar (and tree grammar) available for ANTLR 2.x?
Unfortunately not. C++ does not lend itself to easy parsing. Most C++ recognizers accept a very loose superset of C++ and then try to "understand" it and restrict the input to valid sy...more
Is there an easy way to include comments and white space in a Java AST Tree (for, say, a code reformatter)?
Please see the examples/java/preserveWhiteSpace example that uses the CommonASTWithHiddenTokens object and the CommonHiddenStreamToken to track whitespace on a hidden channel that is sent from the...more
Where can I download Microsoft VC project file to build CPP LIB for ANTLR?
Check in the distribution (2.7.1 and beyond) for antlr/lib/cpp/contrib/*. You will see MSCV6 project files.
Explanation:
Some caveats:
This is for Visual C++ 6.0. Use At Your Own Risk for ot...more
Which version of ParserView is needed with the newer ANTLR 2.7.0 release? I tryed to use the one specified in the installation html but it generates files with compilation errors.
Which version of ParserView is needed with the newer ANTLR 2.7.0 release?
I tryed to use the one specified in the installation html but it generates files with
compilation errors.
How can I parse an HTML page to capture a URL returned from, e.g., a search engine?
Sun has an good article (with sources) at: Writing a Web Crawler in the Java Programming Languagemore
Are there any other Java-based parser generators available?
JavaCC is another parser generator. It was originally released by Sun and is now available from http://www.metamata.com/javacc/.
You can also take a look at ANTLR.org's useful links.more
How can I add "imaginary" nodes (nodes without corresponding input token) to my AST?
Well, I do lots of imaginary tokens as roots. For example,
class LangParser extends Parser;
options {
buildAST=true;
}
tokens {
EXPR; // imaginary token
}
block
: LCURLY! ( ...more
Where can I find older ANTLR distributions?
Check the ANTLR web site. The left gutter usually has a link to the previous version(s).