public class GrammarElementMatcher extends java.lang.Object implements Rule, Matcher, AstNodeSkippingPolicy
Constructor and Description |
---|
GrammarElementMatcher(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName() |
boolean |
hasToBeSkippedFromAst(AstNode node)
Some AstNode can be pretty useless and makes a global AST less readable.
|
GrammarElementMatcher |
is(java.lang.Object... elements)
This method allows to provide the definition of a context-free grammar rule.
|
boolean |
match(MatcherContext context) |
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
|
GrammarElementMatcher |
override(java.lang.Object... elements)
This method has the same effect as
RuleImpl#is(Object...) , except that it can be called more than once to redefine a rule from
scratch. |
void |
recoveryRule()
A rule should be flagged as being a "Recovery" rule if it's responsibility is to consume
some bad tokens in order to recover from a parsing error.
|
void |
skip()
Remove this node from the AST and attached its children directly to its parent
|
void |
skipIf(AstNodeSkippingPolicy policy)
Remove this node from the AST according to a provided policy
|
void |
skipIfOneChild()
Remove this node from the AST if it has exactly 1 child
|
public GrammarElementMatcher is(java.lang.Object... elements)
Rule
Rule.override(Object...)
method must be used.public GrammarElementMatcher override(java.lang.Object... elements)
Rule
RuleImpl#is(Object...)
, except that it can be called more than once to redefine a rule from
scratch. It can be used if the rule has to be redefined later (for instance in a grammar extension).public void mock()
Rule
public java.lang.String getName()
public boolean match(MatcherContext context)
public void skip()
Rule
public void skipIfOneChild()
Rule
skipIfOneChild
in interface Rule
public void skipIf(AstNodeSkippingPolicy policy)
Rule
public void recoveryRule()
Rule
RecognitionExceptionListener
injected into the Parser
are automatically
notified.recoveryRule
in interface Rule
RecognitionExceptionListener
public boolean hasToBeSkippedFromAst(AstNode node)
AstNodeSkippingPolicy
hasToBeSkippedFromAst
in interface AstNodeSkippingPolicy
node
- the node that should or not be removed from the ASTCopyright © 2012 SonarSource. All Rights Reserved.