public class MutableParsingRule extends Object implements CompilableGrammarRule, Matcher, Rule, AstNodeSkippingPolicy, MemoParsingExpression, GrammarRuleKey
| Constructor and Description |
|---|
MutableParsingRule(GrammarRuleKey ruleKey) |
MutableParsingRule(String name) |
| Modifier and Type | Method and Description |
|---|---|
Instruction[] |
compile(CompilationHandler compiler)
Compiles this expression into a sequence of instructions.
|
ParsingExpression |
getExpression() |
String |
getName() |
AstNodeType |
getRealAstNodeType() |
GrammarRuleKey |
getRuleKey() |
boolean |
hasToBeSkippedFromAst(AstNode node)
Some AstNode can be pretty useless and makes a global AST less readable.
|
Rule |
is(Object... e)
Allows to provide definition of a grammar rule.
|
void |
mock()
Utility method used for unit testing in order to dynamically replace the definition of the rule to match as soon as a token whose value
equals the name of the rule is encountered.
|
Rule |
override(Object... e)
Allows to override definition of a grammar rule.
|
void |
recoveryRule() |
void |
setExpression(ParsingExpression expression) |
boolean |
shouldMemoize() |
void |
skip()
Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.
|
void |
skipIf(AstNodeSkippingPolicy policy)
Defines policy of creation of AST node for this rule.
|
void |
skipIfOneChild()
Indicates that grammar rule should not lead to creation of AST node if it has exactly one child.
|
String |
toString() |
public MutableParsingRule(String name)
public MutableParsingRule(GrammarRuleKey ruleKey)
public String getName()
public AstNodeType getRealAstNodeType()
public GrammarRuleKey getRuleKey()
getRuleKey in interface CompilableGrammarRulepublic ParsingExpression getExpression()
getExpression in interface CompilableGrammarRulepublic Rule is(Object... e)
RuleNote: this method can be called only once for a rule. If it is called more than once, an IllegalStateException will be thrown.
public Rule override(Object... e)
Rule
This method has the same effect as #is(Object), except that it can be called more than once to redefine a rule from scratch.
public void mock()
Rulepublic void setExpression(ParsingExpression expression)
setExpression in interface CompilableGrammarRulepublic void skip()
Rulepublic void skipIfOneChild()
RuleskipIfOneChild in interface Rulepublic void skipIf(AstNodeSkippingPolicy policy)
Rulepublic void recoveryRule()
recoveryRule in interface Rulepublic boolean hasToBeSkippedFromAst(AstNode node)
AstNodeSkippingPolicyhasToBeSkippedFromAst in interface AstNodeSkippingPolicynode - the node that should or not be removed from the ASTpublic Instruction[] compile(CompilationHandler compiler)
ParsingExpressioncompile in interface ParsingExpressionpublic boolean shouldMemoize()
shouldMemoize in interface MemoParsingExpressionCopyright © 2009–2018 SonarSource. All rights reserved.