ANTLR Section Index | Page 5
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
Why does ANTLR generate an if-then-else for an optional subrule where the else-clause tests for what follows the subrule?
Summary: ANTLR tries to detect errors as soon as possible. To make the question more concrete, look at this grammar fragment: r : (A)? B ; For the optional subrule and B reference, ANTLR g...more
Use the lexer grammar option "filter=true" or "filter=MySkipRule". See ANTLR Masquerading as SED and ANTLR Meets Sed.more
Using the heterogenous tree construction facility, how can I force all the AST nodes created be of type MyASTNode thereby doing away the required casting from AST*?
Forcing all tree nodes to be the same kind of object makes them homogeneous trees not heterogeneous trees. If you are asking how to get ANTLR to generate variable references as MyASTNode, then ju...more
Check the ANTLR web site. The left gutter usually has a link to the previous version(s).
No. Naturally language is considered a much more difficult problem than the deterministic, unambiguous parsing of programming languages, data formats, and the like. That said, you can do a prett...more
The simple answer is "yes", however, if you try to parse the same input using the same object with more than one thread the answer is "no". Fortunately, parsing is, for the mo...more
How do I signal the parser to bail out immediately upon detection of a syntax error, instead of trying to consume tokens until it resynchs?
ANTLR generates catch-clauses to catch RecognitionException objects thrown by rules (parsers and tree-parsers). Parser rules can throw either RecognitionException objects or TokenStreamException ...more
Lexers are just objects, so you can attach any parser you want to instances of the same object (just don't have the parsers operate simultaneously--lexers only work on one input stream at a time)....more
The list changes constantly as people build more and more parsers and translators with ANTLR; some of these people make their work available. Your best bet is to ask firstname.lastname@example.org, t...more
The core of the answer is: use the filter option in the lexer. This option is used in a simple form where filter=true and in a more sophisticated form of filter=SKIP_RULE. The first just says, &...more
How do you design the parser to retain identifiers to check if the same identifier is being repeated later in the input?
You need what we typically call a symbol table. This is usually just a hashtable that records the symbols you see in a particular scope (if you have scopes, that is). So, if you see the definiti...more
Yes. See Scanning Unicode Characters for a full description. I hope to support predefined UNICODE sets now like LETTER but that will wait for 2.7.3 I think. As of 2.7.2, you can use European ...more
Subclass your scanner from antlr::TokenStream and make it adhere to the interface defined by TokenStream. Basically this comes down to defining a nextToken function in your scanner class. I use...more
Sure. In fact, this is a great way to do multiple-phase tree transformations. Have the super grammar contain all common rules and the complete set of token types used by your system so that the ...more