forked from jasder/antlr
rm gated sem pred and other weird variants
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 8914]
This commit is contained in:
parent
9328c164af
commit
e084c12483
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -109,7 +109,6 @@ element returns [List<? extends SrcOp> 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<SrcOp> om
|
|||
| ruleref[label, $astOp] {$omos = $ruleref.omos;}
|
||||
| blockSet[$label, $astOp, invert] {$omos = $blockSet.omos;}
|
||||
;
|
||||
|
||||
|
||||
ruleref[GrammarAST label, GrammarAST astOp] returns [List<SrcOp> 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<SrcOp> omos]
|
||||
: {
|
||||
controller.treeLevel++;
|
||||
|
|
|
@ -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<ActionAST>
|
||||
| FORCED_ACTION<ActionAST>
|
||||
| SEMPRED
|
||||
( IMPLIES -> GATED_SEMPRED[$SEMPRED]
|
||||
| -> SEMPRED<PredAST>
|
||||
)
|
||||
| SEMPRED -> SEMPRED<PredAST>
|
||||
| treeSpec
|
||||
( ebnfSuffix -> ^( ebnfSuffix ^(BLOCK<BlockAST>[$treeSpec.start,"BLOCK"] ^(ALT<AltAST> 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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue