Commit Graph

608 Commits

Author SHA1 Message Date
Terence Parr 03d7b51d3c throw exception upon bad token indexes, add getOffChannelTokensToLeft, right. pull up some off channel token methods from CommonTokenStream. renamed. 2012-05-19 14:22:52 -07:00
Terence Parr 7be2ba9d42 remove unused type param 2012-05-19 13:06:27 -07:00
Terence Parr c590ba8fd8 don't look backwards for err msg if EOF is entire input. make sure we don't use -1 rule index for ruleNames[] 2012-04-29 12:12:42 -07:00
Terence Parr 30f61b17e3 comment tweak 2012-04-15 18:30:28 -07:00
Terence Parr 35aeeb7c5c turn on building parse trees by default since we do -listener by default. 2012-04-07 11:27:18 -07:00
Sam Harwell 1ade15392b Add license header 2012-04-04 15:33:39 -05:00
Sam Harwell e11dc07275 Remove TokenRewriteStream 2012-04-04 15:33:03 -05:00
Terence Parr 585aa0a14b Merge branch 'tokenstreamrewriter' of git://github.com/sharwell/antlr4 2012-04-04 13:20:58 -07:00
Sam Harwell ff2655d379 Rename getSource() to getTokenStream() 2012-04-04 15:20:45 -05:00
Sam Harwell bbd61dca35 Remove TokenStreamRewriter.getOriginalText() (use rewriter.getSource().getText() instead) 2012-04-04 10:15:29 -05:00
Sam Harwell a85f1c17a1 Add TokenStreamRewriter.getSource() 2012-04-04 10:14:09 -05:00
Sam Harwell e4612935f2 Only need TokenStream (was overly restricted to BufferedTokenStream) 2012-04-04 10:10:33 -05:00
Sam Harwell 16046a7ec1 Proper maven reference for org.abego.treelayout.core dependency 2012-04-04 09:52:06 -05:00
Terence Parr bf9c7c3a28 Remove old TokenRewriteStream in favor of new TokenStreamRewriter that is not a stream; it feeds off of the stream to provide transformations of that original stream. Updated the comment at the top of the file. Instead of toString() we use getText(). Altered the unit tests to create a buffered stream and then create the rewriter attached to that. 2012-04-02 18:10:32 -07:00
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 53c5aecb85 Implement UnbufferedTokenStream.get(int) within marked intervals 2012-04-01 18:23:32 -05:00
Sam Harwell 8ec9ba14c9 Implement getText within marked intervals of unbuffered streams 2012-04-01 18:22:43 -05:00
Sam Harwell d6e2e41c1f Fix stop index 2012-04-01 14:29:06 -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 f238d7579e added getText() to ParseTree. getText(tokens) is still really what you want but convenient for ctx.type().getText() when it's just one token. 2012-03-31 17:27:11 -07:00
Terence Parr cc20a52cdd allow special "tokens" start rule name so we can test pure lexer grammars. 2012-03-31 15:54:00 -07:00
Sam Harwell e5d7c27b09 Updated comments to indicate preference of .g4 over .g 2012-03-30 11:37:22 -05:00
Terence Parr 447a5620f0 add -diagnostics option to test rig. 2012-03-28 11:07:23 -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 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
Terence Parr 169f58a3ff fix def of EMPTY->INVALID 2012-03-25 21:19:39 -07: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 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 542e700644 fix antlr/antlr4/#48 (getText from parse tree node). Don't NPE when start/stop null in getSourceInterval. 2012-03-25 10:01:27 -07:00
Terence Parr 4ea3c73d1f cleaned up interval stuff. moved getSourceInterval to ParserRuleContext; renamed create to of() in Interval. 2012-03-24 18:17:35 -07:00
Terence Parr c6365fb5e2 removed config list (huge) from default message. 2012-03-24 16:56:36 -07:00
Terence Parr e228e88ac5 tweak to remove insuff pred method 2012-03-24 16:48:26 -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 b1bcde76b7 Merge commit '768bfc0' into parrt-default-error-listener 2012-03-24 16:40:09 -07:00
Terence Parr 2232ea5101 was not computing lookahead correctly in _LOOK. It assumed all epsilons were predicates. 2012-03-19 17:50:51 -07:00
Sam Harwell bd7796544d Update comments 2012-03-19 08:33:55 -05:00
Sam Harwell 5e0f9a4490 Ensure target non-null in Transition constructor (additional runtime-side consistency check). 2012-03-19 08:33:36 -05:00
Sam Harwell a70cb6f36a Fix NPE in LexerATNSimulator.execDFA error recovery 2012-03-19 08:17:59 -05:00
Terence Parr ea7037dd2d missing semicolon 2012-03-16 14:29:07 -07:00
Terence Parr 9a0aaacbee rm k=1 chk to report early ambiguity. 2012-03-16 14:11:21 -07:00
Sam Harwell ae871dcc07 Rename exec/exec to execDFA/execATN 2012-03-13 19:27:52 -05:00
Sam Harwell aeb43069aa Move reach variable inside loop. Remove unnecessary ATNConfigSet clone. 2012-03-13 19:25:39 -05:00
Sam Harwell 51a15ac4a7 ATNConfigSet prior to error is closure, not reach. Reach is empty. 2012-03-13 19:25:38 -05:00
Sam Harwell 83c680850e Only create a new ATNConfigSet for reach when no DFA edge is available 2012-03-13 19:25:38 -05:00
Sam Harwell 9d774c6543 Separate handling of DFA and ATN transitions during lexer atn sim. 2012-03-13 19:25:37 -05:00
Sam Harwell 1f60da9cfd Handle DFA error states in lexer atn exec 2012-03-13 19:25:37 -05:00
Sam Harwell 590558c4d8 Combine DFAExecState and ATNExecState so we no longer need to throw exceptions in LexerATNSimulator.failOrAccept for valid inputs 2012-03-13 19:25:31 -05:00
Terence Parr aca3e0ddb2 make trim parse trees singular 2012-03-12 15:40:22 -07:00
Terence Parr dc627158e6 loop invar. code motion 2012-03-12 14:19:19 -07:00
Terence Parr 2fc9760ba7 Merge remote-tracking branch 'sharwell/ambig-sempred' 2012-03-12 13:50:45 -07:00
Terence Parr 79f204ff94 Merge commit 'fa9ec19' 2012-03-12 13:22:55 -07:00
Terence Parr 754408da27 Merge commit '86671d3' 2012-03-12 13:19:35 -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 768bfc0cf2 Add ProxyErrorListener to allow dispatching error reporting to multiple listeners without manually iterating over the list of listeners. 2012-03-12 15:07:48 -05:00
Sam Harwell dce72dcbfb * Recognizer._listeners initialized to have a single ConsoleErrorListener
* Use CopyOnWriteArrayList so listeners can be added/removed in callbacks
* Remove special handling for _listeners null or empty (never null, ConsoleErrorListener will be present if feature is desired)
2012-03-12 15:01:21 -05:00
Sam Harwell 50180825d9 Add boolean field ParserATNSimulator.reportAmbiguities (default true). When false, ambiguous alts aren't reported which allows usage of (the faster) incomplete semantic predicate evaluation even within execATN. 2012-03-10 16:41:57 -06:00
Sam Harwell 04cd48e88d No need to fully evaluate predicates when called from execDFA because ambiguous alts aren't reported anyway. 2012-03-10 16:32:10 -06: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 86671d30fb Tweak comments 2012-03-10 13:23:02 -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
Sam Harwell 5deab167a1 ParseTreeVisitor.visit takes a ParseTree... only visitChildren takes a RuleNode 2012-03-04 12:52:43 -06:00
Sam Harwell b570641e2b Simplify ParseTree.visitChildren; ParseTree.visit and visitChildren take a RuleNode parameter; update comments 2012-03-04 12:17:43 -06:00
Sam Harwell a948736729 TerminalNodeImpl.isErrorNode now tests for ErrorNode interface instead of ErrorNodeImpl implementation 2012-03-03 21:57:49 -06:00
Sam Harwell 80b3ec8c62 Dispatch accept() for terminal nodes to visitor 2012-03-03 21:57:08 -06:00
Terence Parr 0375f8318a rename a parameter 2012-03-01 18:01:27 -08:00
Terence Parr 2ba5a1f12a Made the parse tree visitor walk ParseTree objects not ParserRuleContext objects. This necessitated pulling up the accept() and toStringTree(Parser) methods into ParseTree. 2012-03-01 17:57:49 -08:00
Sam Harwell fa9ec191bd Add TrimToSizeListener and Parser.get/setTrimParseTrees 2012-02-29 11:22:54 -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
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 9ae92a5cef reformat 2012-02-27 21:32:25 -08:00
Terence Parr 67b2e6d7c1 forgot to move Pair etc... 2012-02-26 21:55:23 -08:00
Terence Parr e9a3de645a add useful method to get a->b pairs out 2012-02-26 15:55:46 -08:00
Terence Parr 41be88dcd5 mv to runtime 2012-02-26 15:49:45 -08:00
Sam Harwell bedc502d33 Set the listeners list back to null if all listeners are removed from it 2012-02-26 17:33:52 -06:00
Terence Parr 1e438746be added interface for error nodes, method in terminalnode. 2012-02-26 15:32:18 -08:00
Terence Parr db1b86af91 alter visitTerminal interface, add visitErrorNode. 2012-02-25 17:03:41 -08:00
Terence Parr 528e9c7b86 fix cut/paste error 2012-02-25 16:09:29 -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 a74da2df60 Use ==ParserRuleContext.EMPTY instead of .isEmpty() 2012-02-24 15:57:43 -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 1e3e092326 Fix unchecked warnings in clone() 2012-02-23 16:13:15 -06:00
Sam Harwell e400f5b1a1 Move Recognizer._errHandler to Parser class 2012-02-23 16:13:14 -06:00
Sam Harwell 1c8efd6a48 Allow contravariant error listeners 2012-02-23 16:13:13 -06:00
Sam Harwell 6c26917b90 Use generic List instead of generic array for listeners 2012-02-23 16:13:12 -06:00
Sam Harwell 7dcb148d73 CommonTokenStream now extends BufferedTokenStream<Token> instead of BufferedTokenStream<CommonToken>. Token interface provides the same information and the change helps the work on improving generics. 2012-02-23 16:13:11 -06:00
Sam Harwell d7dbef2782 Can get token start and stop index from Token interface now 2012-02-23 16:13:11 -06:00
Sam Harwell 1492648d26 Add missing @Override annotations 2012-02-23 16:13:06 -06:00
Sam Harwell 96c08bec52 Remove unused imports 2012-02-23 16:12:02 -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 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
Terence Parr 58ef729be5 renamed next to target. factored out to methods, commented code. 2012-02-21 12:47:34 -08:00
Terence Parr 0e23c7e2a3 Merge commit '611728a3806d6a8c9fe44a538d34b448784986c1' 2012-02-21 12:14:11 -08:00
Sam Harwell 5fb389b6e4 Improve lexer performance during warm-up by tracking DFA states within exec (ATN) and using existing edges when available 2012-02-20 19:20:50 -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 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