--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Arguments in fragment rules could be useful. In fact, the original implementation allowing actions at arbitrary locations allowed them, but this functionality was removed in commit 214b715. There are several problems with this functionality, but the primary problem is it produced a major breaking change to many complicated grammars involving multiple modes. For example, consider the following grammar:
In this grammar the rule TemplateExpression_LBRACE references rule LBRACE. If actions from invoked rules were executed, the semantics of TemplateExpression_LBRACE would now result in two calls to pushMode(AnonymousTemplate). In addition to sneaky but major breaking changes to existing grammars, the mental effort required to maintain an understanding of the impact of actions in invoked rules vastly outweighed any possible benefit of allowing this scenario. We chose instead to implement LexerATNSimulator in a manner that always ignores these actions, which preserves existing behavior for pre-4.2 grammars, but still allows additional action placement starting with 4.2.
Sam
--
Arguments in fragment rules could be useful. In fact, the original implementation allowing actions at arbitrary locations allowed them, but this functionality was removed in commit 214b715. There are several problems with this functionality, but the primary problem is it produced a major breaking change to many complicated grammars involving multiple modes. For example, consider the following grammar:
In this grammar the rule TemplateExpression_LBRACE references rule LBRACE. If actions from invoked rules were executed, the semantics of TemplateExpression_LBRACE would now result in two calls to pushMode(AnonymousTemplate). In addition to sneaky but major breaking changes to existing grammars, the mental effort required to maintain an understanding of the impact of actions in invoked rules vastly outweighed any possible benefit of allowing this scenario. We chose instead to implement LexerATNSimulator in a manner that always ignores these actions, which preserves existing behavior for pre-4.2 grammars, but still allows additional action placement starting with 4.2.
Cheers,
Chris
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussion+unsubscribe@googlegroups.com.
Cheers,
Chris
As a side note, I have experimented with the "token per character" approach suggested by Terence.
I did have problems with NullPointerException's in the default error handling strategy which turned out to be due to the fact that the CharsAsTokens TokenSource provided with the book example didn't implement get/setTokenFactory() properly. Once I fixed that it seems to work quite well, despite its uglyness. I highly doubt that it performs very well though, although I haven't ran any performance tests on it yet.
Cheers,
Chris
@Overridepublic TokenFactory<?> getTokenFactory() {return CommonTokenFactory.DEFAULT;}
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.