Commit Graph

408 Commits

Author SHA1 Message Date
parrt 6013c4c97d Added modeNames to gen'd lexers
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9878]
2012-01-21 15:10:46 -08:00
parrt dc82edad02 Summary: we can have lexer commands like -> skip now.
moved model.actions package to chunk
type(foo) didn't match.
ATNBuilder.g now tracks the outer alternative number and calls new factory commands on the lexer commands.
Removed unnecessary resolveWithPredicate field from ATNConfig
Added lexerActionIndex field to ATNConfig since we need to track whether we passed an action in an alternative will rule in the lexer.
Renamed ruleIndex in DFAState and added the lexer action index so that we can execute lexer actions from the DFA.
added functions to the grammar tree visitor for the lexer commands.
Added templates for the lexer commands.
Augmented the lexer ATN factory so that it constructs plain old actions from the lexer commands it finds. That way, the code generator doesn't know any different and generates an action.
Augmented the lexer ATN simulator so that it fires a proper action index now. previously it only used the rule index, which of course doesn't work when you have more than one action in a rule.
rm'd dup code from OutputModelController
altered the epsilon edge removal optimization so that it could not remove actions in lexer rules.
Added list of valid lexer commands in Rule.

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9877]
2012-01-21 15:01:05 -08:00
parrt 093a4f951b leave start/stop char index alone in CommonTokenFactory; refers to original text.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9867]
2012-01-14 11:18:23 -08:00
parrt 5bd780c235 in tree views, spaces/newlines were blanks. I converted to \n and middle dot
for space.

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9857]
2012-01-11 17:25:44 -08:00
parrt 848c6e4313 This change is a major restructuring of how left recursive rules are transformed. Previously I simply rewrote the grammar and ANTLR was none the wiser. However, it quickly became apparent that ANTLR needed to do many different things for recursive rules so I had to insert transformation later in the pipeline. Specifically, I needed it after Rule object creation. I made a special LeftRecursiveRule object that track information collected during transformation so that I could use it later. I made major changes to the left recursion templates as well as the little code snippets in Java.stg. I created a new template called LeftRecursiveRuleFunction an accompanying model object that handles the special case, even though there is some duplication. the biggest difference in the grammar is the introduction of => ID notation on any outermost alternative. This information is not added to the tree, instead the ALT node is annotated with the ID. Rule.getAltLabels() now looks also in the LeftRecursiveRuleAltInfo objects. I have moved to the left recursion transformation to its own object and have moved some objects into the analysis package. Further, I have split out the Rule object creation into its own RuleCollector. I renamed discoverAlt in the grammar tree visitor to be discoverOuterAlt an added discoverAlt so we can get information about individual alts even inside subrules. Listeners always get an event for the generic rule context, which is used if there is no specific label for an alternative. Added a list of iteration operations for LL(*) subrules. Split buildRuleFunction into buildLeftRecursiveRuleFunction and one for normal rule function creation. I have to insert lots of extra code to manage the contexts, but of course it's all done using the templates. As long as those templates are correct, this code generation mechanism will work. I removed the st field from the parser rule context. I injected the left recursion transformation inside the SemanticPipeline. Visitor dispatch methods are always added to the generated context structures. Fixed some unit tests. About 24 fail.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9854]
2012-01-11 11:00:05 -08:00
sharwell 742a08862f Merging dev changes to main
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9853]
2012-01-09 10:26:23 -08:00
parrt 4ae23f4a64 * 1+2*3 now gives new parse tree: (e (e 1) + (e (e 2) * (e 3))) See CHANGES.txt now too
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9833]
2012-01-05 12:27:14 -08:00
parrt cab41e41e3 had non-ascii char
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9812]
2012-01-04 09:05:31 -08:00
parrt 963ccd2700 added comment
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9797]
2012-01-03 12:46:51 -08:00
parrt 224a4bc9e1 changed formatting
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9796]
2012-01-03 12:46:39 -08:00
parrt 8099cec3bd Added ctx to visitTerminal in parse tree listener. That should be useful information. made commensurate change in the parse tree walker to make sure I have a proper context to send to the visitTerminal method. renamed a few fields of parser/lexer to have _ in front to avoid name collisions with user actions. change the name of the listener method so that they're more explicit using the terms Error and Parser to identify what kind of listener we are adding or removing. Added a default TraceListener to Parser so that we can call setTrace(true) to have it start dumping out information as a first step in the debugging process. there are now multiple parse tree listeners possible because I made a list. we may want to pass in multiple actions to the parser.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9795]
2012-01-03 12:46:18 -08:00
parrt 5c328c7e3f Bug: didn't stop at end of stream during consume()
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9794]
2012-01-03 12:40:42 -08:00
parrt 5d60e85617 rm trace ATN state stuff. Will think about when we do debugging.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9792]
2012-01-03 11:07:49 -08:00
parrt c716a87544 move method down in file
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9791]
2012-01-03 11:05:40 -08:00
parrt 5c3c8d6e7a Added TokenFactory, CommonTokenFactory. Update the parser in the lexer with methods to set the factory. Alter the default error strategy and the lexer to use the factory. The parser's set token factory method updates the token source, usually the lexer, and the error handling strategy. I had to add the set token factory method to token source as well to make all of this work.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9789]
2012-01-03 10:58:01 -08:00
parrt 3aeeb2b277 rename BaseREcognizer as Parser
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9781]
2012-01-02 18:36:59 -08:00
parrt 1b04195a2f removed all template / AST rewrite stuff; massive change; added -encoding tool option
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9780]
2012-01-02 18:13:16 -08:00
parrt 8846b98ee7 fix compile error
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9765]
2011-12-29 17:05:34 -08:00
parrt a923ad8765 Major update to v4. I backed out a change I made on Christmas then mistakenly prevented any lexer DFA creation. Per http://www.antlr.org/wiki/display/~admin/2011/12/29/Flaw+in+ANTLR+v3+LL%28*%29+analysis+algorithm I fixed a major flaw in ANTLR's notion of context. To do that, I needed to create a new LoopEndState, with all of its fanout to the serialization and parser ATN construction. got a very good start on ParserATNPathFinder, which uses basic recursion to find all possible paths and return a tree with the possibilities. I left it in the condition where he would sometimes loop forever; it needs to track sets of configurations in the busy set; it using states at the moment. added a new signal from the interpreter: reportAttemptingFullContext. I fixed a bug where configuration sets derived from a configuration that had reachesIntoOuterContext>0 were not being considered as dipping into the outer context. The ambiguity checker needed to switch so that a check for exact matches not suffixes when doing full context. It's faster at the very least for full context. added some more support routines to DFA. Added TraceTree in support of the new ParserATNPathFinder.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9764]
2011-12-29 17:04:40 -08:00
parrt 3b51bb478d rm unneeded field
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9761]
2011-12-27 15:52:47 -08:00
parrt d01bde9125 added new reportAttemptingFullContext to strategy
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9760]
2011-12-27 15:25:01 -08:00
parrt bb960e3c37 improved data to report insuff. preds. also, it was detecting it improperly
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9758]
2011-12-27 14:11:41 -08:00
parrt 638969bed9 add '...' to diagnostics input
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9757]
2011-12-27 13:37:47 -08:00
parrt c1e199d77f added -tokens flag
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9756]
2011-12-26 18:10:29 -08:00
parrt bf8473e0fd add cmt
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9755]
2011-12-26 17:57:00 -08:00
parrt ce9638e59c was still creating dfa with sempreds
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9752]
2011-12-26 17:07:45 -08:00
parrt c1923a107e -tree => -print option
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9748]
2011-12-26 14:05:58 -08:00
parrt db655f8f2c add -gui option to view in gui window
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9747]
2011-12-26 13:06:05 -08:00
parrt 5c50e5f049 Wasn't using Udo's lib correctly
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9746]
2011-12-26 13:05:46 -08:00
parrt c6bde7e1e8 -ps arg wrong
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9745]
2011-12-26 11:13:46 -08:00
parrt adb91a9bde rm print
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9744]
2011-12-26 11:10:30 -08:00
parrt 494f519b05 add java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName [-tree | -ps file.ps] [input-filename]
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9743]
2011-12-26 11:03:51 -08:00
parrt 6daa66f83f no more resolved bit in config. use ATNConfigSet all over. final clean up of ATN sim.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9741]
2011-12-25 12:01:24 -08:00
sharwell 79d1c40427 Integrate CL9648 to main (getAncestors returns Collections.emptyList() instead of null)
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9649]
2011-12-17 11:42:26 -08:00
sharwell c59cf36f88 Integrate CL9646 to main (fix forward seek)
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9647]
2011-12-17 09:51:18 -08:00
parrt 6b673a3b2e track stats properly
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9643]
2011-12-16 16:00:11 -08:00
parrt ebd1fbb63d within 2 or 3 unit test of where I was before I got it the ATN simulator
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9642]
2011-12-16 15:07:28 -08:00
parrt 3d133e9417 broke out fullctx tests, some fixes.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9636]
2011-12-16 09:43:29 -08:00
parrt 1e8548297e mv comment over and make sure that the tree parsers use the new ATN engine
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9635]
2011-12-15 16:14:49 -08:00
parrt 5ad1505fdb almost got new ATN engine working; separated .* nongreedy tests, reorg args on reporting methods
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9627]
2011-12-15 11:03:41 -08:00
sharwell fa3483a7fc Merge CL9619 to main (fix CommonTokenStream.seek)
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9620]
2011-12-15 07:27:52 -08:00
parrt 92279bd6db almost got prediction working
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9600]
2011-12-13 18:10:04 -08:00
parrt 8d73f53775 check in start of new ATN sim engine; rm traversedPred in DFAState.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9598]
2011-12-13 14:38:30 -08:00
parrt 8f7fb98e16 added big comments
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9565]
2011-12-12 16:33:10 -08:00
parrt b9afdf6e07 rename var; add missing return
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9564]
2011-12-11 14:45:25 -08:00
parrt 3fb7466a80 another big reorg and fixed unit test. lots more sharing and splitting into methods; same 21/807 tests fail; java works.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9563]
2011-12-11 14:34:32 -08:00
parrt 8615fc26da rm dead code
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9562]
2011-12-11 13:03:34 -08:00
parrt 18ff004d83 playing; nop
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9560]
2011-12-11 12:29:27 -08:00
parrt d372d761d5 interim refactoring. much smaller execATN; removed prevAccept fields. useless.
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9559]
2011-12-11 12:09:29 -08:00
parrt c3630843d2 add convenience method
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9558]
2011-12-11 11:23:42 -08:00