Commit Graph

838 Commits

Author SHA1 Message Date
Terence Parr 3849cd572d rm SymbolStream<T>, change all to TokenStream. all but 5 tests pass. 2012-04-02 16:49:04 -07:00
Sam Harwell 78fcc134cd Fix error codes in unit tests 2012-04-02 18:22:05 -05:00
Sam Harwell 5fd8b223b6 Fix ErrorManager ignoring error code in messages 2012-04-02 18:13:47 -05:00
Terence Parr 186293ae86 tweak 2012-04-02 10:13:13 -07:00
Terence Parr 9ef6127982 merging from master 2012-04-01 18:13:40 -07:00
Sam Harwell adad53ee18 Fix unit tests that called TokenStream.toString (now TokenStream.getText) 2012-04-01 18:33:49 -05:00
Terence Parr e1870d16e9 added convenience getText(ctx) method to TokenStream. unlikley to need in CharStream and can get another way 2012-04-01 12:23:45 -07:00
Terence Parr 588e30bfe1 getText(...) moved to CharStream and TokenStream; cleaned up names. removed getInputString from parser. 2012-04-01 12:12:49 -07:00
Terence Parr c9aef6fdbe Merge branch 'master' into stack-graphs-integration 2012-03-31 10:33:22 -07:00
Terence Parr 9fbe9b6e21 op=(x|y) works as left-recur binary op now. 2012-03-30 13:00:31 -07:00
Sam Harwell f166df7b94 Updated unit tests to use .g4 as the preferred grammar extension 2012-03-30 11:44:34 -05:00
Sam Harwell e5d7c27b09 Updated comments to indicate preference of .g4 over .g 2012-03-30 11:37:22 -05:00
Sam Harwell cfcb2a1a55 Add Tool.GRAMMAR_EXTENSION (.g4) and Tool.LEGACY_GRAMMAR_EXTENSION (.g), allow imported grammars to use either extension (favoring .g4 over .g). 2012-03-30 11:36:20 -05:00
Terence Parr 11cd720cc6 added failing test so i go back and fix issue with op=('+'|'-') in LR rules 2012-03-29 21:37:56 -07:00
Terence Parr 42706485e9 was looking for imports with .g not .g4 2012-03-29 14:59:43 -07:00
Terence Parr 48b2e237d1 Merge branch 'no-rules-npe' of https://github.com/sharwell/antlr4 2012-03-27 21:23:47 -07:00
Sam Harwell cc7e9c1b0c Don't strip error numbers from lines because the numbers are constants of the public API 2012-03-27 21:52:34 -05:00
Sam Harwell 8d16912fb9 Fix expected output for testAmbigLR 2012-03-27 21:51:55 -05:00
Sam Harwell 2ff9c12848 Fix expected error/warning numbers 2012-03-27 21:51:31 -05:00
Sam Harwell 95b6cd58c4 Fix NPE when a grammar contains no rules (instead of appropriate error message) 2012-03-27 21:25:23 -05:00
Sam Harwell eb48cdf55b Fix test affected by 9c1e58db7c (add {} in primary alt block of LR rule) 2012-03-27 21:22:04 -05:00
Sam Harwell 4b0040f2a1 Fix test affected by bdda174af6 (set stop token even if exception occurs) 2012-03-27 21:20:29 -05:00
Terence Parr a363e70582 pull from master 2012-03-27 16:22:01 -07:00
Terence Parr 9c1e58db7c add {} in primary alt block to prevent ID|INT from becoming SET, which breaks code gen needs. 2012-03-27 16:21:01 -07:00
Terence Parr bd51907c5e Merge branch 'abstract-parser' of github.com:sharwell/antlr4 2012-03-27 15:18:06 -07:00
Terence Parr bf07f7907f Merge branch 'override-ruleindex' of github.com:sharwell/antlr4 2012-03-27 15:09:50 -07:00
Terence Parr 41e97791bb Merge branch 'set-stop-token' of github.com:sharwell/antlr4 2012-03-27 15:08:57 -07:00
Terence Parr 580ec1f7d7 Merge branch 'fix-tests' of github.com:sharwell/antlr4 2012-03-27 15:07:05 -07:00
Terence Parr f307945d2a Merge branch 'lexer-npe' of github.com:sharwell/antlr4 2012-03-27 15:06:17 -07:00
Terence Parr 8465920343 Merge branch 'atnstate-reachability-test' of github.com:sharwell/antlr4 2012-03-27 15:05:39 -07:00
Sam Harwell 9b42e7dfe6 Implement support for abstract grammars via the "abstract" grammar option and "-abstract" command line option. Resolves antlr/antlr4#36. 2012-03-26 18:00:16 -05:00
Sam Harwell df2e24a228 Override getRuleIndex() in generated context objects so ParserRuleContext.ruleIndex field can be removed 2012-03-25 21:50:55 -05:00
Sam Harwell fdb92ccf6d Fix tests affected by 9a0aaacbee and 2232ea5101 2012-03-25 21:50:31 -05:00
Sam Harwell be4caa3d11 Fix tests affected by c6365fb5e2 2012-03-25 21:50:30 -05:00
Sam Harwell bdda174af6 Set stop token even when RecognitionException occurs. Add ParserRuleContext.exception field to hold exception if one occurs. Resolves antlr/antlr4#49. 2012-03-25 21:50:12 -05:00
Terence Parr 2b5896e83b Merge branch 'master' into stack-graphs-integration 2012-03-25 10:08:29 -07:00
Terence Parr 6791bf60cf Merge commit '3f1f76d' into parrt-default-error-listener
Conflicts:
	runtime/Java/src/org/antlr/v4/runtime/ANTLRErrorStrategy.java
	runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java
	runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java
	runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java
