org.sonar.sslr.grammar
Interface GrammarRuleBuilder


public interface GrammarRuleBuilder

This interface contains methods used to describe rule of grammar.

This interface is not intended to be implemented by clients.

Since:
1.18
See Also:
LexerlessGrammarBuilder.rule(GrammarRuleKey), LexerfulGrammarBuilder.rule(GrammarRuleKey)

Method Summary
 GrammarRuleBuilder is(Object e)
          Allows to provide definition of a grammar rule.
 GrammarRuleBuilder is(Object e, Object... rest)
          Convenience method equivalent to calling is(grammarBuilder.sequence(e, rest)).
 GrammarRuleBuilder override(Object e)
          Allows to override definition of a grammar rule.
 GrammarRuleBuilder override(Object e, Object... rest)
          Convenience method equivalent to calling override(grammarBuilder.sequence(e, rest)).
 void recoveryRule()
          Deprecated. in 1.19, no difference between usual grammar rule and "recovery rule" - both will be presented in AST and so can be handled via AST visitor.
 void skip()
          Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.
 void skipIfOneChild()
          Indicates that grammar rule should not lead to creation of AST node if it has exactly one child.
 

Method Detail

is

GrammarRuleBuilder is(Object e)
Allows 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 GrammarException will be thrown.

Parameters:
e - expression of grammar
Returns:
this (for method chaining)
Throws:
GrammarException - if definition has been already done
IllegalArgumentException - if given argument is not a parsing expression

is

GrammarRuleBuilder is(Object e,
                      Object... rest)
Convenience method equivalent to calling is(grammarBuilder.sequence(e, rest)).

Parameters:
e - expression of grammar
rest - rest of expressions
Returns:
this (for method chaining)
Throws:
GrammarException - if definition has been already done
IllegalArgumentException - if any of given arguments is not a parsing expression
See Also:
is(Object)

override

GrammarRuleBuilder override(Object e)
Allows to override definition of a grammar 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.

Parameters:
e - expression of grammar
Returns:
this (for method chaining)
Throws:
IllegalArgumentException - if given argument is not a parsing expression

override

GrammarRuleBuilder override(Object e,
                            Object... rest)
Convenience method equivalent to calling override(grammarBuilder.sequence(e, rest)).

Parameters:
e - expression of grammar
rest - rest of expressions
Returns:
this (for method chaining)
Throws:
IllegalArgumentException - if any of given arguments is not a parsing expression
See Also:
override(Object)

skip

void skip()
Indicates that grammar rule should not lead to creation of AST node - its children should be attached directly to its parent.


skipIfOneChild

void skipIfOneChild()
Indicates that grammar rule should not lead to creation of AST node if it has exactly one child.


recoveryRule

@Deprecated
void recoveryRule()
Deprecated. in 1.19, no difference between usual grammar rule and "recovery rule" - both will be presented in AST and so can be handled via AST visitor.

Throws:
UnsupportedOperationException - always


Copyright © 2009-2014 SonarSource. All Rights Reserved.