Sam Harwell
9600a70724
Fix NPE in CommonToken when TokenSource is not available
2012-02-13 08:41:57 -06:00
Terence Parr
6e4cba131a
Allow var args in ctor of IntervalSet
2012-02-11 15:30:54 -08:00
Terence Parr
f278d3b453
add unit test for left-recur grammars
2012-02-11 11:35:27 -08:00
sharwell
9c554a002b
Add LexerATNSimulator.copyState (allows copying state information from another simulator instance)
2012-02-09 00:15:30 -06:00
sharwell
40a8759276
Add LexerATNSimulator.getTraceStream
2012-02-09 00:14:37 -06:00
sharwell
3b4ae2a742
Use trivial implementation of mark/release for BufferedTokenStream
2012-02-08 18:58:57 -06:00
sharwell
f43f9f2218
Override CommonTokenStream.reset() to make sure the stream is left on an on-channel token
2012-02-08 18:58:19 -06:00
sharwell
a34fd6330b
Use isEmpty() instead of size()==0
2012-02-08 18:57:32 -06:00
sharwell
a9e44f3aab
Use isEmpty() instead of size()==0, use StringBuilder instead of StringBuffer, use chained append() calls instead of string concatenation, add @Override annotations
2012-02-08 18:57:05 -06:00
sharwell
d181b230dc
Specify generic type parameter
2012-02-08 18:55:57 -06:00
sharwell
64203312ac
Improved SemanticContext.hashCode(), add @Override annotations
2012-02-08 18:54:40 -06:00
sharwell
773e9e1c7e
Add generic type argument
2012-02-08 18:12:01 -06:00
sharwell
dcdfac4bcd
Improved implementation of equals() and hashCode() for ATNConfig
2012-02-08 18:09:32 -06:00
sharwell
64210f4b72
Add @NotNull annotations, make ATNConfig.semanticContext field final
2012-02-08 17:21:09 -06:00
sharwell
71e0c66477
Rename NUM_EDGES to MAX_DFA_EDGE, reduce max value to 127
2012-02-08 17:15:34 -06:00
sharwell
2249135c21
Specify generic type parameters
2012-02-08 17:12:22 -06:00
sharwell
1df70924f5
Use ATNConfigSet instead of OrderedHashSet<ATNConfig>
2012-02-08 17:06:41 -06:00
sharwell
52256044a9
Use for each instead of indexed for; use isEmpty() instead of size()==0
2012-02-08 17:06:03 -06:00
sharwell
326cb259a0
Construct Parser with TokenStream (restriction from IntStream)
2012-02-08 16:34:04 -06:00
sharwell
18a6414fb3
Use ATNConfigSet for parameter instead of OrderedHashSet<ATNConfig>
2012-02-08 16:26:14 -06:00
sharwell
a6524d8b38
Add pom.xml to support maven builds
2012-02-08 15:07:06 -06:00
Terence Parr
894a77168d
rename atn sim, add error message to TestRig
2012-02-05 10:14:04 -08:00
Terence Parr
1cc7ac3410
added -trace to TestRig. fixed code gen issue for trace listener
2012-01-30 16:51:55 -08:00
parrt
e90b322dd4
~[] stuff is allowed and works inside sets etc...
...
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9926]
2012-01-28 14:36:46 -08:00
parrt
09da63cfd4
rollback and do a real fix for whitespace escaping
...
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9911]
2012-01-27 12:00:30 -08:00
parrt
7498908d62
rollback and do a real fix for whitespace escaping
...
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9906]
2012-01-26 14:18:57 -08:00
parrt
adcf72b9a2
whitespace was being escaped to special characters even when printing to string should only do so when doing GUI tree
...
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9904]
2012-01-26 14:11:30 -08:00
parrt
9fd280b30e
Lexer fields mv from x to _x
...
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9883]
2012-01-21 15:36:20 -08:00
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