ANTLR 3.4 Release Notes
The primary reason for this release is to remove the dependency on ANTLR v2. ANTLR v3.3 and earlier were written using ANTLR v2 grammars and StringTemplate v3, which itself had an ANTLR v2 dependency. Because the v2 license was unclean, projects such eclipse could not include ANTLR v3. This version, 3.4, is completely BSD clean and all additions were subject to the click wrap license or the ANTLR contributor's certificate of origin. ANTLR 3.4 written using StringTemplate 4.0.4, but generated parsers that built templates still use StringTemplate v3 for backward compatibility. A big thanks goes to Sam Harwell, for converting all of the v2 ANTLR grammars in ANTLR v3 to v3!
Targets consistent with ANTLR 3.4: C# 3 target, Java, Scala (no ASTs), Python, Objective-C, C.
Improvements
- Added tree method insertChild(int i, Object t).
- Added BaseTree.freshenParentAndChildIndexesDeeply() to recursively
walk tree and set ptrs. - Sam noticed CommonToken.getText() cached substring pulled from input, which
defeated purpose of pointing into input char array. Altered to not cache.
Should reduce memory footprint. - Added inContext(String context) back into TreeParser.
- Updated for ST v4.0.2 (setting iterateAcrossValues = true as instance var)
- Implement the 'throwsSpec' feature of parser rules for the Java target
- Improve algorithm for SemanticContext Boolean predicate reduction
- Uses ST v4 now!!! Massive change. Only updated Java target so far.
Ripped out ST v3 usage to remove indirect dependency on ANTLR v2. - Sam Harwell ported all v2 grammars to v3!
- Adding type, text terminal options
- Add tree, getTree() to ParserRuleReturnScope to do away with specific ones like:
Removed these special classes if it's just AST; keep if they have defined "returns"
public static class rewrite_template_args_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } };
values - Add -language L option to override language=L option in grammar. Same
grammar can yield multiple parsers in different languages now. - Added method to generated Java code to return the array of delegates; e.g.,
yields:
import Sub1, Sub2;
public Parser[] getDelegates() { return new Parser[] {gSub1, gSub2}; }
- Improve error messages for no viable alt parse exceptions
Bug fixes
- reset() for token stream didn't skip initial off-channel tokens.
- Sam fixes rare infinite loop upon error in nextToken().
- rewrites weren't pulled from syntactic predicates.
- empty alts with actions didn't have EPSILON dummy alt node.
- Udo noticed that Parser.getMissingSymbol() didn't set invented token's input
- Needed throws condition for delegatedRules.
- Unmangled region names in STViz hiearchy tree display.
- ANTLRCore.sti no longer used; removed from all targets.
- Replaced hetero arg with terminalOptions arg in all templates that reference hetero
(this is the class name / node type used for TOKEN<NODETYPE> references
in grammar). Widespread but trivial changes to all targets. hetero is
now terminalOptions.node. Can also get terminalOptions.type and
terminalOptions.text from dictionary of options. - Fixed mispelling of license in BSD license headers
- All finally {} have comment now to suppress warning.
- removed ; from {;} blank method
- Added @SuppressWarnings({"all"}) to front of each
generated class. - -print wasn't always showing ^ and ! in grammar
- -Xmaxinlinedfastates went to 60 from 10 for forcing prediction in left-
recursive expression rules to stay in rule; preds use a parameter. - trees know where they came from now start..stop tokens; todo: use for better err handling.
- Got immediate left-recursion working for rules. Added TestLeftRecursion.java
- Fixed http://www.antlr.org/jira/browse/ANTLR-437 thanks to Vladislav Kuzkokov.
added unit test. - TokenRewriteStream had dead code; also updated insertBefore followed by
replace or delete. If input is abc and I did insertBefore(2,"y"), where
'c' is index 2, then did delete of 2 previously defined functionality
was to ignore the insert. that's weird; fixed to keep insert. Also
Delete special case of replace (text==null):D.i-j.u D.x-y.v | boundaries overlap => combine to max(min)..max(right)
- Send couldBacktrack now to enterDecision in debug protocol
- TreeWizard ctor needed a default tree adaptor.