2012-03-24 16:44:47 -07:00
Terence Parr b035ceec9e EMPTY gives "" not "$" now. rename closure->closure_. had return in wrong spot in closure for-loop. fix fromRuleContext. 2012-03-20 19:06:52 -07:00
Terence Parr 0f969af947 added in Sam's popAll to deal with loop end push/pop stuff. passes LR tests and all but 2 sempred tests. does some JavaLR.g4 parsing too. 2012-03-20 18:06:00 -07:00
Terence Parr 9318391664 tweak to fromRuleContext. more sempred tests work. 2012-03-20 12:32:28 -07:00
Terence Parr 55ed1a45bf lexer wasn't using new prediction context. weird. put in functionality for $ merge in full ctx mode. removed configs array in ATNConfigSet. ATNConfigSet wasn't tracking lexerActionIndex from config. ATNConfigSet now maps key to ATNConfig. 2012-03-20 12:12:18 -07:00
Terence Parr 5945b29a86 got more working 2012-03-19 19:58:04 -07:00
Terence Parr 7e9a86a3e1 got TestATNInterpreter working 2012-03-19 18:47:41 -07:00
Terence Parr 85b40c7d2e shelve 2012-03-19 17:47:57 -07:00
Sam Harwell 4bc615d72f Ensure that serialized transitions only point to states which weren't removed. Add unit test for a current failure case (will be a regression test once fixed). 2012-03-19 08:32:34 -05:00
Sam Harwell a70cb6f36a Fix NPE in LexerATNSimulator.execDFA error recovery 2012-03-19 08:17:59 -05:00
Terence Parr 7233177441 got integrated graph stacks to compile. commit so i can look at sam's 2012-03-18 15:20:52 -07:00
Terence Parr 3a79aa15ba move new classes into proper package locations 2012-03-18 13:45:13 -07:00
Sam Harwell ea434982fb Pull error reporting outside of try/finally to ensure errors are not hidden 2012-03-17 17:38:05 -05:00
Terence Parr 9a0aaacbee rm k=1 chk to report early ambiguity. 2012-03-16 14:11:21 -07:00
Terence Parr 102980dffd make T.g same 2012-03-14 13:20:24 -07:00
Terence Parr 28ee391c81 Merge remote-tracking branch 'sharwell/loops-recursion-test' 2012-03-14 13:09:19 -07:00
Sam Harwell 0ec7f1528c Clean up testLoopsSimulateTailRecursion, move to TestFullContextParsing. 2012-03-14 15:04:01 -05:00
Sam Harwell ee0bc39b53 Add unit test for loopsSimulateTailRecursion 2012-03-14 14:08:22 -05:00
Terence Parr 6887c86d5e shelve 2012-03-14 12:04:18 -07:00
Terence Parr 2fc9760ba7 Merge remote-tracking branch 'sharwell/ambig-sempred' 2012-03-12 13:50:45 -07:00
Sam Harwell 3f1f76df7d Move reportAmbiguity, reportContextSensitivity, reportAttemptingFullContext, reportInsufficientPredicates from ANTLRErrorStrategy to ANTLRErrorListener.
Add BaseErrorListener to allow implementing ANTLRErrorListener without implementing every method (e.g. ConsoleErrorListener).
DiagnosticErrorStrategy is now DiagnosticErrorListener, updated tests.
2012-03-12 15:07:48 -05:00
Sam Harwell bbff5bd20a New tests related to if/if/else constructs 2012-03-12 07:26:39 -05:00
Sam Harwell 2cc39c2f9b Evaluate predicates for all ambiguous alternatives and report if still ambiguous after predicate evaluation. Remove misleading message insufficient predicates. Fixes antlr/antlr4#31. Partially addresses antlr/antlr4#39. 2012-03-10 16:16:39 -06:00
Sam Harwell 7525bb6e1d Semantic predicates now evaluate with standard min-alt selection 2012-03-08 13:53:45 -06:00
Terence Parr a9e74ce399 Merge branch 'failed-predicate-message' of git://github.com/sharwell/antlr4 2012-03-06 13:28:47 -08:00
Terence Parr ce142a2a4c Merge commit '51c38c1' 2012-03-06 13:27:46 -08:00
Sam Harwell 5280bc3280 Tweak doc comment 2012-03-06 07:34:20 -06:00
Sam Harwell c3cd99858c Reduce size of generated code by emitting predicate text instead of full failed predicate message 2012-02-29 08:14:42 -06:00
Sam Harwell 51c38c1103 Use single int _alt in generated code instead of a new _alt<choice.uniqueID> for each PlusBlock and StarBlock 2012-02-29 07:56:29 -06:00
Terence Parr dd69a7532d getToken/s returns TerminalNode now per Sam's suggestion. altered tests. seems correct. 2012-02-27 21:39:30 -08:00
Terence Parr ae08867ff3 alter visitTerminal interface, add visitErrorNode. 2012-02-26 22:07:45 -08:00
Terence Parr 67b2e6d7c1 forgot to move Pair etc... 2012-02-26 21:55:23 -08:00
Terence Parr 41be88dcd5 mv to runtime 2012-02-26 15:49:45 -08:00
Terence Parr b7da3361de fix bug. e : e '(' exprList ')' ... ; came back with e as a list not single element. 2012-02-26 15:33:05 -08:00
Terence Parr db1b86af91 alter visitTerminal interface, add visitErrorNode. 2012-02-25 17:03:41 -08:00
Terence Parr 600c4bbd91 crap. sun already made IdentityHashMap; rm'ing my version 2012-02-25 16:07:34 -08:00
Terence Parr 73ae2b0bfc Added ParseTreeProperty and added generically useful Map that ignores key.hashCode and equals() and simply uses key identity instead. In particular, this is useful for ANTLR because parse trees are actually interfaces laid on top of the rule context objects used by ANTLR's grammar analysis. These context objects use special equals methods and so on. Plus, when we want to annotate trees with values, we want a specific note to have a value. Identity is what we intend. 2012-02-25 13:43:32 -08:00
Sam Harwell 90bcfec456 Simplify CodeGenerator 2012-02-24 15:58:21 -06:00
Sam Harwell 019ea15e3f Catch specific RecognitionException instead of Exception 2012-02-23 16:45:35 -06:00
Sam Harwell 2c8ef6470f Despite being absurdly verbose in Java, use callable objects instead of reflection in CodeGenerator because the latter is prone to runtime errors and debugging headaches 2012-02-23 16:44:54 -06:00
Sam Harwell 9bf6f284df Code cleanup (little things like using .isEmpty() and StringBuilder, and specify some small-scale generic arguments) 2012-02-23 16:42:36 -06:00
Sam Harwell 1c8efd6a48 Allow contravariant error listeners 2012-02-23 16:13:13 -06:00
Sam Harwell 4ae58868d7 Compile listeners and visitors with the unit tests by default to help catch compile errors with them 2012-02-23 16:13:10 -06:00
Sam Harwell db4ce6dd8e Unexpected v3 RecognitionException should cause testActions to fail 2012-02-23 16:13:09 -06:00
Sam Harwell 5ab1c3319c Make sure failed compiles result in failed unit tests 2012-02-23 16:13:08 -06:00
Sam Harwell 44df49f24f Remove tree parser methods from BaseTest 2012-02-23 16:13:07 -06:00
Sam Harwell 1492648d26 Add missing @Override annotations 2012-02-23 16:13:06 -06:00
Terence Parr b459dafeb9 empty alternatives didn't trigger listener events. overrode getParent in ParserRuleContext to make type more specific. 2012-02-23 12:16:14 -08:00
Terence Parr 5a13ddc517 fix regression; LR rules weren't working 2012-02-23 11:37:50 -08:00
Terence Parr d30b36ca01 tweak to compile with 3.4 2012-02-23 10:05:43 -08:00
Sam Harwell 4aee8aa4dc Merge remote-tracking branch 'parrt/master' 2012-02-22 15:46:22 -06:00
Sam Harwell 7c0d5cd726 Fix use of v3 runtime generics 2012-02-22 15:44:17 -06:00
Terence Parr 8a34176d82 added listener unit tests. fixed bug that didn't create ctx getters properly for recursive rules. added Symbol extends Token to parse tree stuff. added visitTerminal to Visitor. recursive alts now track their original, unedited AltAST subtree so we can properly count rule refs etc... later. dup of RuleRefAST was making wrong node. don't gen dispatch methods if no listener. 2012-02-22 12:44:33 -08:00
Sam Harwell 05930b04ce Use Class.asSubclass instead of unchecked cast 2012-02-21 07:50:02 -06:00
Sam Harwell 1970ac240e Generalize several functions in TestPerformance 2012-02-20 20:59:06 -06:00
Sam Harwell 611728a380 Update testPerformance to show information about DFA states in the lexer 2012-02-20 18:51:26 -06:00
Sam Harwell f5edb7653a Add missing @Override attributes in generated code, use hard tabs instead of spaces 2012-02-20 17:23:38 -06:00
Sam Harwell ca0b1d399c Move "metadata" methods to top of generated parser 2012-02-20 17:21:44 -06:00
Sam Harwell a81b1a17eb Extract abstract method in Recognizer for Parser.getGrammarFileName() and generated lexer's getGrammarFileName(). Make Recognizer.getTokenNames(), getRuleNames(), and getATN() abstract - implementations are always generated. 2012-02-20 17:18:57 -06:00
Sam Harwell d166e6d5d1 Emit grammar file name instead of generated class file name in generated implementation of getGrammarFileName(). Implement getGrammarFileName() in generated parser. 2012-02-20 17:14:19 -06:00
Sam Harwell 8773c34375 Fix unit tests 2012-02-20 15:58:21 -06:00
Terence Parr 97660e21ae add alt labels to all alts 2012-02-20 12:26:32 -08:00
Terence Parr e9122cafa3 Merge commit '46d5458' 2012-02-20 12:22:37 -08:00
Terence Parr 1a2094b2dd merging Sam\'s fix to full ctx pred etc...; effectively did pull parrt/antlr4#15, includes fixes antlr/antlr4#14, includes fixes antlr/antlr4#15 2012-02-20 11:48:03 -08:00
Terence Parr 7287f5a2d3 prefix left-recursive alts weren't recognized with actions on end. 2012-02-20 10:51:34 -08:00
Terence Parr 642177f716 forgot to add dispatch methods in context objects. in-parse listeners should work now. 2012-02-19 11:25:15 -08:00
Terence Parr 4e8931519c added -parse-listener option and generated code if option on. parse listener differs from tree listener 2012-02-18 16:49:05 -08:00
Terence Parr 71b75c88dd Fix regression; did not gen enter/exit in alt label structs. 2012-02-18 15:16:42 -08:00
Terence Parr c6fd897287 altered naming scheme for listeners/visitors
* names changed. visit() -> visitX(). enter/exit() -> enter/exitX()
* capitalizing automatically now. rule s -> SContext not sContext
* no enter/exit method in generic rule context object if rule has alt labels, nor in interfaces.
* dup labels allowed in same rule
* label X or x illegal if rule x exists
2012-02-18 12:40:47 -08:00
Terence Parr 725b105135 Added visitor gen mechanism, runtime support 2012-02-16 17:49:57 -08:00
Sam Harwell 82aac56c98 Fix rule list labels 2012-02-16 17:35:01 -06:00
Sam Harwell 0520400493 TestPerformance: print additional information about states/configs 2012-02-16 15:41:43 -06:00
Sam Harwell feeaffc710 Fix listener name BlankJavaListener->JavaBaseListener 2012-02-15 19:06:27 -06:00
Sam Harwell 27806dc490 Merge remote-tracking branch 'parrt/master' 2012-02-15 14:58:16 -06:00
Sam Harwell 79f0de4cde Fix unit test checking for incorrect input index in warning message 2012-02-15 13:51:28 -06:00
Sam Harwell 685cf7b7d5 Further improvements to auto-label generic usage, return Collections.emptyList() instead of null when no children are found 2012-02-15 12:31:43 -06:00
Sam Harwell bc87562aff Remove unused exception LexerRecognitionExeption [sic] 2012-02-15 11:01:01 -06:00
Sam Harwell 2d2134eb6b Update BaseTest to compile XBaseListener instead of BlankXListener 2012-02-15 10:48:49 -06:00
Sam Harwell 40af402822 Allow enabling TEST_IN_SAME_PROCESS via jvm argument 2012-02-15 10:47:50 -06:00
Sam Harwell 707311996d Updated TestPerformance (features, grammar fixes) 2012-02-15 10:28:59 -06:00
Sam Harwell 19afb4a8bc Specify surefire plugin version 2012-02-15 10:28:58 -06:00
Terence Parr 3d56d40975 update playground 2012-02-14 16:33:34 -08:00
Terence Parr fa3a664696 got some good examples working that play around with the getter methods. 2012-02-14 16:33:12 -08:00
Terence Parr e30627c967 updated command line options. 2012-02-14 15:14:46 -08:00
Terence Parr cdb420fdde got implementation of getters in! Fixes #8 2012-02-14 15:01:03 -08:00
Terence Parr b8f50d46e7 update playground 2012-02-14 13:59:53 -08:00
Terence Parr a6786743d4 got it generating getters, labels correctly. now to impl getters 2012-02-14 13:58:48 -08:00
Terence Parr 6c2beb530d see A.g4 for getter syntax; use e() not gete(). adding ContextGetterDecl.java 2012-02-13 20:47:19 -08:00
Terence Parr 203ad46820 fixed 8 unit tests; only 9 fail now. 2012-02-13 17:47:26 -08:00
Terence Parr 0031075da2 Merge branch 'master' into enhance-ctx 2012-02-13 17:36:56 -08:00
Terence Parr 2091f2d001 change enterRule to enter in listener interface 2012-02-13 17:35:29 -08:00
Terence Parr 7b672c31da Merge pull request #11 from sharwell/clean-tests
Clean tests
2012-02-13 15:38:39 -08:00
Sam Harwell 146a9b0509 Fix unit test placing output files like "null.java" in the project directory 2012-02-13 16:32:42 -06:00
Terence Parr b68ce1f5aa almost got ctx stuff working 2012-02-13 11:47:26 -08:00
Terence Parr 97ab2c42da mode wasn't working as lexer command 2012-02-13 11:45:10 -08:00
Terence Parr ebb8b3a15b Merge branch 'master' of github.com:parrt/antlr4 into enhance-ctx 2012-02-13 10:20:09 -08:00
Terence Parr d06b83fd22 Merge pull request #8 from sharwell/62146c1651620445e96303e5522eddc2105f2379
Removed redundant check for null
2012-02-13 10:19:30 -08:00
Terence Parr 8af1e23461 adding tests 2012-02-13 09:16:29 -08:00
Terence Parr 3dbf4cdabc mid-job push so i can pull from work to continue. working on updating ctx objects to have getters 2012-02-13 09:15:54 -08:00
Terence Parr f8285bcca0 another useful tuple 2012-02-13 09:15:05 -08:00
Sam Harwell 62146c1651 Remove redundant null check 2012-02-12 23:33:01 -06:00
Terence Parr dee579a68f oops; need to alter this when removing up/down stuff 2012-02-11 17:46:02 -08:00
Terence Parr 808d23e6d1 add some useful classes 2012-02-11 17:42:02 -08:00
Terence Parr b80b22e4fa rm remnants of tree parser 2012-02-11 17:39:50 -08:00
Terence Parr f278d3b453 add unit test for left-recur grammars 2012-02-11 11:35:27 -08:00
Sam Harwell 702b91fab7 Ignore TestPerformance by default since it fails without special configuration 2012-02-09 13:30:44 -06:00
Sam Harwell 7fb73a3849 Construct DFA instances with the decision number 2012-02-09 13:29:14 -06:00
Sam Harwell d589011ad8 Small fixes to the Java grammars used in the performance test 2012-02-09 13:00:27 -06:00
Sam Harwell b686efb293 Code cleanup in unit tests 2012-02-09 12:42:48 -06:00
Sam Harwell 6304a562ea Fix unit tests 2012-02-09 08:45:19 -06:00
sharwell 46d5458617 Fix handling of alts with some configs predicated and some configs unpredicated (should be treated as always true) 2012-02-09 01:11:09 -06:00
sharwell f5f3861cb7 Fix unit test 2012-02-08 23:47:35 -06:00
sharwell 0ec084dc73 Simplified exec code in BaseTest 2012-02-08 19:27:34 -06:00
sharwell e5aa949435 More informative parameter names 2012-02-08 19:26:05 -06:00