diff --git a/tool/src/org/antlr/v4/automata/ATNFactory.java b/tool/src/org/antlr/v4/automata/ATNFactory.java index 3d1ad1440..8731aab5a 100644 --- a/tool/src/org/antlr/v4/automata/ATNFactory.java +++ b/tool/src/org/antlr/v4/automata/ATNFactory.java @@ -109,7 +109,6 @@ public interface ATNFactory { * the SEMPRED token. */ Handle sempred(PredAST pred); - Handle gated_sempred(GrammarAST pred); /** Build what amounts to an epsilon transition with an action. * The action goes into ATN though it is ignored during analysis. diff --git a/tool/src/org/antlr/v4/automata/ParserATNFactory.java b/tool/src/org/antlr/v4/automata/ParserATNFactory.java index 8b69a1c2d..6679e355d 100644 --- a/tool/src/org/antlr/v4/automata/ParserATNFactory.java +++ b/tool/src/org/antlr/v4/automata/ParserATNFactory.java @@ -227,14 +227,6 @@ public class ParserATNFactory implements ATNFactory { return new Handle(left, right); } - public Handle gated_sempred(GrammarAST pred) { - ATNState left = newState(pred); - ATNState right = newState(pred); - left.transition = new PredicateTransition(right); - pred.atnState = left; - return new Handle(left, right); - } - /** Build what amounts to an epsilon transition with an action. * The action goes into ATN though it is ignored during prediction * if actionIndex < 0. Only forced are executed during prediction. diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g index 5425ab2c0..e0816025e 100644 --- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g +++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g @@ -109,7 +109,6 @@ element returns [List omos] | ACTION {$omos = controller.action($ACTION);} | FORCED_ACTION {$omos = controller.forcedAction($FORCED_ACTION);} | SEMPRED {$omos = controller.sempred($SEMPRED);} - | GATED_SEMPRED | treeSpec ; @@ -165,7 +164,7 @@ atom[GrammarAST label, GrammarAST astOp, boolean invert] returns [List om | ruleref[label, $astOp] {$omos = $ruleref.omos;} | blockSet[$label, $astOp, invert] {$omos = $blockSet.omos;} ; - + ruleref[GrammarAST label, GrammarAST astOp] returns [List omos] : ^(RULE_REF ARG_ACTION?) {$omos = controller.ruleRef($RULE_REF, $label, $ARG_ACTION, $astOp);} ; @@ -213,7 +212,7 @@ rewrite returns [Rewrite code] ; predicatedRewrite returns [RewriteChoice alt] - : ^(ST_RESULT SEMPRED rewriteSTAlt) + : ^(ST_RESULT SEMPRED rewriteSTAlt) | ^(RESULT SEMPRED rewriteTreeAlt) {$alt = controller.rewrite_choice((PredAST)$SEMPRED, $rewriteTreeAlt.omos);} ; @@ -269,7 +268,7 @@ rewriteTreeEbnf returns [CodeBlock op] controller.codeBlockLevel--; } ; - + rewriteTree returns [List omos] : { controller.treeLevel++; diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.g b/tool/src/org/antlr/v4/parse/ANTLRParser.g index 4d6570a7e..fe814cf0f 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.g +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.g @@ -69,7 +69,6 @@ tokens { OPTIONAL; CLOSURE; POSITIVE_CLOSURE; - SYNPRED; RANGE; SET; CHAR_RANGE; @@ -84,9 +83,6 @@ tokens { INITACTION; LABEL; // $x used in rewrite rules TEMPLATE; - GATED_SEMPRED; // {p}? => - SYN_SEMPRED; // (...) => it's a manually-specified synpred converted to sempred - BACKTRACK_SEMPRED; // auto backtracking mode syn pred converted to sempred WILDCARD; // A generic node indicating a list of something when we don't // really need to distinguish what we have a list of as the AST @@ -400,9 +396,9 @@ rule ARG_ACTION? ruleReturns? - + throwsSpec? - + locals? // Now, before the rule specification itself, which is introduced @@ -587,10 +583,7 @@ element | ebnf | ACTION | FORCED_ACTION - | SEMPRED - ( IMPLIES -> GATED_SEMPRED[$SEMPRED] - | -> SEMPRED - ) + | SEMPRED -> SEMPRED | treeSpec ( ebnfSuffix -> ^( ebnfSuffix ^(BLOCK[$treeSpec.start,"BLOCK"] ^(ALT treeSpec ) ) ) | -> treeSpec @@ -855,7 +848,7 @@ options {backtrack=true;} | // try to parse a template rewrite rewriteTemplate {$isTemplate=true;} // must be 2nd so "ACTION ..." matches as tree rewrite - + | ETC | /* empty rewrite */ -> EPSILON diff --git a/tool/src/org/antlr/v4/parse/ATNBuilder.g b/tool/src/org/antlr/v4/parse/ATNBuilder.g index b272d3ccb..4cfe76390 100644 --- a/tool/src/org/antlr/v4/parse/ATNBuilder.g +++ b/tool/src/org/antlr/v4/parse/ATNBuilder.g @@ -96,13 +96,12 @@ element returns [ATNFactory.Handle p] | ACTION {$p = factory.action((ActionAST)$ACTION);} | FORCED_ACTION {$p = factory.action((ActionAST)$FORCED_ACTION);} | SEMPRED {$p = factory.sempred((PredAST)$SEMPRED);} - | GATED_SEMPRED {$p = factory.gated_sempred($GATED_SEMPRED);} | treeSpec {$p = $treeSpec.p;} | ^(ROOT a=astOperand) {$p = $a.p;} | ^(BANG a=astOperand) {$p = $a.p;} | ^(NOT b=blockSet[true]) {$p = $b.p;} ; - + astOperand returns [ATNFactory.Handle p] : atom {$p = $atom.p;} | ^(NOT blockSet[true]) {$p = $blockSet.p;} @@ -137,7 +136,7 @@ setElement | TOKEN_REF | ^(RANGE a=STRING_LITERAL b=STRING_LITERAL) ; - + astBlockSuffix : ROOT | IMPLIES