public final class PGrammarRule extends Object
The rule can be ground or be parameterized by a number of formal parameters. A parameterized rule represents a generic rule from which ground rules can be obtained by simply instantiating the formal parameters with terminals or (instantiated) non-terminals of the grammar. A rule's parameter can be used in its production items, as a regular symbol of the grammar, and also as holes in semantic actions where they stand for the return type associated to the formal parameter. Public rules cannot be parametric as public rules act as monomorphic entry points allowing the monomorphization of a parametric grammar.
The relative order of productions for this grammar rule is the one from the original source but is not semantically relevant for the produced grammar.
Modifier and Type | Class and Description |
---|---|
static class |
PGrammarRule.Builder
A builder class for grammar rules,
where productions can be added incrementally
|
Modifier and Type | Field and Description |
---|---|
@Nullable PExtent |
args
The formal arguments for this rule, if any
|
Located<String> |
name
The name of this rule
|
List<Located<String>> |
params
The generic parameters of the rule
|
List<PProduction> |
productions
The productions for this rule
|
PExtent |
returnType
This rule's return type
|
boolean |
visibility
Whether this grammar rule is public or not
|
Constructor and Description |
---|
PGrammarRule(boolean visibility,
PExtent returnType,
Located<String> name,
List<Located<String>> params,
@Nullable PExtent args,
List<PProduction> productions)
Builds a grammar rule from the given parameters
|
public final boolean visibility
public final PExtent returnType
public final @Nullable PExtent args
public final List<PProduction> productions
public PGrammarRule(boolean visibility, PExtent returnType, Located<String> name, List<Located<String>> params, @Nullable PExtent args, List<PProduction> productions)
visibility
- returnType
- name
- params
- args
- productions
-