forked from jasder/antlr
change ruleElementOption back to elementOption
This commit is contained in:
parent
531afe5af8
commit
19fce5dd7d
|
@ -658,8 +658,8 @@ alternative
|
|||
paraphrases.pop();
|
||||
Grammar.setNodeOptions($tree, $o.tree);
|
||||
}
|
||||
: o=ruleElementOptions?
|
||||
e+=element+ -> ^(ALT<AltAST> ruleElementOptions? $e+)
|
||||
: o=elementOptions?
|
||||
e+=element+ -> ^(ALT<AltAST> elementOptions? $e+)
|
||||
| -> ^(ALT<AltAST> EPSILON) // empty alt
|
||||
;
|
||||
|
||||
|
@ -715,9 +715,9 @@ actionElement
|
|||
}
|
||||
}
|
||||
: ACTION<ActionAST>
|
||||
| ACTION ruleElementOptions -> ^(ACTION<ActionAST> ruleElementOptions)
|
||||
| ACTION elementOptions -> ^(ACTION<ActionAST> elementOptions)
|
||||
| SEMPRED<PredAST>
|
||||
| SEMPRED ruleElementOptions -> ^(SEMPRED<PredAST> ruleElementOptions)
|
||||
| SEMPRED elementOptions -> ^(SEMPRED<PredAST> elementOptions)
|
||||
;
|
||||
|
||||
labeledElement
|
||||
|
@ -794,8 +794,8 @@ wildcard
|
|||
// Because the terminal rule is allowed to be the node
|
||||
// specification for the start of a tree rule, we must
|
||||
// later check that wildcard was not used for that.
|
||||
DOT ruleElementOptions?
|
||||
-> ^(WILDCARD<TerminalAST>[$DOT] ruleElementOptions?)
|
||||
DOT elementOptions?
|
||||
-> ^(WILDCARD<TerminalAST>[$DOT] elementOptions?)
|
||||
;
|
||||
|
||||
// --------------------
|
||||
|
@ -876,13 +876,13 @@ if ( options!=null ) {
|
|||
Grammar.setNodeOptions($tree, options);
|
||||
}
|
||||
}
|
||||
: TOKEN_REF ruleElementOptions? -> ^(TOKEN_REF<TerminalAST> ruleElementOptions?)
|
||||
| STRING_LITERAL ruleElementOptions? -> ^(STRING_LITERAL<TerminalAST> ruleElementOptions?)
|
||||
: TOKEN_REF elementOptions? -> ^(TOKEN_REF<TerminalAST> elementOptions?)
|
||||
| STRING_LITERAL elementOptions? -> ^(STRING_LITERAL<TerminalAST> elementOptions?)
|
||||
;
|
||||
|
||||
// Terminals may be adorned with certain options when
|
||||
// reference in the grammar: TOK<,,,>
|
||||
ruleElementOptions
|
||||
elementOptions
|
||||
: LT (elementOption (COMMA elementOption)*)? GT
|
||||
-> ^(ELEMENT_OPTIONS[$LT,"ELEMENT_OPTIONS"] elementOption*)
|
||||
;
|
||||
|
|
|
@ -148,7 +148,7 @@ public void finishAlt(AltAST alt) { }
|
|||
|
||||
public void ruleRef(GrammarAST ref, ActionAST arg) { }
|
||||
public void tokenRef(TerminalAST ref) { }
|
||||
public void ruleElementOption(GrammarASTWithOptions t, GrammarAST ID, GrammarAST valueAST) { }
|
||||
public void elementOption(GrammarASTWithOptions t, GrammarAST ID, GrammarAST valueAST) { }
|
||||
public void stringRef(TerminalAST ref) { }
|
||||
public void wildcardRef(GrammarAST ref) { }
|
||||
public void actionInAlt(ActionAST action) { }
|
||||
|
@ -703,8 +703,8 @@ lexerElement
|
|||
| lexerSubrule
|
||||
| ACTION {actionInAlt((ActionAST)$ACTION);}
|
||||
| SEMPRED {sempredInAlt((PredAST)$SEMPRED);}
|
||||
| ^(ACTION ruleElementOptions) {actionInAlt((ActionAST)$ACTION);}
|
||||
| ^(SEMPRED ruleElementOptions) {sempredInAlt((PredAST)$SEMPRED);}
|
||||
| ^(ACTION elementOptions) {actionInAlt((ActionAST)$ACTION);}
|
||||
| ^(SEMPRED elementOptions) {sempredInAlt((PredAST)$SEMPRED);}
|
||||
| EPSILON
|
||||
;
|
||||
|
||||
|
@ -738,7 +738,7 @@ lexerAtom
|
|||
: terminal
|
||||
| ^(NOT blockSet)
|
||||
| blockSet
|
||||
| ^(WILDCARD ruleElementOptions)
|
||||
| ^(WILDCARD elementOptions)
|
||||
| WILDCARD
|
||||
| LEXER_CHAR_SET
|
||||
| range
|
||||
|
@ -752,9 +752,9 @@ actionElement
|
|||
exitActionElement($start);
|
||||
}
|
||||
: ACTION
|
||||
| ^(ACTION ruleElementOptions)
|
||||
| ^(ACTION elementOptions)
|
||||
| SEMPRED
|
||||
| ^(SEMPRED ruleElementOptions)
|
||||
| ^(SEMPRED elementOptions)
|
||||
;
|
||||
|
||||
alternative
|
||||
|
@ -766,7 +766,7 @@ alternative
|
|||
finishAlt((AltAST)$start);
|
||||
exitAlternative((AltAST)$start);
|
||||
}
|
||||
: ^(ALT ruleElementOptions? element+)
|
||||
: ^(ALT elementOptions? element+)
|
||||
| ^(ALT EPSILON)
|
||||
;
|
||||
|
||||
|
@ -806,8 +806,8 @@ element
|
|||
| subrule
|
||||
| ACTION {actionInAlt((ActionAST)$ACTION);}
|
||||
| SEMPRED {sempredInAlt((PredAST)$SEMPRED);}
|
||||
| ^(ACTION ruleElementOptions) {actionInAlt((ActionAST)$ACTION);}
|
||||
| ^(SEMPRED ruleElementOptions) {sempredInAlt((PredAST)$SEMPRED);}
|
||||
| ^(ACTION elementOptions) {actionInAlt((ActionAST)$ACTION);}
|
||||
| ^(SEMPRED elementOptions) {sempredInAlt((PredAST)$SEMPRED);}
|
||||
|
||||
| ^(NOT blockSet)
|
||||
| ^(NOT block)
|
||||
|
@ -888,7 +888,7 @@ atom
|
|||
}
|
||||
: ^(DOT ID terminal)
|
||||
| ^(DOT ID ruleref)
|
||||
| ^(WILDCARD ruleElementOptions) {wildcardRef($WILDCARD);}
|
||||
| ^(WILDCARD elementOptions) {wildcardRef($WILDCARD);}
|
||||
| WILDCARD {wildcardRef($WILDCARD);}
|
||||
| terminal
|
||||
| blockSet
|
||||
|
@ -963,33 +963,33 @@ terminal
|
|||
@after {
|
||||
exitTerminal($start);
|
||||
}
|
||||
: ^(STRING_LITERAL ruleElementOptions)
|
||||
: ^(STRING_LITERAL elementOptions)
|
||||
{stringRef((TerminalAST)$STRING_LITERAL);}
|
||||
| STRING_LITERAL {stringRef((TerminalAST)$STRING_LITERAL);}
|
||||
| ^(TOKEN_REF ruleElementOptions) {tokenRef((TerminalAST)$TOKEN_REF);}
|
||||
| ^(TOKEN_REF elementOptions) {tokenRef((TerminalAST)$TOKEN_REF);}
|
||||
| TOKEN_REF {tokenRef((TerminalAST)$TOKEN_REF);}
|
||||
;
|
||||
|
||||
ruleElementOptions
|
||||
elementOptions
|
||||
@init {
|
||||
enterElementOptions($start);
|
||||
}
|
||||
@after {
|
||||
exitElementOptions($start);
|
||||
}
|
||||
: ^(ELEMENT_OPTIONS ruleElementOption[(GrammarASTWithOptions)$start.getParent()]*)
|
||||
: ^(ELEMENT_OPTIONS elementOption[(GrammarASTWithOptions)$start.getParent()]*)
|
||||
;
|
||||
|
||||
ruleElementOption[GrammarASTWithOptions t]
|
||||
elementOption[GrammarASTWithOptions t]
|
||||
@init {
|
||||
enterElementOption($start);
|
||||
}
|
||||
@after {
|
||||
exitElementOption($start);
|
||||
}
|
||||
: ID {ruleElementOption(t, $ID, null);}
|
||||
| ^(ASSIGN id=ID v=ID) {ruleElementOption(t, $id, $v);}
|
||||
| ^(ASSIGN ID v=STRING_LITERAL) {ruleElementOption(t, $ID, $v);}
|
||||
| ^(ASSIGN ID v=ACTION) {ruleElementOption(t, $ID, $v);}
|
||||
| ^(ASSIGN ID v=INT) {ruleElementOption(t, $ID, $v);}
|
||||
: ID {elementOption(t, $ID, null);}
|
||||
| ^(ASSIGN id=ID v=ID) {elementOption(t, $id, $v);}
|
||||
| ^(ASSIGN ID v=STRING_LITERAL) {elementOption(t, $ID, $v);}
|
||||
| ^(ASSIGN ID v=ACTION) {elementOption(t, $ID, $v);}
|
||||
| ^(ASSIGN ID v=INT) {elementOption(t, $ID, $v);}
|
||||
;
|
||||
|
|
|
@ -121,12 +121,12 @@ outerAlternative returns [boolean isLeftRec]
|
|||
;
|
||||
|
||||
binary
|
||||
: ^( ALT ruleElementOptions? recurse element+ recurse ACTION? )
|
||||
: ^( ALT elementOptions? recurse element+ recurse ACTION? )
|
||||
{setAltAssoc((AltAST)$ALT,currentOuterAltNumber);}
|
||||
;
|
||||
|
||||
prefix
|
||||
: ^( ALT ruleElementOptions?
|
||||
: ^( ALT elementOptions?
|
||||
({!((CommonTree)input.LT(1)).getText().equals(ruleName)}? element)+
|
||||
recurse ACTION?
|
||||
)
|
||||
|
@ -134,14 +134,14 @@ prefix
|
|||
;
|
||||
|
||||
suffix
|
||||
: ^( ALT ruleElementOptions? recurse element+ )
|
||||
: ^( ALT elementOptions? recurse element+ )
|
||||
{setAltAssoc((AltAST)$ALT,currentOuterAltNumber);}
|
||||
;
|
||||
|
||||
nonLeftRecur
|
||||
: ^(ALT element+) // no assoc for these; ignore if <assoc=...> present
|
||||
;
|
||||
|
||||
|
||||
recurse
|
||||
: ^(ASSIGN ID recurseNoLabel)
|
||||
| recurseNoLabel
|
||||
|
@ -153,16 +153,16 @@ token returns [GrammarAST t=null]
|
|||
: ^(ASSIGN ID s=token {$t = $s.t;})
|
||||
| ^(PLUS_ASSIGN ID s=token {$t = $s.t;})
|
||||
| b=STRING_LITERAL {$t = $b;}
|
||||
| ^(b=STRING_LITERAL ruleElementOptions) {$t = $b;}
|
||||
| ^(c=TOKEN_REF ruleElementOptions) {$t = $c;}
|
||||
| ^(b=STRING_LITERAL elementOptions) {$t = $b;}
|
||||
| ^(c=TOKEN_REF elementOptions) {$t = $c;}
|
||||
| c=TOKEN_REF {$t = $c;}
|
||||
;
|
||||
|
||||
ruleElementOptions
|
||||
: ^(ELEMENT_OPTIONS ruleElementOption*)
|
||||
elementOptions
|
||||
: ^(ELEMENT_OPTIONS elementOption*)
|
||||
;
|
||||
|
||||
ruleElementOption
|
||||
elementOption
|
||||
: ID
|
||||
| ^(ASSIGN ID ID)
|
||||
| ^(ASSIGN ID STRING_LITERAL)
|
||||
|
@ -200,16 +200,16 @@ block
|
|||
;
|
||||
|
||||
alternative
|
||||
: ^(ALT ruleElementOptions? element+)
|
||||
: ^(ALT elementOptions? element+)
|
||||
;
|
||||
|
||||
atom
|
||||
: ^(RULE_REF ARG_ACTION?)
|
||||
| ^(STRING_LITERAL ruleElementOptions)
|
||||
| ^(STRING_LITERAL elementOptions)
|
||||
| STRING_LITERAL
|
||||
| ^(TOKEN_REF ruleElementOptions)
|
||||
| ^(TOKEN_REF elementOptions)
|
||||
| TOKEN_REF
|
||||
| ^(WILDCARD ruleElementOptions)
|
||||
| ^(WILDCARD elementOptions)
|
||||
| WILDCARD
|
||||
| ^(DOT ID element)
|
||||
;
|
||||
|
|
|
@ -232,7 +232,7 @@ public class BasicSemanticChecks extends GrammarTreeVisitor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void ruleElementOption(GrammarASTWithOptions elem, GrammarAST ID, GrammarAST valueAST) {
|
||||
public void elementOption(GrammarASTWithOptions elem, GrammarAST ID, GrammarAST valueAST) {
|
||||
String v = null;
|
||||
boolean ok = checkElementOptions(elem, ID, valueAST);
|
||||
// if ( ok ) {
|
||||
|
|
|
@ -185,7 +185,7 @@ public class SymbolCollector extends GrammarTreeVisitor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void ruleElementOption(GrammarASTWithOptions t, GrammarAST ID, GrammarAST valueAST) {
|
||||
public void elementOption(GrammarASTWithOptions t, GrammarAST ID, GrammarAST valueAST) {
|
||||
setActionResolver(valueAST);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue