Package org.sonar.sslr.internal.grammar
Class MutableParsingRule
java.lang.Object
org.sonar.sslr.internal.grammar.MutableParsingRule
- All Implemented Interfaces:
AstNodeSkippingPolicy,AstNodeType,Rule,Matcher,GrammarRuleKey,Matcher,CompilableGrammarRule,MemoParsingExpression,ParsingExpression
public class MutableParsingRule
extends Object
implements CompilableGrammarRule, Matcher, Rule, AstNodeSkippingPolicy, MemoParsingExpression, GrammarRuleKey
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompile(CompilationHandler compiler) Compiles this expression into a sequence of instructions.getName()booleanhasToBeSkippedFromAst(AstNode node) Some AstNode can be pretty useless and makes a global AST less readable.Allows to provide definition of a grammar rule.voidmock()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.Allows to override definition of a grammar rule.voidsetExpression(ParsingExpression expression) booleanvoidskip()Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.voidIndicates that grammar rule should not lead to creation of AST node if it has exactly one child.toString()
-
Constructor Details
-
MutableParsingRule
-
MutableParsingRule
-
-
Method Details
-
getName
-
getRealAstNodeType
-
getRuleKey
- Specified by:
getRuleKeyin interfaceCompilableGrammarRule
-
getExpression
- Specified by:
getExpressionin interfaceCompilableGrammarRule
-
is
Description copied from interface:RuleAllows to provide definition of a grammar rule.Note: this method can be called only once for a rule. If it is called more than once, an IllegalStateException will be thrown.
-
override
Description copied from interface:RuleAllows to override definition of a grammar rule.This method has the same effect as
, except that it can be called more than once to redefine a rule from scratch.invalid reference
#is(Object) -
mock
public void mock()Description copied from interface:RuleUtility 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. -
setExpression
- Specified by:
setExpressionin interfaceCompilableGrammarRule
-
skip
public void skip()Description copied from interface:RuleIndicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent. -
skipIfOneChild
public void skipIfOneChild()Description copied from interface:RuleIndicates that grammar rule should not lead to creation of AST node if it has exactly one child.- Specified by:
skipIfOneChildin interfaceRule
-
hasToBeSkippedFromAst
Description copied from interface:AstNodeSkippingPolicySome AstNode can be pretty useless and makes a global AST less readable. This method allows to automatically remove those AstNode from the AST.- Specified by:
hasToBeSkippedFromAstin interfaceAstNodeSkippingPolicy- Parameters:
node- the node that should or not be removed from the AST- Returns:
- true if AstNode with this type must be skipped from the AST.
-
compile
Description copied from interface:ParsingExpressionCompiles this expression into a sequence of instructions.- Specified by:
compilein interfaceParsingExpression
-
toString
-
shouldMemoize
public boolean shouldMemoize()- Specified by:
shouldMemoizein interfaceMemoParsingExpression
-