1**************************************************************************** 2As of ANTLR 3.5.2, March 25 2014, we are no longer updating this file. Instead, 3we are using the github release mechanism. For example, here is 43.5.2 release notes: 5 6https://github.com/antlr/antlr3/releases/tag/3.5.2 7**************************************************************************** 8 9ANTLR 3.5 Release 10January 4, 2012 11 12Terence Parr, parrt at cs usfca edu 13ANTLR project lead and supreme dictator for life 14University of San Francisco 15 16CHANGES 17 18January 4 2012 -- release 3.5 19 20January 3, 2012 21 22* Improve error reporting and recovery for STRAY_BRACKET, fixes antlr/antlr3#42 23* Do not write output files if errors were reported, fixes antlr/antlr3#61 24* Fix AST operator on labeled set of terminals e.g. x=(A|B)^ 25* Fix labeled set of terminals with rewrite e.g. x=(A|B) -> $x 26 27December 1, 2012 28 29* Added error msg for .. in parser 30 31September 17, 2012 32 33* Add Gokulakannan Somasundaram's C++ target based upon C target. 34 Use language=Cpp in options. It's a header-only library, runtime/Cpp/include, 35 so installation is not required. 36 37September 16, 2012 38 39* Python 3.3 target added by Benjamin Wolf based upon Python 2 target 40 https://github.com/antlr/antlr3/pull/23 41 42September 15, 2012 43 44* LookaheadStream bug fixes; 45 https://github.com/antlr/antlr3/pull/21 46 47* Pulled "Fix Python handling of syntactic predicates" 48 https://github.com/antlr/antlr3/pull/33 49 50July 15, 2012 51 52* GUnit improvements 53 https://github.com/antlr/antlr3/pull/27 54 55May 2012: 56 57* ANTLR3 update of ObjC runtime to go with latest ST4-ObjC 58 https://github.com/antlr/antlr3/pull/17 59 60August 9, 2012 61 62* Provide Lexer get end of file method so people can override it. 63 64November 25, 2011 65 66* stderr not test correctly in gunit examineExecResult 67 68October 27, 2011 69 70* Dieter Habelitz reported bug in java code gen with synpreds. labels were 71 being carried from grammar into synpreds but weren't typed properly (they 72 were "void x=null;" for x=ruleref labels) 73 74October 25, 2011 75 76* (Sam) Rule.setOption didn't do memoize option right. 77* (Sam) Fix labels in synpreds 78* (Sam) Fix input index for NoViableAltException during inline prediction 79* (Sam) Fix label aliasing errors in cases like (x=y|x=z) 80 81August 10, 2011 82 83* (Sam) fix stack overflow in semantic context analysis 84 85July 30, 2011 86 87* added range check to BaseTree.insertChild() 88 89July 18, 2011 -- release 3.4 90 91* Added tree method insertChild(int i, Object t). 92 93July 14, 2011 94 95* Added BaesTree.freshenParentAndChildIndexesDeeply() to recursively 96 walk tree and set ptrs. 97 98July 6, 2011 99 100* reset() for token stream didn't skip initial off-channel tokens. 101 102July 5, 2011 103 104* Sam fixes rare infinite loop upon error in nextToken(). 105* rewrites weren't pulled from syntactic predicates. 106 107June 29, 2011 108 109* Sam noticed CommonToken.getText() cached substring pulled from input, which 110 defeated purpose of pointing into input char array. Altered to not cache. 111 Should reduce memory footprint. 112 113June 24, 2011 114 115* empty alts with actions didn't have EPSILON dummy alt node. 116 117June 19, 2011 118 119* Udo noticed that Parser.getMissingSymbol() didn't set invented token's input 120 121June 8, 2011 122 123* Added inContext(String context) back into TreeParser. 124 125April 21, 2011 126 127* Updated for ST v4.0.2 (setting iterateAcrossValues = true as instance var) 128* Needed throws condition for delegatedRules. 129 130April 20, 2011 (Sam Harwell) 131 132* Implement the 'throwsSpec' feature of parser rules for the Java target 133* Improve algorithm for SemanticContext Boolean predicate reduction 134 135April 13, 2011 136 137* Unmangled region names in STViz hiearchy tree display. 138* Removed conversion timeout thing again 139 140April 11, 2011 141 142* Added option -Xconversiontimeout back in. Turns out we hit NFA conversion 143 time landmine occasionally with huge grammars; fails over to backtracking 144 (if turned on) if it can't make DFA. 145 146March 29 - April 10, 2011 147 148* Uses ST v4 now!!! Massive change. Only updated Java target so far. 149 Ripped out ST v3 usage to remove indirect dependency on ANTLR v2. 150 151March 28, 2011 152 153* Sam Harwell ported all v2 grammars to v3! 154 155March 3, 2011 156 157* left-recursion pattern off until all targets catch up 158 159* ANTLRCore.sti no longer used; removed from all targets. 160 161* Adding type, text terminal options 162 163* Replaced hetero arg with terminalOptions arg in all templates that reference hetero 164 (this is the class name / node type used for TOKEN<NODETYPE> references 165 in grammar). Widespread but trivial changes to all targets. hetero is 166 now terminalOptions.node. Can also get terminalOptions.type and 167 terminalOptions.text from dictionary of options. 168 169* Fixed mispelling of license in BSD license headers 170 171March 3, 2011 172 173* Add tree, getTree() to ParserRuleReturnScope to do away with specific ones like: 174 public static class rewrite_template_args_return extends ParserRuleReturnScope { 175 CommonTree tree; 176 public Object getTree() { return tree; } 177 }; 178 Removed these special classes if it's just AST; keep if they have defined "returns" 179 values 180 181February 26, 2011 182 183* All finally {} have comment now to suppress warning. 184 185* removed ; from {;} blank method 186 187* Added @SuppressWarnings({"all"}) to front of each 188 generated class. 189 190* -print wasn't always showing ^ and ! in grammar 191 192* Added java-left-recur/Java.g example. 193 194* left-recursion pattern detection handles backtracking mode now 195 196February 25, 2011 197 198* -Xmaxinlinedfastates went to 60 from 10 for forcing prediction in left- 199 recursive expression rules to stay in rule; preds use a parameter. 200 201* trees know where they came from now start..stop tokens; todo: use for better err handling. 202 203* Got immediate left-recursion working for rules. Added TestLeftRecursion.java 204 205February 21, 2011 206 207* Fixed http://www.antlr.org/jira/browse/ANTLR-437 thanks to Vladislav Kuzkokov. 208 added unit test. 209 210February 17, 2011 211 212* Add -language L option to override language=L option in grammar. Same 213 grammar can yield multiple parsers in different languages now. 214 215February 10, 2011 216 217* Added method to generated Java code to return the array of delegates; e.g., 218 import Sub1, Sub2; 219 yields: 220 221 public Parser[] getDelegates() { 222 return new Parser[] {gSub1, gSub2}; 223 } 224 225January 25, 2011 226 227* Improve error messages for no viable alt parse exceptions 228 229January 20, 2011 230 231* TokenRewriteStream had dead code; also updated insertBefore followed by 232 replace or delete. If input is abc and I did insertBefore(2,"y"), where 233 'c' is index 2, then did delete of 2 previously defined functionality 234 was to ignore the insert. that's weird; fixed to keep insert. Also 235 Delete special case of replace (text==null): 236 D.i-j.u D.x-y.v | boundaries overlap => combine to max(min)..max(right) 237 238December 12, 2010 239 240* Send couldBacktrack now to enterDecision in debug protocol 241 242December 4, 2010 243 244* TreeWizard ctor needed a default tree adapator. 245 246November 29, 2010 -- ANTLR v3.3 247 248November 23, 2010 249 250* CodeGenerator.loadLanguageTarget is now static and available to load 251 targets so we can ask them questions during analysis. 252 253* Fixed and added unit test 254 http://www.antlr.org/jira/browse/ANTLR-370 255 http://www.antlr.org/jira/browse/ANTLR-375 256 257November 23, 2010 258 259* Added source name to syntax error msgs 260 261October 20, 2010 262 263Added boolean couldBacktrack to enterDecision in dbg interface. Breaks AW 264interface and other tools! [BREAKS BACKWARD COMPATIBILITY] 265 266October 17, 2010 267 268* Missing -trace in help msg 269 270November 22, 2010 271 272* Added GrammarAST: public int getCharPositionInLine() { return getColumn()-1; } 273 and Grammar.getHasDelegates() for C# guys 274 275October 16, 2010 276 277* Doesn't write profile data to file anymore; emits decision data to stderr 278 279October 14, 2010 280 281* Make OrderedHashSet have deterministic iteration 282 283July 20, 2010 284 285* greedy=true option shuts off nondeterminism warning. 286 287* code gen for AST and -profile didn't compile. had useless line: 288 289 proxy.setTreeAdaptor(adap); 290 291 292July 17, 2010 293 294* Removed conversion timeout failsafe; no longer needed. 295 296* Stats updated to be correct for -report. 297 298June 10, 2010 299 300* added toArray in OrderedHashSet to make addAll calls get same order for DFA edges and possibly code gen in some areas. 301 302June 5, 2010 303 304* Added -Xsavelexer 305 306May 24, 2010 307 308* lexerStringRef was missing elementIndex attribute. i='import' didn't work 309 in lexer. Altered all target stg files. Set in codegen.g 310 311* output=AST, rewrite=true for tree rewriters broken. nextNode for subtree 312 streams didn't dup node, it gave whole tree back. 313 314March 17, 2010 315 316* Added MachineProbe class to make it easier to highlight ambig paths in 317 grammar. More accurate than DecisionProbe; retrofitted from v4. 318 319February 20, 2010 320 321* added range to TokenStream and implementors: 322 /** How far ahead has the stream been asked to look? The return 323 * value is a valid index from 0..n-1. 324 */ 325 int range(); 326 327* added new method to get subset of tokens to buffered token streams: 328 public List get(int start, int stop); 329 330February 15, 2010 331 332* Refs to other tokens in a lexer rule didn't get its line/charpos right. 333 altered Java.stg. 334 335January 31, 2010 336 337* Creating token from another token didn't copy input stream in CommonToken. 338 makes sense to copy too; i don't think anybody relies on it being null after 339 a copy. We might want to know where token came from. 340 341January 26, 2009 342 343* TreeParser.getMissingSymbol() use CommonTree instead of using 344 adaptor.create() 345 346December 8, 2009 347 348* Instead of sharing Token.EOF_TOKEN, I'm now creating EOF tokens so I can set the char position for better error messages. 349 350December 5, 2009 351 352* Fixed bug in TreeVisitor when rewrites altered number of children. Thanks to Chris DiGiano. 353 354* added new buffered on-demand streams: BufferedTokenStream. Renamed CommonTokenStream to LegacyCommonTokenStream and made new one as subclass of BufferedTokenStream. 355 356November 3, 2009 357 358* Added org.antlr.runtime.UnbufferedTokenStream. Was trivial and works! 359 360November 1, 2009 361 362* Couldn't properly reuse parser state; ctor reset the state; fixed. 363 Parser(TokenStream input, RecognizerSharedState state) 364 365* LookaheadStream<T> used some hardcoded Object return types for LT, etc... 366 uses T now. 367 368September 23, 2009 -- ANTLR v3.2 369 370September 21, 2009 [Jim Idle] 371 372* Added new options for tool invocation to control the points at which the code 373 generator tells the target code to use its equivalent of switch() instead of 374 inline ifs. 375 -Xmaxswitchcaselabels m don't generate switch() statements for dfas 376 bigger than m [300] 377 -Xminswitchalts m don't generate switch() statements for dfas smaller 378 than m [3] 379* Upgraded -X help output to include new optins and provide the default 380 settings, as well as provide units for those settings that need them. 381 382* Change the C Target to overide the deafults for the new settings to 383 generate the most optimizable C code from the modern C compiler point of 384 view. This is essentially to always use swtich statements unless there 385 is absolutely no other option. C defaults are to use 1 for minimum and 386 3000 for maximum number of alts that trigger switch(). This results in 387 object code that is 30% smaller and up to 20% faster. 388 389April 23, 2009 390 391* Added reset to TreeNodeStream interface. 392 393April 22, 2009 394 395* Fixed ANTLR-374. Was caused by moved of grammars. %foo() stuff didn't work 396 397April 9, 2009 398 399* .g and .g3 file extensions work again. 400* introduced bug in 3.1.3: gives exception not error msg upon 401 missing .g file 402 403March 26, 2009 404 405* Made ctor in TreeRewriter and TreeFilter call this not super. 406 407March 21, 2009 408 409* Added ctor to RecognizerSharedState to allow cloning it. 410 411March 17, 2009 -- ANTLR v3.1.3 412 413* improved ANTLRv3.g to handle <...> element options 414 415March 15, 2009 416 417* Fixed ANTLR-389. Strip didn't ignore options in subrules; also seemed 418 to demand stdin. 419 420March 15, 2009 421 422* ANTLR always sorts incoming grammar list by dependency. For example, 423 If W.g depends on tokens from P.g then P.g is done first even if 424 W.g mentioned first on command line. It does not ignore any files you 425 specify the commandline. If you do *.g and that includes some 426 imported grammars, it will run antlr on them. 427 428* -make option prevents ANTLR from running on P.g if P older than 429 generated files. 430 431* Added org.antlr.tool.GrammarSpelunker to build a faster dependency 432 checker (what grammars depend on etc...). Totally independent of any 433 ANTLR code; easy to pull into other tools. 434 435* Added org.antlr.misc.Graph, a general graph with nodes 436 containing an Object payload. It knows how to do a topological sort 437 on the nodes. 438 439March 10, 2009 440 441* Added associativity token option to support upcoming special expression 442 parsing. Added rule option strategy=precedence also 443 444March 1, 2009 445 446* Changed ANTLRWorks debug port from 49153 to 49100. Apparently we change the port in 447 ANTLRWorks to 49100 in 1.2 but forgot to do so in the ANTLR targets. 448 449START CHANGES FOR TREE FILTER MODE (pulled from dev branch) 450 451This feature will be announced in 3.2, but I am integrating from my development branch now into the mainline so target developers have a chance to implement. We might release 3.1.3 bug fix release before 3.2. 452 453* CommonTreeNodeStream -> BufferedTreeNodeStream. Now, 454 CommonTreeNodeStream is completely unbuffered unless you are 455 backtracking. No longer making a list of all nodes before tree parsing. 456 457* Added tree grammar filter=true mode. 458 459 Altered templates: 460 Java.stg: added filterMode to genericParser and treeParser. 461 This required a change to ANTLRCore.sti 462 Defined a default parameter in treeParser to set the superclass 463 to TreeFilter for tree grammar with filter=true. It sets 464 superclass to TreeRewriter if filter=true and output=AST. 465 Other them that, I only had to change ANTLR itself a little bit. 466 Made filter mode valid for tree grammars and have it automatically set 467 the necessary elements: @synpredgate, backtrack=true, rewrite=true 468 (if output=AST). Added error message for detecting conflicting 469 options. 470 471* Added misc.FastQueue and TestFastQueue: 472 A queue that can dequeue and get(i) in O(1) and grow arbitrarily large. 473 A linked list is fast at dequeue but slow at get(i). An array is 474 the reverse. This is O(1) for both operations. 475 476* Added tree.TreeIterator, a generator that walks a doubly linked tree. 477 The nodes must know what index they are. It's an Iterator but 478 remove() is not supported. Returns navigation nodes always: 479 UP, DOWN, EOF. 480 481* Added misc.LookaheadStream: A lookahead queue that knows how 482 to mark/release locations in the buffer for backtracking purposes. 483 I hope to use for both tree nodes and tokens. Just implement 484 nextElement() to say how to get next node or token. 485 486END CHANGES FOR TREE FILTER MODE 487 488February 23, 2009 -- ANTLR v3.1.2 489 490February 18, 2009 491 492* Added org.antlr.tool.Strip (reads from file arg or stdin, emits to stdout) 493 to strip actions from a grammar. 494 495February 4, 2009 496 497* Added CommonTree.setUnknownTokenBoundaries(). Sometimes we build trees 498 in a grammar and some of the token boundaries are not set properly. 499 This only matters if you want to print out the original text associated 500 with a subtree. Check this out rule: 501 502 postfixExpression 503 : primary ('.'^ ID)* 504 ; 505 506 For a.b.c, we get a '.' that does not have the token boundaries set. 507 ANTLR only sets token boundaries for subtrees returned from a rule. 508 SO, the overall '.' operator has the token boundaries set from 'a' 509 to 'c' tokens, but the lower '.' subtree does not get the boundaries 510 set (they are -1,-1). Calling setUnknownTokenBoundaries() on 511 the returned tree sets the boundaries appropriately according to the 512 children's token boundaries. 513 514January 22, 2009 515 516* fixed to be listeners.add(listener); in addListener() of DebugEventHub.java 517 518January 20, 2009 519 520* Removed runtime method: mismatch in BaseRecognizer and TreeParser. Seems 521 to be unused. Had to override method recoverFromMismatchedToken() in 522 TreeParser to get rid of single token insertion and deletion for 523 tree parsing because it makes no sense with all of the up-and-down nodes. 524 525* Changed JIRA port number from 8888 to no port spec (aka port 80) and all 526 refs to it in this file. 527 528* Changed BaseTree to Tree typecase in getChild and toStringTree() and 529 deleteChild() to make more generic. 530 531December 16, 2008 532 533* Added -verbose cmd-line option and turned off standard header 534 and list of read files. Silent now without -verbose. 535 536November 24, 2008 537 538* null-ptr protected getParent and a few others. 539 540* Added new ctor to CommonTreeNodeStream for walking subtrees. Avoids 541 having to make new serialized stream as it can reuse overall node stream 542 buffer. 543 544November 20, 2008 545 546* Updated BaseTest to isolate tests better. 547 548November 17, 2008 549 550* BaseTreeAdaptor.getType() was hosed; always gave 0. Thanks to Sam Harwell. 551 552November 8, 2008 553 554* Added methods to BaseRecognizer: 555 public void setBacktrackingLevel(int n) { state.backtracking = n; } 556 /** Return whether or not a backtracking attempt failed. */ 557 public boolean failed() { return state.failed; } 558 559November 5, 2008 560 561* Tweaked traceIn/Out to say "fail/succeeded" 562 563* Bug in code gen for tree grammar wildcard list label x+=. 564 565* Use of backtrack=true anywhere in grammar causes backtracking sensitive 566 code to be generated. Actions are gated etc... Previously, that only 567 happened when a syntactic predicate appeared in a DFA. But, we need 568 to gate actions when backtracking option is set even if no decision 569 is generated to support filtering of trees. 570 571October 25, 2008 572 573* Fixed debug event socket protocol to allow spaces in filenames. 574 575* Added TreeVisitor and TreeVisitorAction to org.antlr.runtime.tree. 576 577October 22, 2008 578 579* Added inContext() to TreeParser. Very useful for predicating 580 tree grammar productions according to context (their parent list). 581 Added new TestTreeContext unit tests (15). 582 583 /** Check if current node in input has a context. Context means sequence 584 * of nodes towards root of tree. For example, you might say context 585 * is "MULT" which means my parent must be MULT. "CLASS VARDEF" says 586 * current node must be child of a VARDEF and whose parent is a CLASS node. 587 * You can use "..." to mean zero-or-more nodes. "METHOD ... VARDEF" 588 * means my parent is VARDEF and somewhere above that is a METHOD node. 589 * The first node in the context is not necessarily the root. The context 590 * matcher stops matching and returns true when it runs out of context. 591 * There is no way to force the first node to be the root. 592 */ 593 public boolean inContext(String context) {...} 594 595* Added 3 methods to Tree interface [BREAKS BACKWARD COMPATIBILITY] 596 597 /** Is there is a node above with token type ttype? */ 598 public boolean hasAncestor(int ttype); 599 600 /** Walk upwards and get first ancestor with this token type. */ 601 public Tree getAncestor(int ttype); 602 603 /** Return a list of all ancestors of this node. The first node of 604 * list is the root and the last is the parent of this node. 605 */ 606 public List getAncestors(); 607 608October 21, 2008 609 610* Updated unit tests to be correct for \uFFFE->\uFFFF change 611 612* Made . in tree grammar look like ^(. .*) to analysis, though ^(. foo) 613 is illegal (can't have . at root). Wildcard is subtree or node. 614 Fixed bugs: 615 http://www.antlr.org/browse/ANTLR-248 616 http://www.antlr.org/browse/ANTLR-344 617 618October 1, 2008 -- ANTLR v3.1.1 619 620September 8, 2008 621 622* Labels on tokens, rules carry into synpreds now so semantic predicates work. 623 This didn't work since labels were stripped in the synpred and they weren't 624 defined in the generated method. 625 626 a : x=A z=a {$x.text.equals($z.text)}? A 627 | y=A a A A 628 ; 629 630September 3, 2008 631 632* Made a REV static variable in Tool so that we can change the rev for 633 daily builds. 634 635* Made \uFFFF a valid character. Token types are 32-bit clean using -1 636 not 0x0000FFFF as -1 so it should be okay. Label.java: 637 public static final int MIN_CHAR_VALUE = '\u0000'; 638 public static final int MAX_CHAR_VALUE = '\uFFFF'; 639 640August 30, 2008 641 642* Changed messages in en.stg so that TOKEN_NONDETERMINISM correctly 643 indicates when actions hid semantic predicates. 644 645August 15, 2008 646 647* Tweaked build properties and build.xml 648 649August 13, 2008 650 651* Fixed ANTLR-314; 3.1 introduced a problem with list labels += 652 653August 12, 2008 -- ANTLR v3.1 654 655* Added JavaScript target 656 657August 7, 2008 658 659* an NFA target of EOF predicate transition in DFA cause an exception in 660 getPredicatesPerNonDeterministicAlt(). 661 662* Kay Roepke found a nasty bug when debugging AST-constructing 663 composite recognizers. If the input state was null to the constructor, 664 super class constructor created a new parser state object. 665 Later, though we passed the argument state not this.state 666 to the delegate constructors, forcing them to share a different 667 state objects! Changed state to this.state in Dbg.stg constructors. 668 669* Ack. messed up debug/AST. Have to set proxy's tree adaptor; it's 670 a circular ref. Just an ASTDbg.stg change. 671 672August 4, 2008 673 674* superClass works now for lexers 675 676* Made Grammar.defineNamedAction propogate header actions down to all 677 delegates if root grammar; regardless of lexer/parser scope. 678 679* Rejiggered AST templates to propogate changes to tree adaptor 680 for delegate grammars. Fixes ANTLR-302 681 682August 4, 2008 683 684* FOLLOW set computations altered constant FOLLOW bit sets. 685 686* Added (...) are all predicate evaluations. 687 688* Extra init code for tree parser nonrewrite mode removed. 689 690* Added empty child list check in becomeRoot 691 692August 3, 2008 693 694* Was using RuleReturnScope not Rulename_return for list labels in tree 695 parser. 696 697* Didn't set _last in tree parser for rule ref track stuff (rewrite=true) 698 699August 2, 2008 700 701* Benjamin found another rewrite engine bug. 702 703July 30, 2008 704 705* CommonTreeNodeStream / CommonTokenStream did not reset properly. 706 707July 29, 2008 708 709* Fixed another bug in TokenRewriteStream; didn't like inserts after end. 710 711July 28, 2008 712 713* Fixed bug in TokenRewriteStream.toString(start,stop); it ignored 714 parameters. ;) 715 716July 17, 2008 717 718* allow qualified type names in hetero <...> options like T<a.b.c.Node> 719 720July 5, 2008 721 722* treeLevel not set for setBlock alts; added unit test 723 724July 3, 2008 725 726* Fixed ANTLR-267. parse tree added nodes during backtracking and 727 cyclic DFAs. tracks hidden tokens too now. Added toInputString() to 728 get text back including hidden tokens. Shows <epsilon> for rules 729 that match nothing. 730 731June 26, 2008 732 733* Added gParent ptr that points to immediate parent grammar. E.g., 734 // delegators 735 public MParser gM; 736 public M_S gS; 737 public M_S gParent = gS; // NEW 738 739* Grammar imports didn't set all the delegate pointers...lots of imported 740 grammars would cause a null ptr exception. Fixes ANTLR-292. 741 742June 25, 2008 743 744* List labels in tree construction didn't always track the tree; sometimes 745 had a rule result structure. 746 747June 4, 2008 748 749* Improved unit testing so that each test suite executes and builds grammars 750 in a separate temporary directory. This means they can execute concurrently. 751 Also seem to be a problem with my class path during execution. Moved 752 tmpdir for ahead of standard CLASSPATH. 753 754* By virtue of an improvement to StringTemplate, output newlines 755 in generated files should be normalized to whatever your host uses. 756 757June 3, 2008 758 759* Restrict legality of grammar options; for example you cannot use output option 760 in lexer anymore. 761 762June 2, 2008 763 764* Throw illegal arg exception upon invalid TokenRewriteStream ops. Rewrote 765 core of engine. Slightly different operation. Added many more unit tests. 766 7673.1b1 - May 20, 2008 768 769May 11, 2008 770 771* rewrite=true, output=AST for tree grammar was not working. Altered trees were not 772 propagated back up the rule reference chain. Required a number of mods to 773 ASTTreeParser.stg. Added unit tests. 774 775May 10, 2008 776 777* [BACKWARD INCOMPATIBLE if you override match()] 778 I had turned off single token insertion and deletion because I could not figure 779 out how to work with trees and actions. Figure that out and so I turned it back on. 780 match() returns Object matched now (parser, tree parser) so we can set labels 781 on token refs properly after single token ins/del error recovery. Allows actions 782 and tree construction to proceed normally even though we recover in the middle of 783 an alternative. Added methods for conjuring up missing symbols: getMissingSymbol(). 784 785* refactored BaseRecognizer error handling routines 786 787* Single token error recovery was not properly taking into consideration EOF. 788 789* ANTLR no longer tries to recover in tree parsers inline using single node deletion or insertion; throw exception. Trees should be well formed as they are not created by users. 790 791* Added empty constructors to the exception classes that did not have them so that ANTLRWorks can create the exceptions. 792 793* Made debug tree adaptor deal with tokens conjured up during error recovery. 794 795* Removed extra location() debug element that was emitted. 796 797May 8, 2008 798 799* ANTLR didn't update line/col to DFA map for AW. 800 801May 6-7, 2008 802 803* Insufficiently covered (with semantic predicates) alt warnings are now emitted before 804 nondeterminisms so it's clear the nondeterminism is a result of insufficient preds. 805 806* Improved insufficiently covered alt warnings from: 807 warning(203): T.g:2:3: The following alternatives are insufficiently covered with predicates: 1 808 to: 809 warning(203): T.g:2:3: Input B is insufficiently covered with predicates at loca 810tions: alt 1: line 3:15, alt 2: line 2:9 811 812* Improved nondeterminism warning to have: 813 Semantic predicates were present but were hidden by actions. 814parser grammar U; 815a : (A B)? ; 816b : X a {p1}? A B | Y a {a1} {p2}? A B | Z a ; 817 818To create the prediction DFA for the optional sub rule in 'a', ANTLR must find all references to 'a' to determine what can follow. A B can follow 'a' in the first two alts rule 'b'. To resolve the conflict between matching A B immediately in the sub rule and exiting rule 'a' to match it in 'b', ANTLR looks for predicates. In this case, there are two predicates that indicate the semantic context in which the surrounding alternatives are valid. The problem is that one of the predicates is hidden by an action. It took me 1.5 days, but I've finally have gotten ANTLR to properly track the insufficiently covered alternatives. Further, I have gotten it to tell you precisely where the uncovered predicates are even if they are simply hidden by actions. I have also updated all of the nondeterminism warnings so that it tells you if there was a predicate but one hidden by an action (this could be a separate condition from insufficiently covered predicates). here are your messages from ANTLR: 819 820ANTLR Parser Generator Version 3.1b1 (??) 1989-2007 821warning(203): U.g:2:5: Input such as "A B" is insufficiently covered with predicates at locations: alt 2: line 3:38 at B 822Semantic predicates were present but were hidden by actions. 823warning(200): U.g:2:5: Decision can match input such as "A B" using multiple alternatives: 1, 2 824As a result, alternative(s) 2 were disabled for that input 825Semantic predicates were present but were hidden by actions. 826 827* Fixed issue where 828r41 829 : (INT -> INT) ( ('+' i=INT) -> ^($i $r41) )* ';' 830 ; 831still warned about $r41 being ambig. 832 833* actions are now added to the NFA. 834 835* Fixed ANTLR-222. ANTLR now ignores preds after actions. 836 837May 5, 2008 838 839* Fixed ANTLR-235 by backing out a change from 12-31-07. 840 841* Fixed ANTLR-249; I include semantic context again in closure busy signal. 842 843May 3, 2008 844 845* Fixed ANTLR-208. Looks in library or in -o output path. antlr -o foo T.g U.g where U needs T.tokens won't work unless we look in foo too. fixed. 846 847* Refactored assign.types.g to move methods to a class called AssignTokenTypesBehavior. 848 849* Fixed ANTLR-207. Lexers importing vocabs didn't see ';'=4 type aliases in .tokens. 850 851* Fixed ANTLR-228. Couldn't use wildcard in alts with AST rewrites. 852 853May 2, 2008 854 855* Fixed ANTLR-230; can use \' now in action. 856 857* Scope attributes no longer have a stack depth check on front. If you ref $r::a when r has not invoked you, then you get an exception not a default value. Back to the way 3.0.1 worked. 858 859* $channel was a global variable in 3.0.1 unlike $type which did not affect an invoking lexer rule. Now it's local too. Only $type and $channel are ever set with regularity. Setting those should not affect an invoking lexer rule as in the following should work: 860 861 X : ID WS? '=' ID ; // result is X on normal channel 862 WS : ' '+ {$channel = HIDDEN; } ; 863 864 STRING : '"' (ESC|.)* '"' ; // result is STRING not ESC 865 866 FLOAT : INT '.' INT? ; // should be FLOAT 867 INT : Digit+ ; 868 fragment 869 Digit : '0'..'9' ; 870 871* Fixed bug in interpreter regarding (...)* loops 872 873May 1, 2008 874 875* Fixed ANTLR-202. These now give warnings about ambig ref to $a. 876 a : ID a -> $a | INT ; 877 and 878 a : A a {$a.text} | B ; 879 880April 30, 2008 881 882* Fixed ANTLR-237. updated -depend to know about imported grammars. 883$ java org.antlr.Tool -depend -lib foo T.g 884 ANTLR Parser Generator Version 3.1b1 (??) 1989-2007 885 T.g: foo/Java.g 886 TParser.java : T.g 887 T.tokens : T.g 888 TLexer.java : T.g 889 T_Java : T.g 890 891April 29, 2008 892 893* Fixed ANTLR-217; scope A,B,C; didn't work 894 895* Fixed ANTLR-224; ! or ^ on item in alt with rewrite gave exception 896 897* Added token options to terminals: ID<node=V; foo="Big bob"> etc... 898 node is default so you can do ID<V> for hetero tree types. most common. 899 900April 17, 2008 901 902* Use default msg if unknown recog type in getErrorMessage(): 903 String msg = e.getMessage(); 904 905April 14, 2008 906 907* %x.y = foo; was not working in @members section 908 909March 29, 2008 910 911* Import couldn't handle A imports B imports C. 912 913March 27, 2008 914 915* Added get/setInputStream to Token interface and affected classes. 916 917February 26, 2008 918 919* made fillBuffer public in CommonTreeNodeStream so we can add trees 920 to stream for interactive interpreters. 921 922February 14, 2008 923 924* Fixed a bug in the code generation where tree level 0 was used 925 no matter what to rewrite trees in tree grammars. added unit test 926 927* Fixed ANTLR-221. exceptions were generated when using 928 AST construction operators and no output=AST option. 929 930February 13, 2008 931 932* Improved error msgs for unreachable alts and tokens. 933 934February 11-12, 2008 935 936* Fixed ANTLR-219. 937 It looks like the AST construction code for sets was totally messed up. 938 This was for not only the new tree parser AST construction, but also 939 the regular tree construction for parsers. I had to introduce templates 940 in the ASTTreeParser.stg file to deal with this. added unit tests: 941 TestTreeGrammarRewriteAST.testSetMatchNoRewrite(), 942 testSetMatchNoRewriteLevel2(), testSetMatchNoRewriteLevel2Root(). 943 Had to add template matchRuleBlockSet() 944 to differentiate between a regular set in one that is an entire rule. 945 If it is an entire rule, it has to set the return value, retval.tree. 946 947* Fixed ANTLR-220. 948 Made TreeAdaptor dupNode and dupTree events emit debugging events 949 so AW could see tree node duplications. 950 951February 4, 2008 952 953* BACKWARD INCOMPATIBILITY 954 Added getSourceName to IntStream and TokenSource interfaces and also the 955 BaseRecognizer. Have to know where char come from for error messages. 956 Widespread change, but a trivial one. 957 958January 17, 2008 959 960* Interpreter throws FailedPredicateException now when it sees a predicate; 961 before it was silently failing. I'll make it work one of these days. ;) 962 963January 12, 2008 964 965* Copy ctor not copying start and stop for common token. Fixes ANTLR-212 966 967* Removed single token insertion and deletion for tokens, sets. 968 Required a change to the code generation for matchSet() template 969 and a tweak inside the BaseRecognizer. To engage this again is easy, 970 just override mismatch() to call mismatchRecover(). I changed it to simply 971 throw an exception. 972 973* Added syntaxError recognizer state var so you can easily tell if 974 a recognizer failed. Added getNumberOfSyntaxErrors() to recognizers. 975 976* Added doc for the error node stuff: 977 http://www.antlr.org/wiki/display/ANTLR3/Tree+construction 978 979* Fixed ANTLR-193 980 981* Added recognizer methods to answer questions about current mismatched 982 token error. Useful now since i don't automatically recover inline 983 to such errors (I throw exception): 984 mismatchIsUnwantedToken(IntStream input, int ttype) 985 mismatchIsMissingToken(IntStream input, BitSet follow) 986 987* Added UnwantedTokenException and MissingTokenException to make 988 match() problems more precise in case you want to catch differently. 989 Updated getErrorMessage() to be more precise. Says: 990 991 line 2:9 missing EQ at '0' 992 993 now instead of 994 995 line 2:9 mismatched input '0' expecting EQ 996 997 Input "x=9 9;" gives 998 999 line 3:8 extraneous input '9' expecting ';' 1000 1001 When very confused, "x=9 for;", you still get old mismatched message: 1002 1003 line 3:8 extraneous input 'for' expecting ';' 1004 line 3:11 mismatched input ';' expecting '(' 1005 1006* Added unit tests to TestAutoAST and copied to TestRewriteAST with 1007 suitable rewrites to ensure basic error node insertion works. 1008 1009January 11, 2008 1010 1011* Adding errorNode to TreeAdaptor and various debug 1012 events/listeners. Had to add new class runtime.tree.CommonErrorNode 1013 to hold all the goodies: input stream, start/stop objects. 1014 1015* Tweaked CommonTree.getType() to return INVALID_TOKEN_TYPE 1016 instead of literal 0 (same thing at moment though). 1017 1018* Updated ANTLRWorks to show error nodes in tree as much as I could; Jean 1019 will get to rest of it. 1020 1021January 9-10, 2008 1022 1023* Continued work on debugging/profiling composite grammars. 1024 1025* Updated debug protocol for debugging composite grammars. enter/exit 1026 rule needs grammar to know when to flip display in AW. 1027 1028* Fixed ANTLR-209. ANTLR consumed 2 not 1 char to recover in lexer. 1029 1030* Added two faqs instead of making changes to antlr runtime about 1031 lexer error handling: 1032 http://www.antlr.org/wiki/pages/viewpage.action?pageId=5341230 1033 http://www.antlr.org/wiki/pages/viewpage.action?pageId=5341217 1034 1035January 1-8, 2008 1036 1037* Making debugging/profiling work with composite grammars. 1038 1039* Updated ANTLRWorks so it works still for noncomposite grammars. 1040 1041* two new examples: import and composite-java (the java example grammar 1042 broken up into multiple pieces using import). 1043 1044* Worked on composite grammars. Had to refactor a lot of code to make 1045 ANTLR deal with one meta grammar made up of multiple grammars. I 1046 thought I had it sort of working back in August. Yes, but barely. Lots 1047 of work to do it seemed. Lots of clean up work. Many new unit tests 1048 in TestCompositeGrammars. Had to add new error messages warning about 1049 conflicting tokens inherited from multiple grammars etc... 1050 1051 TOKEN_ALIAS_CONFLICT(arg,arg2) ::= 1052 "cannot alias <arg>; string already assigned to <arg2>" 1053 TOKEN_ALIAS_REASSIGNMENT(arg,arg2) ::= 1054 "cannot alias <arg>; token name already assigned to <arg2>" 1055 TOKEN_VOCAB_IN_DELEGATE(arg,arg2) ::= 1056 "tokenVocab option ignored in imported grammar <arg>" 1057 INVALID_IMPORT(arg,arg2) ::= 1058 "<arg.grammarTypeString> grammar <arg.name> cannot import <arg2.grammarTypeString> grammar <arg2.name>" 1059 IMPORTED_TOKENS_RULE_EMPTY(arg,arg2) ::= 1060 "no lexer rules contributed to <arg> from imported grammar <arg2>" 1061 IMPORT_NAME_CLASH(arg,arg2) ::= 1062 "combined grammar <arg.name> and imported <arg2.grammarTypeString> grammar <arg2.name> both generate <arg2.recognizerName>; import ignored" 1063 1064 This stuff got really really complicated. Syntactic predicate names even 1065 had to be scoped per grammar so they don't conflict. 1066 1067* When using subrules like (atom->atom) to set result tree, it was not 1068 properly setting result (early enough). Future code got null for 1069 $rule.tree. 1070 1071December 31, 2007 1072 1073* Added the start of a semantic predicate computation for LL(1) to 1074 solve a problem with slow grammar analysis even with k=1 due to 1075 predicates. Then I realized the problem with that grammar was 1076 elsewhere. Semantic context really shouldn't be used when 1077 preventing closure recomputation (May 2008 I discovered I was 1078 wrong--you do need it). The predicates became huge even though the 1079 reduced value would be no different. The analyzer seems faster now 1080 that I am not testing predicate values all the time. Further it may 1081 terminate sooner just due to reduced closure recursion. 1082 1083* Moved FIRST/FOLLOW computations to a separate class LL1Analyzer to 1084 tidy up. 1085 1086* ANTLR lexer allowed octal escapes, but they didn't work. ;) Rather than 1087 fix, I'm removing. Use '\uxxxx' to get even 8 bit char values: \u00xx. 1088 1089December 29, 2007 1090 1091* Fixed ANTLR-206. I wasn't avoiding analyzing decisions in 1092 left-recursive rules. 1093 1094* Had to add hetero arg to all tokenRef*() templates. Added _last 1095 local var to track last child so we can do replaceChildren() during 1096 AST rewrite mode for tree grammars. Should be useful later for .text 1097 property. Ack, hetero arg is on lots of templates. :( Moved 1098 ruleCleanUp() template into ASTTreeParser and ASTParser groups. 1099 1100* added noRewrite() template (to Java.stg) so we can insert code during 1101 rewrite mode to return original tree if no rewrite. Might be useful 1102 for token rewrites later. For templates too? 1103 1104* Had to add if !rewriteMode around tree construction in tree parser 1105 templates. 1106 1107* Harald Muller pointed out that we need to use <initValue(attr.type)> 1108 in our tests for null token/rule property references. For int types 1109 we need 0 not null. (p!=null?p.line:0). Changed scopeAttributeRef, 1110 ruleLabelRef. Also changed the known typed attributes like 1111 lexerRuleLabelPropertyRef_line to yield 0 upon null rule ref to 1112 be consistent with case when we don't know the type. Fixes ANTLR-195. 1113 Added testTypeOfGuardedAttributeRefIsCorrect test and reset expected 1114 output for 13 tests that now "fail". 1115 1116December 28, 2007 1117 1118* added polydiff example (Java target) 1119 1120* added "int" property for token and lexer rule refs. super convenient. E.g., 1121 a : b=INT {int x = $b.int;} ; 1122 1123December 27, 2007 1124 1125* Changed -Xnoinlinedfa to -Xmaxinlinedfastates m where m is 1126 maximum number of states a DFA can have before ANTLR avoids 1127 inlining it. Instead, you get a table-based DFA. This 1128 affectively avoids some acyclic DFA that still have many states 1129 with multiple incident edges. The combinatorial explosion smacks 1130 of infinite loop. Fixes ANTLR-130. 1131 1132* [...] are allowed in args now but ] must be escaped as \]. E.g., 1133 a[String[\] ick, int i] : ... ; 1134 And calling a rule: foo[x[i\], 34] 1135 Fixes ANTLR-140. 1136 1137* Fixed ANTLR-105. Target.getTargetStringLiteralFromANTLRStringLiteral() 1138 escaped " that were already escaped. 1139 1140* target's can now specify how to encode int as char escape. Moved 1141 DFA.encodeIntAsCharEscape to Target. 1142 1143* Bug in runtime.DFA. If a special state (one with predicate) failed, it 1144 tried to continue (causing out of range exception due to state = -1) 1145 instead of reporting error. 1146 1147* If -dfa with combined grammar T.g, builds T.dec-*.dot and TLexer.dec-*.dot 1148 1149* Fix ANTLR-165. 1150 Generate TParser.java and TLexer.java from T.g if combined, else 1151 use T.java as output regardless of type. 1152 BACKWARD INCOMPATIBILITY since file names change. 1153 I changed the examples-v3/java to be consistent. Required XML.g -> 1154 XMLLexer.java and fuzzy/Main.java change. 1155 1156* Fix ANTLR-169. Deletes tmp lexer grammar file. 1157 1158December 25, 2007 1159 1160* Fixed ANTLR-111. More unit tests in TestAttributes. 1161 1162December 25, 2007 1163 1164* Dangling states ("decision cannot distinguish between alternatives 1165 for at least one input sequence") is now an error not a warning. 1166 1167* Added sample input sequence that leads to dangling DFA state, one 1168 that cannot reach an accept state. ANTLR ran into a case where 1169 the same input sequence reaches multiple locations in the NFA 1170 (and so not nondeterministic), but analysis ran out of further 1171 NFA states to look for more input. Commonly at EOF target states. 1172 Now says: 1173 1174 error(202): CS.g:248:95: the decision cannot distinguish between alternative(s) 1,2 for input such as "DOT IDENTIFIER EOF" 1175 1176 Also fixed bug where dangling states did not resolve to stop states. 1177 1178* Fixed ANTLR-123 1179 1180December 17-21, 2007 1181 1182* k=1 doesn't prevent backtracking anymore as in 1183 (options {k=1;}:'else' statement)? 1184 if backtrack=true for overall grammar. Set to false in subrule. 1185 1186* Optimized the analysis engine for LL(1). Doesn't attempt LL(*) unless 1187 LL(1) fails. If not LL(1) but autobacktracking but no other kind of 1188 predicate, it also avoids LL(*). This is only important for really 1189 big 4000 line grammars etc... 1190 1191* Lots of code clean up 1192 1193December 16, 2007 1194 1195* Yet more Kay pair programming. Saved yet more RAM; 15% by 1196 wacking NFA configurations etc in each DFA state after DFA construction. 1197 1198* Overall we drop from 2m49s to 1m11s for a huge 4000 line TSQL grammar 1199 with k=*. Only needs -Xconversiontimeout 2000 now not 1200 -Xconversiontimeout 5000 too. With k=1, it's 1m30s down to 40s. 1201 1202December 15, 2007 1203 1204* Working with Kay Roepke, we got about 15% speed improvement in 1205 overall ANTLR exec time. Memory footprint seems to be about 50% 1206 smaller. 1207 1208December 13-14, 2007 1209 1210* I abort entire DFA construction now when I see recursion in > 1 alt. 1211 Decision is non-LL(*) even if some pieces are LL(*). Safer to bail 1212 out and try with fixed k. If user set fixed k then it continues because 1213 analysis will eventually terminate for sure. If a pred is encountered 1214 and k=* and it's non-LL(*), it aborts and retries at k=1 but does NOT 1215 emit an error. 1216 1217* Decided that recursion overflow while computing a lookahead DFA is 1218 serious enough that I should bail out of entire DFA computation. 1219 Previously analysis tried to keep going and made the rules about 1220 how analysis worked more complicated. Better to simply abort when 1221 decision can't be computed with current max stack (-Xm option). 1222 User can adjust or add predicate etc... This is now an error 1223 not a warning. 1224 1225* Recursion overflow and unreachable alt is now a fatal error; no code gen. 1226 The decision will literally not work. 1227 1228* Cleaned up how DFA construction/analysis aborts due to non-LL(*) and 1229 overflow etc... Throws exceptions now, which cleans up a bunch of IF 1230 checks etc... Very nice now. Exceptions: 1231 analysis/AnalysisRecursionOverflowException.java 1232 analysis/AnalysisTimeoutException.java 1233 analysis/NonLLStarDecisionException.java 1234 1235* ErrorManager.grammarWarning() counted them as errors not warnings. 1236 1237* Unreachable alt warnings are now errors. 1238 1239* The upshot of these changes is that I fixed ANTLR-178 and did 1240 lots of refactoring of code handling analysis failure. 1241 1242December 11, 2007 1243 1244* Could not deal with spaces, oddly enough in arg lists: 1245 grammar Bad; 1246 a : A b["foo", $A.text] ; 1247 b[String x, String y] : C ; 1248 1249October 28, 2007 1250 1251* Made ANTLR emit a better error message when it cannot write the 1252 implicit lexer file from a combined grammar. Used to say "cannot open 1253 file", now says "cannot write file" and gives backtrace. 1254 1255September 15, 2007 1256 1257add getCharStream to Lexer. 1258 1259September 10, 2007 1260 1261* Added {{...}} forced action executed even during backtracking. 1262 1263September 9, 2007 1264 1265* r='string' in lexer got a duplicate label definition. 1266 1267August 21, 2007 1268 1269* $scope::variable refs now check for empty stack so that expr == null if 1270 $scope has an empty stack. Works for $scope[...]::variable too. Nice! 1271 1272August 20, 2007 1273 1274* Added reset() to CommonTreeNodeStream, token stream too 1275 1276* Made refs to rule/token properties use ?: to avoid null ptr exception. 1277 $label.st now is label!=null?label.st:null. Updated TestAttributes. 1278 This is useful not only for optional rule/token refs, but also during 1279 error recovery. If ID is not matched, $ID.text won't cause a null ptr. 1280 1281August 20, 2007 1282* Fixed ANTLR-177: hashCode/equals not consistent for label 1283 Fixed bug where Rule was compared to string; introduced from dev branch 1284 1285August 15, 2007 -- Got rough draft of the grammar import working. 1286 Submit to dev and then integrate into mainline. 1287 1288 All file changes/additions: 1289 1290 README.txt # edit 1291 CHANGES.txt # add 1292 Factored out the changes from the readme. 1293 1294 runtime/Java/src/org/antlr/runtime/BaseRecognizer.java # edit 1295 runtime/Java/src/org/antlr/runtime/DFA.java # edit 1296 runtime/Java/src/org/antlr/runtime/Lexer.java # edit 1297 runtime/Java/src/org/antlr/runtime/Parser.java # edit 1298 runtime/Java/src/org/antlr/runtime/debug/DebugParser.java # edit 1299 runtime/Java/src/org/antlr/runtime/tree/TreeParser.java # edit 1300 Factored state fields into RecognizerSharedState 1301 object. You will see a lot of things like 1302 state.errorRecovery = false; 1303 runtime/Java/src/org/antlr/runtime/RecognizerSharedState.java # add 1304 Shares all recognizer state variables including lexer even though 1305 these are superfluous to parsers and tree parsers. There 1306 was a casting issue that I could not resolve. 1307 1308 src/org/antlr/Tool.java # edit 1309 Broke a part Grammar.setGrammarContent() into 1310 parseAndBuildAST() and analyzeGrammar() to make the grammar 1311 import work. I needed to be able to look at the trees for 1312 imported grammars before analyzing them and building DFA. Added 1313 use of the CompositeGrammar object and handling of multiple 1314 delegate grammars. Changed decision DFA DOT file names to 1315 include the grammar name. 1316 1317 src/org/antlr/analysis/DFA.java # edit 1318 Just tweaked to use generics, updated a comment. 1319 1320 src/org/antlr/analysis/DecisionProbe.java # edit 1321 Just tweaked to use generics. 1322 1323 src/org/antlr/analysis/NFA.java # edit 1324 NFA now span multiple grammars and so I moved the NFAs state 1325 tracking to the composite grammar object. 1326 1327 src/org/antlr/analysis/NFAState.java # edit 1328 Added some null checking and made a field public. 1329 1330 src/org/antlr/analysis/NFAToDFAConverter.java # edit 1331 Changed a method call to directly access a field. 1332 1333 src/org/antlr/analysis/RuleClosureTransition.java # edit 1334 Instead of using a rule index, which does not span multiple 1335 grammars, the transition object now attracts a pointer to 1336 the actual Rule definition object. 1337 1338 src/org/antlr/analysis/SemanticContext.java # edit 1339 Tweaked to use a field instead of a method 1340 1341 src/org/antlr/codegen/ActionTranslator.g # edit 1342 src/org/antlr/codegen/ActionTranslatorLexer.java # edit 1343 Tweaked to use new runtime and they changed method name. 1344 1345 src/org/antlr/codegen/CodeGenerator.java # edit 1346 Tweaked comments. 1347 1348 src/org/antlr/codegen/codegen.g # edit 1349 Added import grammar syntax and altered rule atom to pass a 1350 scope around so that grammar.rule works. Caution this 1351 feature is used internally by ANTLR and is not meant to be 1352 used by users at this point. 1353 1354 src/org/antlr/codegen/templates/ANTLRCore.sti # edit 1355 Added scope to all ruleref template interfaces. 1356 1357 src/org/antlr/codegen/templates/Java/Java.stg # edit 1358 Grammars can now import other grammars, which I implemented 1359 using a delegation pointer to the other grammar(s). So if 1360 grammar A imports grammars B and C, then the generated 1361 recognizer for A must have delegation pointers to BParser 1362 and CParser objects. These are now fields: 1363 1364 // delegates 1365 <grammar.delegates: 1366 {g|public <g.name>Lexer <g:delegateName()>;}; separator="\n"> 1367 1368 Also, B and C must have back pointers to the delegator so 1369 that they can refer to rules that have been overridden. 1370 This is a mechanism akin to static inheritance: 1371 1372 // delegators 1373 <grammar.delegators: 1374 {g|public <g.name>Lexer <g:delegateName()>;}; separator="\n"> 1375 1376 This file also has a lot of changes so that state variables 1377 now are state.backtracking instead of the implied 1378 this.backtracking. 1379 1380 The file also refers to grammar.delegatedRules attribute 1381 which is the list of Rule objects for which you must 1382 generate manual delegation. This amounts to a stub whereby 1383 rule foo's method foo() simply calls X.foo() if foo is not 1384 defined inside the delegator. 1385 1386 You will notice that the ruleref templates now take a scope 1387 so that I can have implicit rule Tokens referred to 1388 delegate.Tokens rule in a delegate grammar. This is the way 1389 I do lexer grammar imports. 1390 1391 I added a template called delegateName which uses the 1392 grammar name to compute a delegate name if the user does not 1393 specify a label in the import statement such as: 1394 1395 import x=X; 1396 1397 Oh, note that rule reference templates all receive a Rule 1398 object now instead of the simple rule name as the 'rule' 1399 attribute. You will see me doing <rule.name> instead of 1400 <name> now. 1401 1402 src/org/antlr/codegen/templates/Java/Dbg.stg # edit 1403 Changes mirroring the constructor and field stuff from 1404 Java.stg. Part of this is a cut and paste because of a bug 1405 in ST. 1406 1407 src/org/antlr/codegen/templates/Java/AST.stg # edit 1408 src/org/antlr/codegen/templates/Java/ASTParser.stg # edit 1409 src/org/antlr/codegen/templates/Java/ASTTreeParser.stg # edit 1410 Just added the scope attribute. 1411 1412 src/org/antlr/test/BaseTest.java # edit 1413 Added functionality to support testing composite grammars. 1414 execLexer() 1415 1416 src/org/antlr/test/TestAttributes.java # edit 1417 Tweak to deal with shared recognizer state. 1418 1419 src/org/antlr/test/TestCompositeGrammars.java # add 1420 Start of my unit tests. 1421 1422 src/org/antlr/tool/CompositeGrammar.java # add 1423 src/org/antlr/tool/CompositeGrammarTree.java # add 1424 Tracks main grammar and all delegate grammars. Tracks unique 1425 NFA state numbers and unique token types. This keeps a tree 1426 of grammars computed from the import/delegation chain. When 1427 you want to look up a rule, it starts at the root of the 1428 tree and does a pre-order search to find the rule. 1429 1430 src/org/antlr/tool/ActionAnalysis.g # edit 1431 src/org/antlr/tool/ActionAnalysisLexer.java # edit 1432 1433 src/org/antlr/tool/AttributeScope.java # edit 1434 Updated to use generics in one place. 1435 1436 src/org/antlr/tool/DOTGenerator.java # edit 1437 Updated to indicate when nonlocal rules are referenced. 1438 1439 src/org/antlr/tool/ErrorManager.java # edit 1440 Added some error messages for import grammars; I need more. 1441 1442 src/org/antlr/tool/FASerializer.java # edit 1443 Tweaked to use a field not method. 1444 1445 src/org/antlr/tool/Grammar.java # edit 1446 This is where most of the meat is for the grammar import 1447 stuff as you can imagine. I factored out the token type 1448 tracking into the CompositeGrammar object. I added code to 1449 the addArtificialMatchTokensRule method so that it includes 1450 references to all delegate lexer Tokens rules. Altered the 1451 rule lookup stuff so that it knows about delegate grammars. 1452 1453 src/org/antlr/tool/GrammarAST.java # edit 1454 src/org/antlr/tool/GrammarAnalysisAbortedMessage.java # edit 1455 src/org/antlr/tool/GrammarReport.java # edit 1456 src/org/antlr/tool/NonRegularDecisionMessage.java # edit 1457 Made enclosing rule visible as field. 1458 1459 src/org/antlr/tool/GrammarSanity.java # edit 1460 General cleanup and addition of generics. 1461 1462 src/org/antlr/tool/Interpreter.java # edit 1463 Reference fields instead of methods. 1464 1465 src/org/antlr/tool/NFAFactory.java # edit 1466 General cleanup and use of Rule object instead of rule 1467 index. 1468 1469 src/org/antlr/tool/NameSpaceChecker.java # edit 1470 A little bit of cleanup and changes to use either the local 1471 or globally visible rule. Added code to check that scopes 1472 are valid on scoped rule references. again this is an 1473 internal feature, not to be used by users. 1474 1475 src/org/antlr/tool/RandomPhrase.java # edit 1476 Tweaked. 1477 1478 src/org/antlr/tool/Rule.java # edit 1479 Added field imported. Removed some unused methods by 1480 commenting them out. Made toString() more expressive. 1481 1482 src/org/antlr/tool/antlr.g # edit 1483 src/org/antlr/tool/antlr.print.g # edit 1484 src/org/antlr/tool/assign.types.g # edit 1485 src/org/antlr/tool/buildnfa.g # edit 1486 src/org/antlr/tool/define.g # edit 1487 Added syntax for import statement. assign.types.g is the 1488 grammar that invokes Grammar.importGrammar(). 1489 1490 src/org/antlr/tool/templates/messages/languages/en.stg # edit 1491 Added error messages. 1492 1493 Added 1494 1495 CHANGES.txt 1496 runtime/Java/src/org/antlr/runtime/RecognizerSharedState.java 1497 src/org/antlr/test/TestCompositeGrammars.java 1498 src/org/antlr/tool/CompositeGrammar.java 1499 src/org/antlr/tool/CompositeGrammarTree.java 1500 15013.0.1 - August 13, 2007 1502 1503[See target pages on the wiki for more information on the non-Java targets] 1504 1505August 7, 2007 1506 1507* added escaping of double quotes in DOTTreeGenerator 1508 1509July 22, 2007 1510 1511* fixed dynamic scope implementation in lexers. They were not creating new scope 1512 entries on the stack. Unsupported feature! 1513 1514July 30, 2007 1515 1516* float return values were initalized to 0.0 not 0.0f in java. 1517 1518July 28, 2007 1519 1520* Sam Ellis points out an init var bug in ANTLRReaderStream. 1521 1522July 27, 2007 (done in dev branch) 1523 1524* Moved token type index stuff from CommonTreeNodeStream to TreeWizard 1525 1526* Added getChildren to BaseTree. 1527 1528* Added heterogeneous tree functionality; rewrite for parser/tree parser 1529 and auto AST constr. for parser. 1530 1531 org/antlr/runtime/tree/RewriteRuleElementStream.java 1532 org/antlr/runtime/tree/RewriteRuleNodeStream.java 1533 org/antlr/runtime/tree/RewriteRuleTokenStream.java 1534 Renamed method next() and re-factor things to have more 1535 specific methods: nextToken, nextNode, nextTree. 1536 1537 codegen/codegen.g 1538 Updated to include new <NodeType> AST structure for 1539 token references. Pushed hereto attribute into 1540 all tokenRef* templates. 1541 codegen/templates/Java/AST.stg 1542 Factored out a few templates: 1543 createImaginaryNode(tokenType,hetero,args) 1544 createRewriteNodeFromElement(token,hetero,args) 1545 Converted a lot of stream next() calls to more specific 1546 nextToken, nextNode, nextTree per above. 1547 codegen/templates/Java/ASTParser.stg 1548 Added createNodeFromToken template and re-factored creation 1549 sites to use that template. Added hetero attribute. 1550 codegen/templates/Java/ASTTreeParser.stg 1551 Added createRewriteNodeFromElement template and re-factored. 1552 1553 test/TestHeteroAST.java 1554 New file. Unit tests to test new hetero tree construction. 1555 test/TestRewriteAST.java 1556 Fixed test. Nil single-node trees no longer return nil; 1557 They return null. 1558 1559 tool/ErrorManager.java 1560 tool/templates/messages/languages/en.stg 1561 Added error message: 1562 HETERO_ILLEGAL_IN_REWRITE_ALT(arg) ::= 1563 "alts with rewrites can't use heterogeneous types left of ->" 1564 1565 tool/antlr.g 1566 tool/antlr.print.g 1567 tool/assign.types.g 1568 tool/buildnfa.g 1569 tool/define.g 1570 Added syntax for <NodeType> to token references. 1571 Altered AST structure rippled through different phases. 1572 1573July 24, 2007 1574 1575* Deleted DoubleLinkTree.java; CommonTree does that now. 1576 1577July 23, 2007 1578 1579* template group outputFile; changed rewrite arg to rewriteMode. 1580 1581* added rewrite mode for tree parser build AST. 1582 1583July 22, 2007 1584 1585* Kay fixed dynamic scope implementation in lexers. They were not 1586 creating new scope entries on the stack. This is an UNSUPPORTED feature. 1587 1588* added getParent and getChildIndex to TreeAdaptor. Added 1589 implementation to CommonTree. It's just too useful having those 1590 parent and child indexes available for rewriting etc... I tried 2x 1591 to make an implementation of tree rewriting w/o this and the 1592 constraints just made it too expensive and complicated. Have to 1593 update adaptors to set parent, child index values. Updated Tree 1594 interface and BaseTree also. Should only affect target developers 1595 not users. Well, unless they impl Tree. 1596 1597* dupNode (via ctor) of CommonTree didn't copy start/stop token indexes. 1598 1599TARGET DEVELOPERS WARNING -- AST.stg split with some functionality 1600 going into ASTParser.stg then I added 1601 ASTTreeParser.stg. CodeGenerator 1602 assumes new subgroups exist. 1603 1604July 20, 2007 1605 1606* Added AST construction for tree parsers including -> rewrite rules. 1607 Rewrite mode (rewrite=true) alters the tree in place rather than 1608 constructing a whole new tree. Implementation notes: 1609 1610 org/antlr/runtime/tree/Tree.java 1611 Add methods for parent and child index functionality. 1612 Also added freshenParentAndChildIndexes() which you can use 1613 to ensure that all double linking is set up right after you 1614 manipulate the tree manually. The setChild preteens etc. do 1615 the proper thing so you shouldn't need this. 1616 Added replaceChildren() to support tree rewrite mode in tree parsers 1617 org/antlr/runtime/tree/BaseTree.java 1618 Updated to set parent and child index stuff. Added replaceChildren 1619 method etc... It still only has a list of children as sole field 1620 but calls methods that subclasses can choose to implement such as 1621 CommonTree. 1622 org/antlr/runtime/tree/CommonTree.java 1623 Added parent and childIndex fields to doubly link. 1624 org/antlr/runtime/tree/TreeAdaptor.java 1625 Added methods for new parent and child index functionality. 1626 Also added method for rewrite mode in tree parsers: 1627 replaceChildren(Object parent, int startChildIndex, 1628 int stopChildIndex, Object t); 1629 Added setChild and deleteChild methods 1630 org/antlr/runtime/tree/BaseTreeAdaptor.java 1631 Moved dupTree here from BaseTree. 1632 Updated rulePostProcessing to deal with parent and child index. 1633 Added setChild and deleteChild implementations 1634 org/antlr/runtime/tree/CommonTreeAdaptor.java 1635 Added methods to deal with the parent and child index for a node. 1636 1637 org/antlr/runtime/tree/CommonTreeNodeStream.java 1638 Removed token type index and method fillReverseIndex etc... 1639 Probably will move into the tree wizard in the future. 1640 Changed call/seek stack implementation to use IntArray 1641 Added replaceChildren interface. 1642 org/antlr/runtime/tree/TreeNodeStream.java 1643 Added replaceChildren. 1644 org/antlr/runtime/tree/UnBufferedTreeNodeStream.java 1645 Added replaceChildren method but no implementation 1646 1647 codegen/templates/ANTLRCore.sti 1648 Changed rewrite to a better name: rewriteMode 1649 Added tree level argument to alt, tree so that auto AST 1650 construction can occur while recognizing in tree parsers. 1651 1652 codegen/templates/Java/AST.stg 1653 Split template group: added two subclasses to handle different 1654 functionality for normal parsing and tree parsing + AST 1655 construction. Tree parsers default behavior is to dup tree 1656 not construct another. Added ASTParser.stg and 1657 ASTTreeParser.stg to handle auto AST construction during 1658 recognition for the two different parser types. I just copied 1659 the token, rule, set, wildcard templates to the subclasses. 1660 The rewrite templates are still in AST.stg. I factored out the 1661 node creation so that the same rewrite templates can be used 1662 for both parsing and tree parsing. 1663 1664 codegen/templates/Java/ASTParser.stg 1665 The templates needed to build trees with auto construction 1666 during parsing. 1667 codegen/templates/Java/ASTTreeParser.stg 1668 The templates needed to build trees with auto construction 1669 during tree parsing. 1670 codegen/templates/Java/Java.stg 1671 genericParser now has rewriteElementType (Note or Token) so 1672 that the rewrite streams know what kind of elements are inside 1673 during rewrite rule tree construction. 1674 codegen/templates/Java/ST.stg 1675 rewrite attribute name change to rewriteMode 1676 1677 org/antlr/runtime/debug/DebugTreeAdaptor.java 1678 org/antlr/runtime/debug/DebugTreeNodeStream.java 1679 Updated to handle new interfaces 1680 1681 test/BaseTest.java 1682 Added test rig update to handle AST construction by tree parsers. 1683 All tree construction runs automatically test sanity of parent 1684 and child indexes. 1685 test/TestTreeGrammarRewriteAST.java 1686 test/TestTreeNodeStream.java 1687 test/TestTrees.java 1688 new file; tests the new parent and child index stuff in trees. 1689 1690July 19, 2007 1691 1692* implemented new unique ID; GC was causing non unique hash codes. Debugging 1693 tree grammars was messing up. 1694 1695* got tree rewrites working in tree grammars. It builds a completely new 1696 tree from old tree; i.e., you get two trees in memory. W/o a rewrite 1697 rule, the input for that rule is duplicated and returned. -> w/o elements 1698 to the right means don't return anything; i.e., delete. Ooops...way 1699 harder than I thought. Real implementation notes above. 1700 1701INCOMPATIBILITY WARNING -- templates have changed; must regen output from 1702 grammars. Runtime libraries have also changed. 1703 Debug event listener interface has changed also. 1704 1705July 17, 2007 1706 1707* Added line/charposition to node socket events and event dump so 1708 we have more info during tree parsing. Only works if your 1709 tree adaptor returns a value Token object from getToken(treenode) 1710 with line/col set. Refactored consumeNode/LN to use deserializeNode(). 1711 1712* Fixed mismatched tree node exceptions; for imaginary nodes, it said 1713 "missing null". Now prints the token type we found. 1714 1715* Cleaned up exception stuff. MismatchedTreeNodeException was setting 1716 line/col, but only RecognitionException should do that. 1717 1718* If imaginary token gets a mismatch, there is no line info. Search 1719 backwards in stream if input node stream supports to find last 1720 node with good line/col info. E.g., 1721 1722ANTLRv3Tree.g: node from after line 156:72 mismatched tree node: EOA expecting <UP> 1723 1724 which used to be: 1725 1726ANTLRv3Tree.g: node from line 0:0 mismatched tree node: null expecting <UP> 1727 1728* mismatched tree node exceptions were not sent to the debug event stream. 1729 Due to a type being slightly different on recoverFromMismatchedToken() 1730 in DebugTreeParser. Was calling BaseRecognizer version not subclass. 1731 Now we get: 1732 1733 9459: Recognition exception MismatchedTreeNodeException(0!=0) 1734 1735* List labels were not allowed as root nodes in tree rewrites like 1736 ^($listlabel ...). Had to add a template to AST.stg: 1737 1738 /** Gen ^($label ...) where label+=... */ 1739 rewriteTokenListLabelRefRoot ::= rewriteTokenLabelRefRoot 1740 1741 1742July 16, 2007 1743 1744* fixed nextNode in RewriteRuleSubtreeStream was dup'ing too much, 1745 screwing up debug event stream. Also there was a bug in how 1746 the rewrite tree stream stuff decided to dup nodes. 1747 1748* fixed bug in LT for tree parsing; text was not transmitted properly; 1749 only single words worked. 1750 1751* made decision for rule put line/col on colon not first token of first alt. 1752 1753* remote ProxyToken now emits token index for easier debugging when looking 1754 at AW's event stream. For example, the @5 here is the token index: 1755 1756 31 Consume hidden [ /<64>,channel=99,30:7, @5] 1757 1758* same is true for consume nodes now: 1759 1760 25586 Consume node [')'/, <44>, 4712040,@1749] 25 1761 1762 When debugging tree parsers, it helps to track errors when you know 1763 what corresponding input symbol created this tree node. 1764 1765* Changed debug events associated with trees quite a bit. Passes nodes around 1766 now rather than text, type, unique IDs etc... Mostly affects internal stuff. 1767 Target developers will have some work in their runtime to do to match 1768 this change. :( BUT, there is only a slight tweak in the Dbg.stg 1769 and ASTDbg.stg templates. 1770 Interface just didn't make sense as is. If you turn on debugging, and 1771 want to track a node creation, you want the node pointer not its ID, 1772 text, etc... 1773 Added ProxyTree for passing across socket. Has line/charpos and tokenIndex 1774 1775July 15, 2007 1776 1777* added null ptr protection in CommonTreeAdaptor. 1778 1779July 14, 2007 1780 1781* null child in TreeAdaptor does nothing now. Changed interface and 1782 implementation. Changed DebugTreeAdaptor to not fire events on null add 1783 as well. 1784 1785July 12, 2007 1786 1787* added get method for the line/col to DFA map in Grammar.java 1788 1789July 7, 2007 1790 1791* fixed wrong order of test for exceptions in Lexer.getErrorMessage() 1792 1793June 28, 2007 1794 1795* Added ability to set the port number in the constructor for the debug parser. 1796 1797June 5, 2007 1798 1799* Changed (hidden) option -verbose to -Xnfastates; this just prints out the NFA states along each nondeterministic path for nondeterminism warnings. 1800 1801May 18, 2007 1802 1803* there were some dependencies with org.antlr.* that I removed from 1804 org.antlr.runtime.* 1805 18063.0 final - May 17, 2007 1807 1808May 14, 2007 1809 1810* Auto backtracking didn't work with ! and ^ suffixes on first element 1811 of an alt. 1812 1813* Auto backtracking didn't work with an action as first element. 1814 1815May 10, 2007 1816 1817* turn off the warning about no local messages: 1818 no such locale file org/antlr/tool/templates/messages/languages/ru.stg retrying with English locale 1819 1820May 5, 2007 1821 1822* moving org.antlr.runtime to runtime/Java/src/org/... Other target 1823 source / libs are under runtime/targetname. 1824 1825May 4, 2007 1826 1827* You could not use arguments on a token reference that was a route in a 1828 tree rewrite rule like -> ^(ID[args] ...). 1829 1830May 3, 2007 1831 1832* Fixed ANTLR-82. Actions after the root were considered part of 1833 an optional child. They were not always executed. Required a change 1834 to the ANTLRCore.sti interface for tree() template. 1835 1836May 2, 2007 1837 1838* Fixed ANTLR-117. Wasn't building decisions properly for subrules in 1839 syntactic predicates. 1840 1841April 22, 2007 1842 1843* Made build.xml ref all jars in antlr lib. Thanks to Miguel Ping. 1844 1845* Fixed ANTLR-11 1846 1847* Now labels on ranges and such in lexer work properly. 1848 1849* ActionAnalysisLexer was in wrong package. 1850 1851April 21, 2007 1852 1853* Pushing a huge update that fixes: 1854 http://www.antlr.org/browse/ANTLR-112 1855 http://www.antlr.org/browse/ANTLR-110 1856 http://www.antlr.org/browse/ANTLR-109 1857 http://www.antlr.org/browse/ANTLR-103 1858 http://www.antlr.org/browse/ANTLR-97 1859 http://www.antlr.org/browse/ANTLR-113 1860 http://www.antlr.org/browse/ANTLR-66 1861 http://www.antlr.org/browse/ANTLR-98 1862 http://www.antlr.org/browse/ANTLR-24 1863 http://www.antlr.org/browse/ANTLR-114 1864 http://www.antlr.org/browse/ANTLR-5 1865 http://www.antlr.org/browse/ANTLR-6 1866 1867 Basically, I gutted the way AST rewrites work. MUCH better. 1868 1869* Fixed lots of little label issues in the lexer. Couldn't do x+=ID 1870 in lexer, for example. Fixed ANTLR-114, ANTLR-112 1871 1872* Isolated EOT transition in lexer generated dangling else clause. 1873 Fixed ANTLR-113. 1874 1875April 17, 2007 1876 1877* Fixed a major problem with gated semantic predicates. Added more 1878 unit tests. 1879 1880* Fixed bug in cyclic DFA with syntactic predicates. Wasn't rewinding 1881 properly. Further, mark() in token stream did not fill buffer so 1882 when you rewound back to last marker index was -1 not 0. At same time 1883 I fixed ANTLR-103. Syn preds evaluated only once now. 1884 1885* Altered code gen file writing so it writes directly to a file 1886 instead of building a big string and then writing that out. Should 1887 be faster and much less memory intensive. 1888 1889* Fixed so antlr writes files to correct location again. See: 1890 1891http://www.antlr.org/wiki/pages/viewpage.action?pageId=1862 1892 18933.0b7 - April 12, 2007 1894 1895April 10, 2007 1896 1897* Allows -> {...} actions now when building ASTs. Fixed ANTLR-14. 1898 1899* Allows ! on sets and wildcard now during output=AST option. Fixed ANTLR-17. 1900 1901* Fixed ANTLR-92 bug. Couldn't use sets with -> tree construction. 1902 1903* No lexer rule for a token type is now a warning. 1904 1905* Fixed set labels in lexer; ANTLR-60 bug 1906 1907* Fixed problem with duplicate state variable definitions in switch-case 1908 1909April 9, 2007 1910 1911* Gated predicates didn't work properly in cyclic DFA. 1912 1913April 7, 2007 1914 1915* Couldn't have more than one set per rule it seems. Fixed. 1916 1917April 3, 2007 1918 1919* Fix a problem in my unused label optimization. Added new 1920 pass over actions to examine them. 1921 1922* RuleReturnScope has method back: 1923 /** Has a value potentially if output=template; Don't use StringTemplate 1924 * type as it then causes a dependency with ST lib. 1925 */ 1926 public Object getTemplate() { return null; } 1927 1928March 30, 2007 1929 1930* Fixed ANTLR-8. Labels to rules w/o return values caused compile errors. 1931 1932* Fixed ANTLR-89; semantic predicates in lexer sometimes 1933 caused exception in code gen. 1934 1935* Fixed ANTLR-36; remove runtime dependency with ST 1936 1937March 29, 2007 1938 1939* Over last few days, I've gutted how ANTLR handles sets of chars or 1940 tokens. I cleaned up a lot of stuff in the grammars and added lots 1941 of unit tests. 1942 1943March 26, 2007 1944 1945* CommonTreeNodeStream didn't push correctly; couldn't handle very 1946 deeply nested trees. 1947 1948* Fixed bug that E : 'a' 'b' ; made E be seen as an alias of 'a'. 1949 1950March 22, 2007 1951 1952* Working with Egor Ushakov from Sun Optimization / NetBeans team I 1953 made all the Java lexer transition tables static w/o screwing up 1954 ability to reference semantic predicates etc... Only changed Java.stg 1955 1956* cached text string in CommonToken.getText(); saves on repeated calls; 1957 Java mode. 1958 1959* made all generated methods final; saves a few percent speed according to 1960 Egor Ushakov (Java only). 1961 1962* removed most assignments from each lexer rule and even the Lexer.emit() 1963 call! All done in nextToken now. Saves on code gen size and a wee bit of 1964 execution speed probably. Variables became fields: type, channel, line, 1965 etc... Now emit() needs no args even. Again, Egor helped on this. 1966 1967March 17, 2007 1968 1969* Jonathan DeKlotz updated C# templates to be 3.0b6 current 1970 1971March 14, 2007 1972 1973* Manually-specified (...)=> force backtracking eval of that predicate. 1974 backtracking=true mode does not however. Added unit test. 1975 1976March 14, 2007 1977 1978* Fixed bug in lexer where ~T didn't compute the set from rule T. 1979 1980* Added -Xnoinlinedfa make all DFA with tables; no inline prediction with IFs 1981 1982* Fixed http://www.antlr.org/browse/ANTLR-80. 1983 Sem pred states didn't define lookahead vars. 1984 1985* Fixed http://www.antlr.org/browse/ANTLR-91. 1986 When forcing some acyclic DFA to be state tables, they broke. 1987 Forcing all DFA to be state tables should give same results. 1988 1989March 12, 2007 1990 1991* setTokenSource in CommonTokenStream didn't clear tokens list. 1992 setCharStream calls reset in Lexer. 1993 1994* Altered -depend. No longer printing grammar files for multiple input 1995 files with -depend. Doesn't show T__.g temp file anymore. Added 1996 TLexer.tokens. Added .h files if defined. 1997 1998February 11, 2007 1999 2000* Added -depend command-line option that, instead of processing files, 2001 it shows you what files the input grammar(s) depend on and what files 2002 they generate. For combined grammar T.g: 2003 2004 $ java org.antlr.Tool -depend T.g 2005 2006 You get: 2007 2008 TParser.java : T.g 2009 T.tokens : T.g 2010 T__.g : T.g 2011 2012 Now, assuming U.g is a tree grammar ref'd T's tokens: 2013 2014 $ java org.antlr.Tool -depend T.g U.g 2015 2016 TParser.java : T.g 2017 T.tokens : T.g 2018 T__.g : T.g 2019 U.g: T.tokens 2020 U.java : U.g 2021 U.tokens : U.g 2022 2023 Handles spaces by escaping them. Pays attention to -o, -fo and -lib. 2024 Dir 'x y' is a valid dir in current dir. 2025 2026 $ java org.antlr.Tool -depend -lib /usr/local/lib -o 'x y' T.g U.g 2027 x\ y/TParser.java : T.g 2028 x\ y/T.tokens : T.g 2029 x\ y/T__.g : T.g 2030 U.g: /usr/local/lib/T.tokens 2031 x\ y/U.java : U.g 2032 x\ y/U.tokens : U.g 2033 2034 You have API access via org.antlr.tool.BuildDependencyGenerator class: 2035 getGeneratedFileList(), getDependenciesFileList(). You can also access 2036 the output template: getDependencies(). The file 2037 org/antlr/tool/templates/depend.stg contains the template. You can 2038 modify as you want. File objects go in so you can play with path etc... 2039 2040February 10, 2007 2041 2042* no more .gl files generated. All .g all the time. 2043 2044* changed @finally to be @after and added a finally clause to the 2045 exception stuff. I also removed the superfluous "exception" 2046 keyword. Here's what the new syntax looks like: 2047 2048 a 2049 @after { System.out.println("ick"); } 2050 : 'a' 2051 ; 2052 catch[RecognitionException e] { System.out.println("foo"); } 2053 catch[IOException e] { System.out.println("io"); } 2054 finally { System.out.println("foobar"); } 2055 2056 @after executes after bookkeeping to set $rule.stop, $rule.tree but 2057 before scopes pop and any memoization happens. Dynamic scopes and 2058 memoization are still in generated finally block because they must 2059 exec even if error in rule. The @after action and tree setting 2060 stuff can technically be skipped upon syntax error in rule. [Later 2061 we might add something to finally to stick an ERROR token in the 2062 tree and set the return value.] Sequence goes: set $stop, $tree (if 2063 any), @after (if any), pop scopes (if any), memoize (if needed), 2064 grammar finally clause. Last 3 are in generated code's finally 2065 clause. 2066 20673.0b6 - January 31, 2007 2068 2069January 30, 2007 2070 2071* Fixed bug in IntervalSet.and: it returned the same empty set all the time 2072 rather than new empty set. Code altered the same empty set. 2073 2074* Made analysis terminate faster upon a decision that takes too long; 2075 it seemed to keep doing work for a while. Refactored some names 2076 and updated comments. Also made it terminate when it realizes it's 2077 non-LL(*) due to recursion. just added terminate conditions to loop 2078 in convert(). 2079 2080* Sometimes fatal non-LL(*) messages didn't appear; instead you got 2081 "antlr couldn't analyze", which is actually untrue. I had the 2082 order of some prints wrong in the DecisionProbe. 2083 2084* The code generator incorrectly detected when it could use a fixed, 2085 acyclic inline DFA (i.e., using an IF). Upon non-LL(*) decisions 2086 with predicates, analysis made cyclic DFA. But this stops 2087 the computation detecting whether they are cyclic. I just added 2088 a protection in front of the acyclic DFA generator to avoid if 2089 non-LL(*). Updated comments. 2090 2091January 23, 2007 2092 2093* Made tree node streams use adaptor to create navigation nodes. 2094 Thanks to Emond Papegaaij. 2095 2096January 22, 2007 2097 2098* Added lexer rule properties: start, stop 2099 2100January 1, 2007 2101 2102* analysis failsafe is back on; if a decision takes too long, it bails out 2103 and uses k=1 2104 2105January 1, 2007 2106 2107* += labels for rules only work for output option; previously elements 2108 of list were the return value structs, but are now either the tree or 2109 StringTemplate return value. You can label different rules now 2110 x+=a x+=b. 2111 2112December 30, 2006 2113 2114* Allow \" to work correctly in "..." template. 2115 2116December 28, 2006 2117 2118* errors that are now warnings: missing AST label type in trees. 2119 Also "no start rule detected" is warning. 2120 2121* tree grammars also can do rewrite=true for output=template. 2122 Only works for alts with single node or tree as alt elements. 2123 If you are going to use $text in a tree grammar or do rewrite=true 2124 for templates, you must use in your main: 2125 2126 nodes.setTokenStream(tokens); 2127 2128* You get a warning for tree grammars that do rewrite=true and 2129 output=template and have -> for alts that are not simple nodes 2130 or simple trees. new unit tests in TestRewriteTemplates at end. 2131 2132December 27, 2006 2133 2134* Error message appears when you use -> in tree grammar with 2135 output=template and rewrite=true for alt that is not simple 2136 node or tree ref. 2137 2138* no more $stop attribute for tree parsers; meaningless/useless. 2139 Removed from TreeRuleReturnScope also. 2140 2141* rule text attribute in tree parser must pull from token buffer. 2142 Makes no sense otherwise. added getTokenStream to TreeNodeStream 2143 so rule $text attr works. CommonTreeNodeStream etc... now let 2144 you set the token stream so you can access later from tree parser. 2145 $text is not well-defined for rules like 2146 2147 slist : stat+ ; 2148 2149 because stat is not a single node nor rooted with a single node. 2150 $slist.text will get only first stat. I need to add a warning about 2151 this... 2152 2153* Fixed http://www.antlr.org/browse/ANTLR-76 for Java. 2154 Enhanced TokenRewriteStream so it accepts any object; converts 2155 to string at last second. Allows you to rewrite with StringTemplate 2156 templates now :) 2157 2158* added rewrite option that makes -> template rewrites do replace ops for 2159 TokenRewriteStream input stream. In output=template and rewrite=true mode 2160 same as before 'cept that the parser does 2161 2162 ((TokenRewriteStream)input).replace( 2163 ((Token)retval.start).getTokenIndex(), 2164 input.LT(-1).getTokenIndex(), 2165 retval.st); 2166 2167 after each rewrite so that the input stream is altered. Later refs to 2168 $text will have rewrites. Here's a sample test program for grammar Rew. 2169 2170 FileReader groupFileR = new FileReader("Rew.stg"); 2171 StringTemplateGroup templates = new StringTemplateGroup(groupFileR); 2172 ANTLRInputStream input = new ANTLRInputStream(System.in); 2173 RewLexer lexer = new RewLexer(input); 2174 TokenRewriteStream tokens = new TokenRewriteStream(lexer); 2175 RewParser parser = new RewParser(tokens); 2176 parser.setTemplateLib(templates); 2177 parser.program(); 2178 System.out.println(tokens.toString()); 2179 groupFileR.close(); 2180 2181December 26, 2006 2182 2183* BaseTree.dupTree didn't dup recursively. 2184 2185December 24, 2006 2186 2187* Cleaned up some comments and removed field treeNode 2188 from MismatchedTreeNodeException class. It is "node" in 2189 RecognitionException. 2190 2191* Changed type from Object to BitSet for expecting fields in 2192 MismatchedSetException and MismatchedNotSetException 2193 2194* Cleaned up error printing in lexers and the messages that it creates. 2195 2196* Added this to TreeAdaptor: 2197 /** Return the token object from which this node was created. 2198 * Currently used only for printing an error message. 2199 * The error display routine in BaseRecognizer needs to 2200 * display where the input the error occurred. If your 2201 * tree of limitation does not store information that can 2202 * lead you to the token, you can create a token filled with 2203 * the appropriate information and pass that back. See 2204 * BaseRecognizer.getErrorMessage(). 2205 */ 2206 public Token getToken(Object t); 2207 2208December 23, 2006 2209 2210* made BaseRecognizer.displayRecognitionError nonstatic so people can 2211 override it. Not sure why it was static before. 2212 2213* Removed state/decision message that comes out of no 2214 viable alternative exceptions, as that was too much. 2215 removed the decision number from the early exit exception 2216 also. During development, you can simply override 2217 displayRecognitionError from BaseRecognizer to add the stuff 2218 back in if you want. 2219 2220* made output go to an output method you can override: emitErrorMessage() 2221 2222* general cleanup of the error emitting code in BaseRecognizer. Lots 2223 more stuff you can override: getErrorHeader, getTokenErrorDisplay, 2224 emitErrorMessage, getErrorMessage. 2225 2226December 22, 2006 2227 2228* Altered Tree.Parser.matchAny() so that it skips entire trees if 2229 node has children otherwise skips one node. Now this works to 2230 skip entire body of function if single-rooted subtree: 2231 ^(FUNC name=ID arg=ID .) 2232 2233* Added "reverse index" from node to stream index. Override 2234 fillReverseIndex() in CommonTreeNodeStream if you want to change. 2235 Use getNodeIndex(node) to find stream index for a specific tree node. 2236 See getNodeIndex(), reverseIndex(Set tokenTypes), 2237 reverseIndex(int tokenType), fillReverseIndex(). The indexing 2238 costs time and memory to fill, but pulling stuff out will be lots 2239 faster as it can jump from a node ptr straight to a stream index. 2240 2241* Added TreeNodeStream.get(index) to make it easier for interpreters to 2242 jump around in tree node stream. 2243 2244* New CommonTreeNodeStream buffers all nodes in stream for fast jumping 2245 around. It now has push/pop methods to invoke other locations in 2246 the stream for building interpreters. 2247 2248* Moved CommonTreeNodeStream to UnBufferedTreeNodeStream and removed 2249 Iterator implementation. moved toNodesOnlyString() to TestTreeNodeStream 2250 2251* [BREAKS ANY TREE IMPLEMENTATION] 2252 made CommonTreeNodeStream work with any tree node type. TreeAdaptor 2253 now implements isNil so must add; trivial, but does break back 2254 compatibility. 2255 2256December 17, 2006 2257 2258* Added traceIn/Out methods to recognizers so that you can override them; 2259 previously they were in-line print statements. The message has also 2260 been slightly improved. 2261 2262* Factored BuildParseTree into debug package; cleaned stuff up. Fixed 2263 unit tests. 2264 2265December 15, 2006 2266 2267* [BREAKS ANY TREE IMPLEMENTATION] 2268 org.antlr.runtime.tree.Tree; needed to add get/set for token start/stop 2269 index so CommonTreeAdaptor can assume Tree interface not CommonTree 2270 implementation. Otherwise, no way to create your own nodes that satisfy 2271 Tree because CommonTreeAdaptor was doing 2272 2273 public int getTokenStartIndex(Object t) { 2274 return ((CommonTree)t).startIndex; 2275 } 2276 2277 Added to Tree: 2278 2279 /** What is the smallest token index (indexing from 0) for this node 2280 * and its children? 2281 */ 2282 int getTokenStartIndex(); 2283 2284 void setTokenStartIndex(int index); 2285 2286 /** What is the largest token index (indexing from 0) for this node 2287 * and its children? 2288 */ 2289 int getTokenStopIndex(); 2290 2291 void setTokenStopIndex(int index); 2292 2293December 13, 2006 2294 2295* Added org.antlr.runtime.tree.DOTTreeGenerator so you can generate DOT 2296 diagrams easily from trees. 2297 2298 CharStream input = new ANTLRInputStream(System.in); 2299 TLexer lex = new TLexer(input); 2300 CommonTokenStream tokens = new CommonTokenStream(lex); 2301 TParser parser = new TParser(tokens); 2302 TParser.e_return r = parser.e(); 2303 Tree t = (Tree)r.tree; 2304 System.out.println(t.toStringTree()); 2305 DOTTreeGenerator gen = new DOTTreeGenerator(); 2306 StringTemplate st = gen.toDOT(t); 2307 System.out.println(st); 2308 2309* Changed the way mark()/rewind() work in CommonTreeNode stream to mirror 2310 more flexible solution in ANTLRStringStream. Forgot to set lastMarker 2311 anyway. Now you can rewind to non-most-recent marker. 2312 2313December 12, 2006 2314 2315* Temp lexer now end in .gl (T__.gl, for example) 2316 2317* TreeParser suffix no longer generated for tree grammars 2318 2319* Defined reset for lexer, parser, tree parser; rewinds the input stream also 2320 2321December 10, 2006 2322 2323* Made Grammar.abortNFAToDFAConversion() abort in middle of a DFA. 2324 2325December 9, 2006 2326 2327* fixed bug in OrderedHashSet.add(). It didn't track elements correctly. 2328 2329December 6, 2006 2330 2331* updated build.xml for future Ant compatibility, thanks to Matt Benson. 2332 2333* various tests in TestRewriteTemplate and TestSyntacticPredicateEvaluation 2334 were using the old 'channel' vs. new '$channel' notation. 2335 TestInterpretedParsing didn't pick up an earlier change to CommonToken. 2336 Reported by Matt Benson. 2337 2338* fixed platform dependent test failures in TestTemplates, supplied by Matt 2339 Benson. 2340 2341November 29, 2006 2342 2343* optimized semantic predicate evaluation so that p||!p yields true. 2344 2345November 22, 2006 2346 2347* fixed bug that prevented var = $rule.some_retval from working in anything 2348 but the first alternative of a rule or subrule. 2349 2350* attribute names containing digits were not allowed, this is now fixed, 2351 allowing attributes like 'name1' but not '1name1'. 2352 2353November 19, 2006 2354 2355* Removed LeftRecursionMessage and apparatus because it seems that I check 2356 for left recursion upfront before analysis and everything gets specified as 2357 recursion cycles at this point. 2358 2359November 16, 2006 2360 2361* TokenRewriteStream.replace was not passing programName to next method. 2362 2363November 15, 2006 2364 2365* updated DOT files for DFA generation to make smaller circles. 2366 2367* made epsilon edges italics in the NFA diagrams. 2368 23693.0b5 - November 15, 2006 2370 2371The biggest thing is that your grammar file names must match the grammar name 2372inside (your generated class names will also be different) and we use 2373$channel=HIDDEN now instead of channel=99 inside lexer actions. 2374Should be compatible other than that. Please look at complete list of 2375changes. 2376 2377November 14, 2006 2378 2379* Force token index to be -1 for CommonIndex in case not set. 2380 2381November 11, 2006 2382 2383* getUniqueID for TreeAdaptor now uses identityHashCode instead of hashCode. 2384 2385November 10, 2006 2386 2387* No grammar nondeterminism warning now when wildcard '.' is final alt. 2388 Examples: 2389 2390 a : A | B | . ; 2391 2392 A : 'a' 2393 | . 2394 ; 2395 2396 SL_COMMENT 2397 : '//' (options {greedy=false;} : .)* '\r'? '\n' 2398 ; 2399 2400 SL_COMMENT2 2401 : '//' (options {greedy=false;} : 'x'|.)* '\r'? '\n' 2402 ; 2403 2404 2405November 8, 2006 2406 2407* Syntactic predicates did not get hoisting properly upon non-LL(*) decision. Other hoisting issues fixed. Cleaned up code. 2408 2409* Removed failsafe that check to see if I'm spending too much time on a single DFA; I don't think we need it anymore. 2410 2411November 3, 2006 2412 2413* $text, $line, etc... were not working in assignments. Fixed and added 2414 test case. 2415 2416* $label.text translated to label.getText in lexer even if label was on a char 2417 2418November 2, 2006 2419 2420* Added error if you don't specify what the AST type is; actions in tree 2421 grammar won't work without it. 2422 2423 $ cat x.g 2424 tree grammar x; 2425 a : ID {String s = $ID.text;} ; 2426 2427 ANTLR Parser Generator Early Access Version 3.0b5 (??, 2006) 1989-2006 2428 error: x.g:0:0: (152) tree grammar x has no ASTLabelType option 2429 2430November 1, 2006 2431 2432* $text, $line, etc... were not working properly within lexer rule. 2433 2434October 32, 2006 2435 2436* Finally actions now execute before dynamic scopes are popped it in the 2437 rule. Previously was not possible to access the rules scoped variables 2438 in a finally action. 2439 2440October 29, 2006 2441 2442* Altered ActionTranslator to emit errors on setting read-only attributes 2443 such as $start, $stop, $text in a rule. Also forbid setting any attributes 2444 in rules/tokens referenced by a label or name. 2445 Setting dynamic scopes's attributes and your own parameter attributes 2446 is legal. 2447 2448October 27, 2006 2449 2450* Altered how ANTLR figures out what decision is associated with which 2451 block of grammar. Makes ANTLRWorks correctly find DFA for a block. 2452 2453October 26, 2006 2454 2455* Fixed bug where EOT transitions led to no NFA configs in a DFA state, 2456 yielding an error in DFA table generation. 2457 2458* renamed action.g to ActionTranslator.g 2459 the ActionTranslator class is now called ActionTranslatorLexer, as ANTLR 2460 generates this classname now. Fixed rest of codebase accordingly. 2461 2462* added rules recognizing setting of scopes' attributes to ActionTranslator.g 2463 the Objective C target needed access to the right-hand side of the assignment 2464 in order to generate correct code 2465 2466* changed ANTLRCore.sti to reflect the new mandatory templates to support the above 2467 namely: scopeSetAttributeRef, returnSetAttributeRef and the ruleSetPropertyRef_* 2468 templates, with the exception of ruleSetPropertyRef_text. we cannot set this attribute 2469 2470October 19, 2006 2471 2472* Fixed 2 bugs in DFA conversion that caused exceptions. 2473 altered functionality of getMinElement so it ignores elements<0. 2474 2475October 18, 2006 2476 2477* moved resetStateNumbersToBeContiguous() to after issuing of warnings; 2478 an internal error in that routine should make more sense as issues 2479 with decision will appear first. 2480 2481* fixed cut/paste bug I introduced when fixed EOF in min/max 2482 bug. Prevented C grammar from working briefly. 2483 2484October 17, 2006 2485 2486* Removed a failsafe that seems to be unnecessary that ensure DFA didn't 2487 get too big. It was resulting in some failures in code generation that 2488 led me on quite a strange debugging trip. 2489 2490October 16, 2006 2491 2492* Use channel=HIDDEN not channel=99 to put tokens on hidden channel. 2493 2494October 12, 2006 2495 2496* ANTLR now has a customizable message format for errors and warnings, 2497 to make it easier to fulfill requirements by IDEs and such. 2498 The format to be used can be specified via the '-message-format name' 2499 command line switch. The default for name is 'antlr', also available 2500 at the moment is 'gnu'. This is done via StringTemplate, for details 2501 on the requirements look in org/antlr/tool/templates/messages/formats/ 2502 2503* line numbers for lexers in combined grammars are now reported correctly. 2504 2505September 29, 2006 2506 2507* ANTLRReaderStream improperly checked for end of input. 2508 2509September 28, 2006 2510 2511* For ANTLRStringStream, LA(-1) was off by one...gave you LA(-2). 2512 25133.0b4 - August 24, 2006 2514 2515* error when no rules in grammar. doesn't crash now. 2516 2517* Token is now an interface. 2518 2519* remove dependence on non runtime classes in runtime package. 2520 2521* filename and grammar name must be same Foo in Foo.g. Generates FooParser, 2522 FooLexer, ... Combined grammar Foo generates Foo$Lexer.g which generates 2523 FooLexer.java. tree grammars generate FooTreeParser.java 2524 2525August 24, 2006 2526 2527* added C# target to lib, codegen, templates 2528 2529August 11, 2006 2530 2531* added tree arg to navigation methods in treeadaptor 2532 2533August 07, 2006 2534 2535* fixed bug related to (a|)+ on end of lexer rules. crashed instead 2536 of warning. 2537 2538* added warning that interpreter doesn't do synpreds yet 2539 2540* allow different source of classloader: 2541ClassLoader cl = Thread.currentThread().getContextClassLoader(); 2542if ( cl==null ) { 2543 cl = this.getClass().getClassLoader(); 2544} 2545 2546 2547July 26, 2006 2548 2549* compressed DFA edge tables significantly. All edge tables are 2550 unique. The transition table can reuse arrays. Look like this now: 2551 2552 public static readonly DFA30_transition0 = 2553 new short[] { 46, 46, -1, 46, 46, -1, -1, -1, -1, -1, -1, -1,...}; 2554 public static readonly DFA30_transition1 = 2555 new short[] { 21 }; 2556 public static readonly short[][] DFA30_transition = { 2557 DFA30_transition0, 2558 DFA30_transition0, 2559 DFA30_transition1, 2560 ... 2561 }; 2562 2563* If you defined both a label like EQ and '=', sometimes the '=' was 2564 used instead of the EQ label. 2565 2566* made headerFile template have same arg list as outputFile for consistency 2567 2568* outputFile, lexer, genericParser, parser, treeParser templates 2569 reference cyclicDFAs attribute which was no longer used after I 2570 started the new table-based DFA. I made cyclicDFADescriptors 2571 argument to outputFile and headerFile (only). I think this is 2572 correct as only OO languages will want the DFA in the recognizer. 2573 At the top level, C and friends can use it. Changed name to use 2574 cyclicDFAs again as it's a better name probably. Removed parameter 2575 from the lexer, ... For example, my parser template says this now: 2576 2577 <cyclicDFAs:cyclicDFA()> <! dump tables for all DFA !> 2578 2579* made all token ref token types go thru code gen's 2580 getTokenTypeAsTargetLabel() 2581 2582* no more computing DFA transition tables for acyclic DFA. 2583 2584July 25, 2006 2585 2586* fixed a place where I was adding syn predicates into rewrite stuff. 2587 2588* turned off invalid token index warning in AW support; had a problem. 2589 2590* bad location event generated with -debug for synpreds in autobacktrack mode. 2591 2592July 24, 2006 2593 2594* changed runtime.DFA so that it treats all chars and token types as 2595 char (unsigned 16 bit int). -1 becomes '\uFFFF' then or 65535. 2596 2597* changed MAX_STATE_TRANSITIONS_FOR_TABLE to be 65534 by default 2598 now. This means that all states can use a table to do transitions. 2599 2600* was not making synpreds on (C)* type loops with backtrack=true 2601 2602* was copying tree stuff and actions into synpreds with backtrack=true 2603 2604* was making synpreds on even single alt rules / blocks with backtrack=true 2605 26063.0b3 - July 21, 2006 2607 2608* ANTLR fails to analyze complex decisions much less frequently. It 2609 turns out that the set of decisions for which ANTLR fails (times 2610 out) is the same set (so far) of non-LL(*) decisions. Morever, I'm 2611 able to detect this situation quickly and report rather than timing 2612 out. Errors look like: 2613 2614 java.g:468:23: [fatal] rule concreteDimensions has non-LL(*) 2615 decision due to recursive rule invocations in alts 1,2. Resolve 2616 by left-factoring or using syntactic predicates with fixed k 2617 lookahead or use backtrack=true option. 2618 2619 This message only appears when k=*. 2620 2621* Shortened no viable alt messages to not include decision 2622 description: 2623 2624[compilationUnit, declaration]: line 8:8 decision=<<67:1: declaration 2625: ( ( fieldDeclaration )=> fieldDeclaration | ( methodDeclaration )=> 2626methodDeclaration | ( constructorDeclaration )=> 2627constructorDeclaration | ( classDeclaration )=> classDeclaration | ( 2628interfaceDeclaration )=> interfaceDeclaration | ( blockDeclaration )=> 2629blockDeclaration | emptyDeclaration );>> state 3 (decision=14) no 2630viable alt; token=[@1,184:187='java',<122>,8:8] 2631 2632 too long and hard to read. 2633 2634July 19, 2006 2635 2636* Code gen bug: states with no emanating edges were ignored by ST. 2637 Now an empty list is used. 2638 2639* Added grammar parameter to recognizer templates so they can access 2640 properties like getName(), ... 2641 2642July 10, 2006 2643 2644* Fixed the gated pred merged state bug. Added unit test. 2645 2646* added new method to Target: getTokenTypeAsTargetLabel() 2647 2648July 7, 2006 2649 2650* I was doing an AND instead of OR in the gated predicate stuff. 2651 Thanks to Stephen Kou! 2652 2653* Reduce op for combining predicates was insanely slow sometimes and 2654 didn't actually work well. Now it's fast and works. 2655 2656* There is a bug in merging of DFA stop states related to gated 2657 preds...turned it off for now. 2658 26593.0b2 - July 5, 2006 2660 2661July 5, 2006 2662 2663* token emission not properly protected in lexer filter mode. 2664 2665* EOT, EOT DFA state transition tables should be init'd to -1 (only 2666 was doing this for compressed tables). Fixed. 2667 2668* in trace mode, exit method not shown for memoized rules 2669 2670* added -Xmaxdfaedges to allow you to increase number of edges allowed 2671 for a single DFA state before it becomes "special" and can't fit in 2672 a simple table. 2673 2674* Bug in tables. Short are signed so min/max tables for DFA are now 2675 char[]. Bizarre. 2676 2677July 3, 2006 2678 2679* Added a method to reset the tool error state for current thread. 2680 See ErrorManager.java 2681 2682* [Got this working properly today] backtrack mode that let's you type 2683 in any old crap and ANTLR will backtrack if it can't figure out what 2684 you meant. No errors are reported by antlr during analysis. It 2685 implicitly adds a syn pred in front of every production, using them 2686 only if static grammar LL(*) analysis fails. Syn pred code is not 2687 generated if the pred is not used in a decision. 2688 2689 This is essentially a rapid prototyping mode. 2690 2691* Added backtracking report to the -report option 2692 2693* Added NFA->DFA conversion early termination report to the -report option 2694 2695* Added grammar level k and backtrack options to -report 2696 2697* Added a dozen unit tests to test autobacktrack NFA construction. 2698 2699* If you are using filter mode, you must manually use option 2700 memoize=true now. 2701 2702July 2, 2006 2703 2704* Added k=* option so you can set k=2, for example, on whole grammar, 2705 but an individual decision can be LL(*). 2706 2707* memoize option for grammars, rules, blocks. Remove -nomemo cmd-line option 2708 2709* but in DOT generator for DFA; fixed. 2710 2711* runtime.DFA reported errors even when backtracking 2712 2713July 1, 2006 2714 2715* Added -X option list to help 2716 2717* Syn preds were being hoisted into other rules, causing lots of extra 2718 backtracking. 2719 2720June 29, 2006 2721 2722* unnecessary files removed during build. 2723 2724* Matt Benson updated build.xml 2725 2726* Detecting use of synpreds in analysis now instead of codegen. In 2727 this way, I can avoid analyzing decisions in synpreds for synpreds 2728 not used in a DFA for a real rule. This is used to optimize things 2729 for backtrack option. 2730 2731* Code gen must add _fragment or whatever to end of pred name in 2732 template synpredRule to avoid having ANTLR know anything about 2733 method names. 2734 2735* Added -IdbgST option to emit ST delimiters at start/stop of all 2736 templates spit out. 2737 2738June 28, 2006 2739 2740* Tweaked message when ANTLR cannot handle analysis. 2741 27423.0b1 - June 27, 2006 2743 2744June 24, 2006 2745 2746* syn preds no longer generate little static classes; they also don't 2747 generate a whole bunch of extra crap in the rules built to test syn 2748 preds. Removed GrammarFragmentPointer class from runtime. 2749 2750June 23-24, 2006 2751 2752* added output option to -report output. 2753 2754* added profiling info: 2755 Number of rule invocations in "guessing" mode 2756 number of rule memoization cache hits 2757 number of rule memoization cache misses 2758 2759* made DFA DOT diagrams go left to right not top to bottom 2760 2761* I try to recursive overflow states now by resolving these states 2762 with semantic/syntactic predicates if they exist. The DFA is then 2763 deterministic rather than simply resolving by choosing first 2764 nondeterministic alt. I used to generated errors: 2765 2766~/tmp $ java org.antlr.Tool -dfa t.g 2767ANTLR Parser Generator Early Access Version 3.0b2 (July 5, 2006) 1989-2006 2768t.g:2:5: Alternative 1: after matching input such as A A A A A decision cannot predict what comes next due to recursion overflow to b from b 2769t.g:2:5: Alternative 2: after matching input such as A A A A A decision cannot predict what comes next due to recursion overflow to b from b 2770 2771 Now, I uses predicates if available and emits no warnings. 2772 2773* made sem preds share accept states. Previously, multiple preds in a 2774decision forked new accepts each time for each nondet state. 2775 2776June 19, 2006 2777 2778* Need parens around the prediction expressions in templates. 2779 2780* Referencing $ID.text in an action forced bad code gen in lexer rule ID. 2781 2782* Fixed a bug in how predicates are collected. The definition of 2783 "last predicated alternative" was incorrect in the analysis. Further, 2784 gated predicates incorrectly missed a case where an edge should become 2785 true (a tautology). 2786 2787* Removed an unnecessary input.consume() reference in the runtime/DFA class. 2788 2789June 14, 2006 2790 2791* -> ($rulelabel)? didn't generate proper code for ASTs. 2792 2793* bug in code gen (did not compile) 2794a : ID -> ID 2795 | ID -> ID 2796 ; 2797Problem is repeated ref to ID from left side. Juergen pointed this out. 2798 2799* use of tokenVocab with missing file yielded exception 2800 2801* (A|B)=> foo yielded an exception as (A|B) is a set not a block. Fixed. 2802 2803* Didn't set ID1= and INT1= for this alt: 2804 | ^(ID INT+ {System.out.print(\"^(\"+$ID+\" \"+$INT+\")\");}) 2805 2806* Fixed so repeated dangling state errors only occur once like: 2807t.g:4:17: the decision cannot distinguish between alternative(s) 2,1 for at least one input sequence 2808 2809* tracking of rule elements was on (making list defs at start of 2810 method) with templates instead of just with ASTs. Turned off. 2811 2812* Doesn't crash when you give it a missing file now. 2813 2814* -report: add output info: how many LL(1) decisions. 2815 2816June 13, 2006 2817 2818* ^(ROOT ID?) Didn't work; nor did any other nullable child list such as 2819 ^(ROOT ID* INT?). Now, I check to see if child list is nullable using 2820 Grammar.LOOK() and, if so, I generate an "IF lookahead is DOWN" gate 2821 around the child list so the whole thing is optional. 2822 2823* Fixed a bug in LOOK that made it not look through nullable rules. 2824 2825* Using AST suffixes or -> rewrite syntax now gives an error w/o a grammar 2826 output option. Used to crash ;) 2827 2828* References to EOF ended up with improper -1 refs instead of EOF in output. 2829 2830* didn't warn of ambig ref to $expr in rewrite; fixed. 2831list 2832 : '[' expr 'for' type ID 'in' expr ']' 2833 -> comprehension(expr={$expr.st},type={},list={},i={}) 2834 ; 2835 2836June 12, 2006 2837 2838* EOF works in the parser as a token name. 2839 2840* Rule b:(A B?)*; didn't display properly in AW due to the way ANTLR 2841 generated NFA. 2842 2843* "scope x;" in a rule for unknown x gives no error. Fixed. Added unit test. 2844 2845* Label type for refs to start/stop in tree parser and other parsers were 2846 not used. Lots of casting. Ick. Fixed. 2847 2848* couldn't refer to $tokenlabel in isolation; but need so we can test if 2849 something was matched. Fixed. 2850 2851* Lots of little bugs fixed in $x.y, %... translation due to new 2852 action translator. 2853 2854* Improperly tracking block nesting level; result was that you couldn't 2855 see $ID in action of rule "a : A+ | ID {Token t = $ID;} | C ;" 2856 2857* a : ID ID {$ID.text;} ; did not get a warning about ambiguous $ID ref. 2858 2859* No error was found on $COMMENT.text: 2860 2861COMMENT 2862 : '/*' (options {greedy=false;} : . )* '*/' 2863 {System.out.println("found method "+$COMMENT.text);} 2864 ; 2865 2866 $enclosinglexerrule scope does not exist. Use text or setText() here. 2867 2868June 11, 2006 2869 2870* Single return values are initialized now to default or to your spec. 2871 2872* cleaned up input stream stuff. Added ANTLRReaderStream, ANTLRInputStream 2873 and refactored. You can specify encodings now on ANTLRFileStream (and 2874 ANTLRInputStream) now. 2875 2876* You can set text local var now in a lexer rule and token gets that text. 2877 start/stop indexes are still set for the token. 2878 2879* Changed lexer slightly. Calling a nonfragment rule from a 2880 nonfragment rule does not set the overall token. 2881 2882June 10, 2006 2883 2884* Fixed bug where unnecessary escapes yield char==0 like '\{'. 2885 2886* Fixed analysis bug. This grammar didn't report a recursion warning: 2887x : y X 2888 | y Y 2889 ; 2890y : L y R 2891 | B 2892 ; 2893 The DFAState.equals() method was messed up. 2894 2895* Added @synpredgate {...} action so you can tell ANTLR how to gate actions 2896 in/out during syntactic predicate evaluation. 2897 2898* Fuzzy parsing should be more efficient. It should backtrack over a rule 2899 and then rewind and do it again "with feeling" to exec actions. It was 2900 actually doing it 3x not 2x. 2901 2902June 9, 2006 2903 2904* Gutted and rebuilt the action translator for $x.y, $x::y, ... 2905 Uses ANTLR v3 now for the first time inside v3 source. :) 2906 ActionTranslator.java 2907 2908* Fixed a bug where referencing a return value on a rule didn't work 2909 because later a ref to that rule's predefined properties didn't 2910 properly force a return value struct to be built. Added unit test. 2911 2912June 6, 2006 2913 2914* New DFA mechanisms. Cyclic DFA are implemented as state tables, 2915 encoded via strings as java cannot handle large static arrays :( 2916 States with edges emanating that have predicates are specially 2917 treated. A method is generated to do these states. The DFA 2918 simulation routine uses the "special" array to figure out if the 2919 state is special. See March 25, 2006 entry for description: 2920 http://www.antlr.org/blog/antlr3/codegen.tml. analysis.DFA now has 2921 all the state tables generated for code gen. CyclicCodeGenerator.java 2922 disappeared as it's unneeded code. :) 2923 2924* Internal general clean up of the DFA.states vs uniqueStates thing. 2925 Fixed lookahead decisions no longer fill uniqueStates. Waste of 2926 time. Also noted that when adding sem pred edges, I didn't check 2927 for state reuse. Fixed. 2928 2929June 4, 2006 2930 2931* When resolving ambig DFA states predicates, I did not add the new states 2932 to the list of unique DFA states. No observable effect on output except 2933 that DFA state numbers were not always contiguous for predicated decisions. 2934 I needed this fix for new DFA tables. 2935 29363.0ea10 - June 2, 2006 2937 2938June 2, 2006 2939 2940* Improved grammar stats and added syntactic pred tracking. 2941 2942June 1, 2006 2943 2944* Due to a type mismatch, the DebugParser.recoverFromMismatchedToken() 2945 method was not called. Debug events for mismatched token error 2946 notification were not sent to ANTLRWorks probably 2947 2948* Added getBacktrackingLevel() for any recognizer; needed for profiler. 2949 2950* Only writes profiling data for antlr grammar analysis with -profile set 2951 2952* Major update and bug fix to (runtime) Profiler. 2953 2954May 27, 2006 2955 2956* Added Lexer.skip() to force lexer to ignore current token and look for 2957 another; no token is created for current rule and is not passed on to 2958 parser (or other consumer of the lexer). 2959 2960* Parsers are much faster now. I removed use of java.util.Stack for pushing 2961 follow sets and use a hardcoded array stack instead. Dropped from 2962 5900ms to 3900ms for parse+lex time parsing entire java 1.4.2 source. Lex 2963 time alone was about 1500ms. Just looking at parse time, we get about 2x 2964 speed improvement. :) 2965 2966May 26, 2006 2967 2968* Fixed NFA construction so it generates NFA for (A*)* such that ANTLRWorks 2969 can display it properly. 2970 2971May 25, 2006 2972 2973* added abort method to Grammar so AW can terminate the conversion if it's 2974 taking too long. 2975 2976May 24, 2006 2977 2978* added method to get left recursive rules from grammar without doing full 2979 grammar analysis. 2980 2981* analysis, code gen not attempted if serious error (like 2982 left-recursion or missing rule definition) occurred while reading 2983 the grammar in and defining symbols. 2984 2985* added amazing optimization; reduces analysis time by 90% for java 2986 grammar; simple IF statement addition! 2987 29883.0ea9 - May 20, 2006 2989 2990* added global k value for grammar to limit lookahead for all decisions unless 2991overridden in a particular decision. 2992 2993* added failsafe so that any decision taking longer than 2 seconds to create 2994the DFA will fall back on k=1. Use -ImaxtimeforDFA n (in ms) to set the time. 2995 2996* added an option (turned off for now) to use multiple threads to 2997perform grammar analysis. Not much help on a 2-CPU computer as 2998garbage collection seems to peg the 2nd CPU already. :( Gotta wait for 2999a 4 CPU box ;) 3000 3001* switched from #src to // $ANTLR src directive. 3002 3003* CommonTokenStream.getTokens() looked past end of buffer sometimes. fixed. 3004 3005* unicode literals didn't really work in DOT output and generated code. fixed. 3006 3007* fixed the unit test rig so it compiles nicely with Java 1.5 3008 3009* Added ant build.xml file (reads build.properties file) 3010 3011* predicates sometimes failed to compile/eval properly due to missing (...) 3012 in IF expressions. Forced (..) 3013 3014* (...)? with only one alt were not optimized. Was: 3015 3016 // t.g:4:7: ( B )? 3017 int alt1=2; 3018 int LA1_0 = input.LA(1); 3019 if ( LA1_0==B ) { 3020 alt1=1; 3021 } 3022 else if ( LA1_0==-1 ) { 3023 alt1=2; 3024 } 3025 else { 3026 NoViableAltException nvae = 3027 new NoViableAltException("4:7: ( B )?", 1, 0, input); 3028 throw nvae; 3029 } 3030 3031is now: 3032 3033 // t.g:4:7: ( B )? 3034 int alt1=2; 3035 int LA1_0 = input.LA(1); 3036 if ( LA1_0==B ) { 3037 alt1=1; 3038 } 3039 3040 Smaller, faster and more readable. 3041 3042* Allow manual init of return values now: 3043 functionHeader returns [int x=3*4, char (*f)()=null] : ... ; 3044 3045* Added optimization for DFAs that fixed a codegen bug with rules in lexer: 3046 EQ : '=' ; 3047 ASSIGNOP : '=' | '+=' ; 3048 EQ is a subset of other rule. It did not given an error which is 3049 correct, but generated bad code. 3050 3051* ANTLR was sending column not char position to ANTLRWorks. 3052 3053* Bug fix: location 0, 0 emitted for synpreds and empty alts. 3054 3055* debugging event handshake how sends grammar file name. Added getGrammarFileName() to recognizers. Java.stg generates it: 3056 3057 public String getGrammarFileName() { return "<fileName>"; } 3058 3059* tree parsers can do arbitrary lookahead now including backtracking. I 3060 updated CommonTreeNodeStream. 3061 3062* added events for debugging tree parsers: 3063 3064 /** Input for a tree parser is an AST, but we know nothing for sure 3065 * about a node except its type and text (obtained from the adaptor). 3066 * This is the analog of the consumeToken method. Again, the ID is 3067 * the hashCode usually of the node so it only works if hashCode is 3068 * not implemented. 3069 */ 3070 public void consumeNode(int ID, String text, int type); 3071 3072 /** The tree parser looked ahead */ 3073 public void LT(int i, int ID, String text, int type); 3074 3075 /** The tree parser has popped back up from the child list to the 3076 * root node. 3077 */ 3078 public void goUp(); 3079 3080 /** The tree parser has descended to the first child of a the current 3081 * root node. 3082 */ 3083 public void goDown(); 3084 3085* Added DebugTreeNodeStream and DebugTreeParser classes 3086 3087* Added ctor because the debug tree node stream will need to ask quesitons about nodes and since nodes are just Object, it needs an adaptor to decode the nodes and get text/type info for the debugger. 3088 3089public CommonTreeNodeStream(TreeAdaptor adaptor, Tree tree); 3090 3091* added getter to TreeNodeStream: 3092 public TreeAdaptor getTreeAdaptor(); 3093 3094* Implemented getText/getType in CommonTreeAdaptor. 3095 3096* Added TraceDebugEventListener that can dump all events to stdout. 3097 3098* I broke down and make Tree implement getText 3099 3100* tree rewrites now gen location debug events. 3101 3102* added AST debug events to listener; added blank listener for convenience 3103 3104* updated debug events to send begin/end backtrack events for debugging 3105 3106* with a : (b->b) ('+' b -> ^(PLUS $a b))* ; you get b[0] each time as 3107 there is no loop in rewrite rule itself. Need to know context that 3108 the -> is inside the rule and hence b means last value of b not all 3109 values. 3110 3111* Bug in TokenRewriteStream; ops at indexes < start index blocked proper op. 3112 3113* Actions in ST rewrites "-> ({$op})()" were not translated 3114 3115* Added new action name: 3116 3117@rulecatch { 3118catch (RecognitionException re) { 3119 reportError(re); 3120 recover(input,re); 3121} 3122catch (Throwable t) { 3123 System.err.println(t); 3124} 3125} 3126Overrides rule catch stuff. 3127 3128* Isolated $ refs caused exception 3129 31303.0ea8 - March 11, 2006 3131 3132* added @finally {...} action like @init for rules. Executes in 3133 finally block (java target) after all other stuff like rule memoization. 3134 No code changes needs; ST just refs a new action: 3135 <ruleDescriptor.actions.finally> 3136 3137* hideous bug fixed: PLUS='+' didn't result in '+' rule in lexer 3138 3139* TokenRewriteStream didn't do toString() right when no rewrites had been done. 3140 3141* lexer errors in interpreter were not printed properly 3142 3143* bitsets are dumped in hex not decimal now for FOLLOW sets 3144 3145* /* epsilon */ is not printed now when printing out grammars with empty alts 3146 3147* Fixed another bug in tree rewrite stuff where it was checking that elements 3148 had at least one element. Strange...commented out for now to see if I can remember what's up. 3149 3150* Tree rewrites had problems when you didn't have x+=FOO variables. Rules 3151 like this work now: 3152 3153 a : (x=ID)? y=ID -> ($x $y)?; 3154 3155* filter=true for lexers turns on k=1 and backtracking for every token 3156 alternative. Put the rules in priority order. 3157 3158* added getLine() etc... to Tree to support better error reporting for 3159 trees. Added MismatchedTreeNodeException. 3160 3161* $templates::foo() is gone. added % as special template symbol. 3162 %foo(a={},b={},...) ctor (even shorter than $templates::foo(...)) 3163 %({name-expr})(a={},...) indirect template ctor reference 3164 3165 The above are parsed by antlr.g and translated by codegen.g 3166 The following are parsed manually here: 3167 3168 %{string-expr} anonymous template from string expr 3169 %{expr}.y = z; template attribute y of StringTemplate-typed expr to z 3170 %x.y = z; set template attribute y of x (always set never get attr) 3171 to z [languages like python without ';' must still use the 3172 ';' which the code generator is free to remove during code gen] 3173 3174* -> ({expr})(a={},...) notation for indirect template rewrite. 3175 expr is the name of the template. 3176 3177* $x[i]::y and $x[-i]::y notation for accesssing absolute scope stack 3178 indexes and relative negative scopes. $x[-1]::y is the y attribute 3179 of the previous scope (stack top - 1). 3180 3181* filter=true mode for lexers; can do this now...upon mismatch, just 3182 consumes a char and tries again: 3183lexer grammar FuzzyJava; 3184options {filter=true;} 3185 3186FIELD 3187 : TYPE WS? name=ID WS? (';'|'=') 3188 {System.out.println("found var "+$name.text);} 3189 ; 3190 3191* refactored char streams so ANTLRFileStream is now a subclass of 3192 ANTLRStringStream. 3193 3194* char streams for lexer now allowed nested backtracking in lexer. 3195 3196* added TokenLabelType for lexer/parser for all token labels 3197 3198* line numbers for error messages were not updated properly in antlr.g 3199 for strings, char literals and <<...>> 3200 3201* init action in lexer rules was before the type,start,line,... decls. 3202 3203* Tree grammars can now specify output; I've only tested output=templat 3204 though. 3205 3206* You can reference EOF now in the parser and lexer. It's just token type 3207 or char value -1. 3208 3209* Bug fix: $ID refs in the *lexer* were all messed up. Cleaned up the 3210 set of properties available... 3211 3212* Bug fix: .st not found in rule ref when rule has scope: 3213field 3214scope { 3215 StringTemplate funcDef; 3216} 3217 : ... 3218 {$field::funcDef = $field.st;} 3219 ; 3220it gets field_stack.st instead 3221 3222* return in backtracking must return retval or null if return value. 3223 3224* $property within a rule now works like $text, $st, ... 3225 3226* AST/Template Rewrites were not gated by backtracking==0 so they 3227 executed even when guessing. Auto AST construction is now gated also. 3228 3229* CommonTokenStream was somehow returning tokens not text in toString() 3230 3231* added useful methods to runtime.BitSet and also to CommonToken so you can 3232 update the text. Added nice Token stream method: 3233 3234 /** Given a start and stop index, return a List of all tokens in 3235 * the token type BitSet. Return null if no tokens were found. This 3236 * method looks at both on and off channel tokens. 3237 */ 3238 public List getTokens(int start, int stop, BitSet types); 3239 3240* literals are now passed in the .tokens files so you can ref them in 3241 tree parses, for example. 3242 3243* added basic exception handling; no labels, just general catches: 3244 3245a : {;}A | B ; 3246 exception 3247 catch[RecognitionException re] { 3248 System.out.println("recog error"); 3249 } 3250 catch[Exception e] { 3251 System.out.println("error"); 3252 } 3253 3254* Added method to TokenStream: 3255 public String toString(Token start, Token stop); 3256 3257* antlr generates #src lines in lexer grammars generated from combined grammars 3258 so error messages refer to original file. 3259 3260* lexers generated from combined grammars now use originally formatting. 3261 3262* predicates have $x.y stuff translated now. Warning: predicates might be 3263 hoisted out of context. 3264 3265* return values in return val structs are now public. 3266 3267* output=template with return values on rules was broken. I assume return values with ASTs was broken too. Fixed. 3268 32693.0ea7 - December 14, 2005 3270 3271* Added -print option to print out grammar w/o actions 3272 3273* Renamed BaseParser to be BaseRecognizer and even made Lexer derive from 3274 this; nice as it now shares backtracking support code. 3275 3276* Added syntactic predicates (...)=>. See December 4, 2005 entry: 3277 3278 http://www.antlr.org/blog/antlr3/lookahead.tml 3279 3280 Note that we have a new option for turning off rule memoization during 3281 backtracking: 3282 3283 -nomemo when backtracking don't generate memoization code 3284 3285* Predicates are now tested in order that you specify the alts. If you 3286 leave the last alt "naked" (w/o pred), it will assume a true pred rather 3287 than union of other preds. 3288 3289* Added gated predicates "{p}?=>" that literally turn off a production whereas 3290disambiguating predicates are only hoisted into the predictor when syntax alone 3291is not sufficient to uniquely predict alternatives. 3292 3293A : {p}? => "a" ; 3294B : {!p}? => ("a"|"b")+ ; 3295 3296* bug fixed related to predicates in predictor 3297lexer grammar w; 3298A : {p}? "a" ; 3299B : {!p}? ("a"|"b")+ ; 3300DFA is correct. A state splits for input "a" on the pred. 3301Generated code though was hosed. No pred tests in prediction code! 3302I added testLexerPreds() and others in TestSemanticPredicateEvaluation.java 3303 3304* added execAction template in case we want to do something in front of 3305 each action execution or something. 3306 3307* left-recursive cycles from rules w/o decisions were not detected. 3308 3309* undefined lexer rules were not announced! fixed. 3310 3311* unreachable messages for Tokens rule now indicate rule name not alt. E.g., 3312 3313 Ruby.lexer.g:24:1: The following token definitions are unreachable: IVAR 3314 3315* nondeterminism warnings improved for Tokens rule: 3316 3317Ruby.lexer.g:10:1: Multiple token rules can match input such as ""0".."9"": INT, FLOAT 3318As a result, tokens(s) FLOAT were disabled for that input 3319 3320 3321* DOT diagrams didn't show escaped char properly. 3322 3323* Char/string literals are now all 'abc' not "abc". 3324 3325* action syntax changed "@scope::actionname {action}" where scope defaults 3326 to "parser" if parser grammar or combined grammar, "lexer" if lexer grammar, 3327 and "treeparser" if tree grammar. The code generation targets decide 3328 what scopes are available. Each "scope" yields a hashtable for use in 3329 the output templates. The scopes full of actions are sent to all output 3330 file templates (currently headerFile and outputFile) as attribute actions. 3331 Then you can reference <actions.scope> to get the map of actions associated 3332 with scope and <actions.parser.header> to get the parser's header action 3333 for example. This should be very flexible. The target should only have 3334 to define which scopes are valid, but the action names should be variable 3335 so we don't have to recompile ANTLR to add actions to code gen templates. 3336 3337 grammar T; 3338 options {language=Java;} 3339 @header { package foo; } 3340 @parser::stuff { int i; } // names within scope not checked; target dependent 3341 @members { int i; } 3342 @lexer::header {head} 3343 @lexer::members { int j; } 3344 @headerfile::blort {...} // error: this target doesn't have headerfile 3345 @treeparser::members {...} // error: this is not a tree parser 3346 a 3347 @init {int i;} 3348 : ID 3349 ; 3350 ID : 'a'..'z'; 3351 3352 For now, the Java target uses members and header as a valid name. Within a 3353 rule, the init action name is valid. 3354 3355* changed $dynamicscope.value to $dynamicscope::value even if value is defined 3356 in same rule such as $function::name where rule function defines name. 3357 3358* $dynamicscope gets you the stack 3359 3360* rule scopes go like this now: 3361 3362 rule 3363 scope {...} 3364 scope slist,Symbols; 3365 : ... 3366 ; 3367 3368* Created RuleReturnScope as a generic rule return value. Makes it easier 3369 to do this: 3370 RuleReturnScope r = parser.program(); 3371 System.out.println(r.getTemplate().toString()); 3372 3373* $template, $tree, $start, etc... 3374 3375* $r.x in current rule. $r is ignored as fully-qualified name. $r.start works too 3376 3377* added warning about $r referring to both return value of rule and dynamic scope of rule 3378 3379* integrated StringTemplate in a very simple manner 3380 3381Syntax: 3382-> template(arglist) "..." 3383-> template(arglist) <<...>> 3384-> namedTemplate(arglist) 3385-> {free expression} 3386-> // empty 3387 3388Predicate syntax: 3389a : A B -> {p1}? foo(a={$A.text}) 3390 -> {p2}? foo(a={$B.text}) 3391 -> // return nothing 3392 3393An arg list is just a list of template attribute assignments to actions in curlies. 3394 3395There is a setTemplateLib() method for you to use with named template rewrites. 3396 3397Use a new option: 3398 3399grammar t; 3400options {output=template;} 3401... 3402 3403This all should work for tree grammars too, but I'm still testing. 3404 3405* fixed bugs where strings were improperly escaped in exceptions, comments, etc.. For example, newlines came out as newlines not the escaped version 3406 34073.0ea6 - November 13, 2005 3408 3409* turned off -debug/-profile, which was on by default 3410 3411* completely refactored the output templates; added some missing templates. 3412 3413* dramatically improved infinite recursion error messages (actually 3414 left-recursion never even was printed out before). 3415 3416* wasn't printing dangling state messages when it reanalyzes with k=1. 3417 3418* fixed a nasty bug in the analysis engine dealing with infinite recursion. 3419 Spent all day thinking about it and cleaned up the code dramatically. 3420 Bug fixed and software is more powerful and I understand it better! :) 3421 3422* improved verbose DFA nodes; organized by alt 3423 3424* got much better random phrase generation. For example: 3425 3426 $ java org.antlr.tool.RandomPhrase simple.g program 3427 int Ktcdn ';' method wh '(' ')' '{' return 5 ';' '}' 3428 3429* empty rules like "a : ;" generated code that didn't compile due to 3430 try/catch for RecognitionException. Generated code couldn't possibly 3431 throw that exception. 3432 3433* when printing out a grammar, such as in comments in generated code, 3434 ANTLR didn't print ast suffix stuff back out for literals. 3435 3436* This never exited loop: 3437 DATA : (options {greedy=false;}: .* '\n' )* '\n' '.' ; 3438 and now it works due to new default nongreedy .* Also this works: 3439 DATA : (options {greedy=false;}: .* '\n' )* '.' ; 3440 3441* Dot star ".*" syntax didn't work; in lexer it is nongreedy by 3442 default. In parser it is on greedy but also k=1 by default. Added 3443 unit tests. Added blog entry to describe. 3444 3445* ~T where T is the only token yielded an empty set but no error 3446 3447* Used to generate unreachable message here: 3448 3449 parser grammar t; 3450 a : ID a 3451 | ID 3452 ; 3453 3454 z.g:3:11: The following alternatives are unreachable: 2 3455 3456 In fact it should really be an error; now it generates: 3457 3458 no start rule in grammar t (no rule can obviously be followed by EOF) 3459 3460 Per next change item, ANTLR cannot know that EOF follows rule 'a'. 3461 3462* added error message indicating that ANTLR can't figure out what your 3463 start rule is. Required to properly generate code in some cases. 3464 3465* validating semantic predicates now work (if they are false, they 3466 throw a new FailedPredicateException 3467 3468* two hideous bug fixes in the IntervalSet, which made analysis go wrong 3469 in a few cases. Thanks to Oliver Zeigermann for finding lots of bugs 3470 and making suggested fixes (including the next two items)! 3471 3472* cyclic DFAs are now nonstatic and hence can access instance variables 3473 3474* labels are now allowed on lexical elements (in the lexer) 3475 3476* added some internal debugging options 3477 3478* ~'a'* and ~('a')* were not working properly; refactored antlr.g grammar 3479 34803.0ea5 - July 5, 2005 3481 3482* Using '\n' in a parser grammar resulted in a nonescaped version of '\n' in the token names table making compilation fail. I fixed this by reorganizing/cleaning up portion of ANTLR that deals with literals. See comment org.antlr.codegen.Target. 3483 3484* Target.getMaxCharValue() did not use the appropriate max value constant. 3485 3486* ALLCHAR was a constant when it should use the Target max value def. set complement for wildcard also didn't use the Target def. Generally cleaned up the max char value stuff. 3487 3488* Code gen didn't deal with ASTLabelType properly...I think even the 3.0ea7 example tree parser was broken! :( 3489 3490* Added a few more unit tests dealing with escaped literals 3491 34923.0ea4 - June 29, 2005 3493 3494* tree parsers work; added CommonTreeNodeStream. See simplecTreeParser 3495 example in examples-v3 tarball. 3496 3497* added superClass and ASTLabelType options 3498 3499* refactored Parser to have a BaseParser and added TreeParser 3500 3501* bug fix: actions being dumped in description strings; compile errors 3502 resulted 3503 35043.0ea3 - June 23, 2005 3505 3506Enhancements 3507 3508* Automatic tree construction operators are in: ! ^ ^^ 3509 3510* Tree construction rewrite rules are in 3511 -> {pred1}? rewrite1 3512 -> {pred2}? rewrite2 3513 ... 3514 -> rewriteN 3515 3516 The rewrite rules may be elements like ID, expr, $label, {node expr} 3517 and trees ^( <root> <children> ). You have have (...)?, (...)*, (...)+ 3518 subrules as well. 3519 3520 You may have rewrites in subrules not just at outer level of rule, but 3521 any -> rewrite forces auto AST construction off for that alternative 3522 of that rule. 3523 3524 To avoid cycles, copy semantics are used: 3525 3526 r : INT -> INT INT ; 3527 3528 means make two new nodes from the same INT token. 3529 3530 Repeated references to a rule element implies a copy for at least one 3531 tree: 3532 3533 a : atom -> ^(atom atom) ; // NOT CYCLE! (dup atom tree) 3534 3535* $ruleLabel.tree refers to tree created by matching the labeled element. 3536 3537* A description of the blocks/alts is generated as a comment in output code 3538 3539* A timestamp / signature is put at top of each generated code file 3540 35413.0ea2 - June 12, 2005 3542 3543Bug fixes 3544 3545* Some error messages were missing the stackTrace parameter 3546 3547* Removed the file locking mechanism as it's not cross platform 3548 3549* Some absolute vs relative path name problems with writing output 3550 files. Rules are now more concrete. -o option takes precedence 3551 // -o /tmp /var/lib/t.g => /tmp/T.java 3552 // -o subdir/output /usr/lib/t.g => subdir/output/T.java 3553 // -o . /usr/lib/t.g => ./T.java 3554 // -o /tmp subdir/t.g => /tmp/subdir/t.g 3555 // If they didn't specify a -o dir so just write to location 3556 // where grammar is, absolute or relative 3557 3558* does error checking on unknown option names now 3559 3560* Using just language code not locale name for error message file. I.e., 3561 the default (and for any English speaking locale) is en.stg not en_US.stg 3562 anymore. 3563 3564* The error manager now asks the Tool to panic rather than simply doing 3565 a System.exit(). 3566 3567* Lots of refactoring concerning grammar, rule, subrule options. Now 3568 detects invalid options. 3569 35703.0ea1 - June 1, 2005 3571 3572Initial early access release 3573