--
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.
The syntax/file with which I am currently playing around can be found right here: https://github.com/timeraider4u/xtext-predicates/blob/master/xtext/C.xtext
The original file has been the ANTLRv3 grammar file for C.
The problem is that you need semantic predicates for distingishing between a typedefName and a directDeclarator.
So I do not know if it is possible to re-write the grammar. If not, I do not know how to continue...
I know that it would be possible to refactor the syntax such that no ambiguties can happen and change the EMF classes later in a post-processing phase after parsing but I would prefer to not change the semantics of the grammar and to be able to use semantic predicates in Xtext instead...
Do you/does anybody know if it is possible to ignore actions when hoisting predicates?
Dear Jim, unfortunately I have to correct you that C.g4 (the ANTLRv4 version of C) is pretty much the same as the version for Xtext/version 3.
When you run the newer version you get less warnings but the generated parser is still not able to distingish between directDeclarators and typeNames in a correct way. Semantic predicates are still needed!!!
I know that it would be possible to refactor the syntax such that no ambiguties can happen and change the EMF classes later in a post-processing phase after parsing but I would prefer to not change the semantics of the grammar and to be able to use semantic predicates in Xtext instead...
Do you/does anybody know if it is possible to ignore actions when hoisting predicates?
* Improved nondeterminism warning to have: Semantic predicates were present but were hidden by actions. parser grammar U; a : (A B)? ; b : X a {p1}? A B | Y a {a1} {p2}? A B | Z a ; To create the prediction DFA for the optional sub rule in 'a', ANTLR must find all references to 'a' to determine what can follow. A B can follow 'a' in the first two alts rule 'b'. To resolve the conflict between matching A B immediately in the sub rule and exiting rule 'a' to match it in 'b', ANTLR looks for predicates. In this case, there are two predicates that indicate the semantic context in which the surrounding alternatives are valid. The problem is that one of the predicates is hidden by an action. It took me 1.5 days, but I've finally have gotten ANTLR to properly track the insufficiently covered alternatives. Further, I have gotten it to tell you precisely where the uncovered predicates are even if they are simply hidden by actions. I have also updated all of the nondeterminism warnings so that it tells you if there was a predicate but one hidden by an action (this could be a separate condition from insufficiently covered predicates). here are your messages from ANTLR: ANTLR Parser Generator Version 3.1b1 (??) 1989-2007 warning(203): U.g:2:5: Input such as "A B" is insufficiently covered with predicates at locations: alt 2: line 3:38 at B Semantic predicates were present but were hidden by actions. warning(200): U.g:2:5: Decision can match input such as "A B" using multiple alternatives: 1, 2 As a result, alternative(s) 2 were disabled for that input Semantic predicates were present but were hidden by actions. * Fixed ANTLR-222. ANTLR now ignores preds after actions.
I will take a closer look on the source code next week when I am back from vacation - thanks to your effort I now know what I have to look out for ;-).
Otherwise there is still the possibility to change the grammar if it is not working out as I would like it to be...