Documentation ¶
Overview ¶
Package ast defines the abstract syntax tree for the PEG grammar.
The parser generator's PEG grammar generates a tree using this package that is then converted by the builder to the simplified AST used in the generated parser.
Index ¶
- func Inspect(expr Expression, f func(Expression) bool)
- func Optimize(g *Grammar, alternateEntrypoints ...string)
- func Walk(v Visitor, expr Expression)
- type ActionExpr
- type AndCodeExpr
- type AndExpr
- type AnyMatcher
- type CharClassMatcher
- type ChoiceExpr
- type CodeBlock
- type Expression
- type FailureLabel
- type Grammar
- type Identifier
- type LabeledExpr
- type LitMatcher
- type NotCodeExpr
- type NotExpr
- type OneOrMoreExpr
- type Pos
- type RecoveryExpr
- type Rule
- type RuleRefExpr
- type SeqExpr
- type StateCodeExpr
- type StringLit
- type ThrowExpr
- type Visitor
- type ZeroOrMoreExpr
- type ZeroOrOneExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Inspect ¶ added in v1.1.0
func Inspect(expr Expression, f func(Expression) bool)
Inspect traverses an AST in depth-first order: It starts by calling f(expr); expr must not be nil. If f returns true, Inspect invokes f recursively for each of the non-nil children of expr, followed by a call of f(nil).
func Optimize ¶ added in v1.1.0
Optimize walks a given grammar and optimizes the grammar in regards of parsing performance. This is done with several optimizations:
- removal of unreferenced rules
- replace rule references with a copy of the referenced Rule, if the referenced rule it self has no references.
- resolve nested choice expressions
- resolve choice expressions with only one alternative
- resolve nested sequences expression
- resolve sequence expressions with only one element
- combine character class matcher and literal matcher, where possible
func Walk ¶ added in v1.1.0
func Walk(v Visitor, expr Expression)
Walk traverses an AST in depth-first order: It starts by calling v.Visit(expr); Expression must not be nil. If the visitor w returned by v.Visit(expr) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of Expression, followed by a call of w.Visit(nil).
Types ¶
type ActionExpr ¶
type ActionExpr struct { Expr Expression Code *CodeBlock FuncIx int Nullable bool // contains filtered or unexported fields }
ActionExpr is an expression that has an associated block of code to execute when the expression matches.
func NewActionExpr ¶
func NewActionExpr(p Pos) *ActionExpr
NewActionExpr creates a new action expression at the specified position.
func (*ActionExpr) InitialNames ¶ added in v1.2.0
func (a *ActionExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*ActionExpr) IsNullable ¶ added in v1.2.0
func (a *ActionExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*ActionExpr) NullableVisit ¶ added in v1.2.0
func (a *ActionExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*ActionExpr) Pos ¶
func (a *ActionExpr) Pos() Pos
Pos returns the starting position of the node.
func (*ActionExpr) String ¶
func (a *ActionExpr) String() string
String returns the textual representation of a node.
type AndCodeExpr ¶
AndCodeExpr is a zero-length matcher that is considered a match if the code block returns true.
func NewAndCodeExpr ¶
func NewAndCodeExpr(p Pos) *AndCodeExpr
NewAndCodeExpr creates a new and (&) code expression at the specified position.
func (*AndCodeExpr) InitialNames ¶ added in v1.2.0
func (a *AndCodeExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*AndCodeExpr) IsNullable ¶ added in v1.2.0
func (a *AndCodeExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*AndCodeExpr) NullableVisit ¶ added in v1.2.0
func (a *AndCodeExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*AndCodeExpr) Pos ¶
func (a *AndCodeExpr) Pos() Pos
Pos returns the starting position of the node.
func (*AndCodeExpr) String ¶
func (a *AndCodeExpr) String() string
String returns the textual representation of a node.
type AndExpr ¶
type AndExpr struct { Expr Expression // contains filtered or unexported fields }
AndExpr is a zero-length matcher that is considered a match if the expression it contains is a match.
func NewAndExpr ¶
NewAndExpr creates a new and (&) expression at the specified position.
func (*AndExpr) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*AndExpr) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*AndExpr) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type AnyMatcher ¶
type AnyMatcher struct {
// contains filtered or unexported fields
}
AnyMatcher is a matcher that matches any character except end-of-file.
func NewAnyMatcher ¶
func NewAnyMatcher(p Pos, v string) *AnyMatcher
NewAnyMatcher creates a new any matcher at the specified position. The value is provided for completeness' sake, but it is always the dot.
func (*AnyMatcher) InitialNames ¶ added in v1.2.0
func (a *AnyMatcher) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*AnyMatcher) IsNullable ¶ added in v1.2.0
func (a *AnyMatcher) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*AnyMatcher) NullableVisit ¶ added in v1.2.0
func (a *AnyMatcher) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*AnyMatcher) Pos ¶
func (a *AnyMatcher) Pos() Pos
Pos returns the starting position of the node.
func (*AnyMatcher) String ¶
func (a *AnyMatcher) String() string
String returns the textual representation of a node.
type CharClassMatcher ¶
type CharClassMatcher struct { IgnoreCase bool Inverted bool Chars []rune Ranges []rune // pairs of low/high range UnicodeClasses []string // contains filtered or unexported fields }
CharClassMatcher is a character class matcher. The value to match must be one of the specified characters, in a range of characters, or in the Unicode classes of characters.
func NewCharClassMatcher ¶
func NewCharClassMatcher(p Pos, raw string) *CharClassMatcher
NewCharClassMatcher creates a new character class matcher at the specified position and with the specified raw value. It parses the raw value into the list of characters, ranges and Unicode classes.
func (*CharClassMatcher) InitialNames ¶ added in v1.2.0
func (c *CharClassMatcher) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*CharClassMatcher) IsNullable ¶ added in v1.2.0
func (c *CharClassMatcher) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*CharClassMatcher) NullableVisit ¶ added in v1.2.0
func (c *CharClassMatcher) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*CharClassMatcher) Pos ¶
func (c *CharClassMatcher) Pos() Pos
Pos returns the starting position of the node.
func (*CharClassMatcher) String ¶
func (c *CharClassMatcher) String() string
String returns the textual representation of a node.
type ChoiceExpr ¶
type ChoiceExpr struct { Alternatives []Expression Nullable bool // contains filtered or unexported fields }
ChoiceExpr is an ordered sequence of expressions. The parser tries to match any of the alternatives in sequence and stops at the first one that matches.
func NewChoiceExpr ¶
func NewChoiceExpr(p Pos) *ChoiceExpr
NewChoiceExpr creates a choice expression at the specified position.
func (*ChoiceExpr) InitialNames ¶ added in v1.2.0
func (c *ChoiceExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*ChoiceExpr) IsNullable ¶ added in v1.2.0
func (c *ChoiceExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*ChoiceExpr) NullableVisit ¶ added in v1.2.0
func (c *ChoiceExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*ChoiceExpr) Pos ¶
func (c *ChoiceExpr) Pos() Pos
Pos returns the starting position of the node.
func (*ChoiceExpr) String ¶
func (c *ChoiceExpr) String() string
String returns the textual representation of a node.
type CodeBlock ¶
type CodeBlock struct {
// contains filtered or unexported fields
}
CodeBlock represents a code block.
func NewCodeBlock ¶
NewCodeBlock creates a new code block at the specified position and with the specified value. The value includes the outer braces.
func (*CodeBlock) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*CodeBlock) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*CodeBlock) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type Expression ¶
type Expression interface { Pos() Pos // for work with left recursion NullableVisit(rules map[string]*Rule) bool IsNullable() bool InitialNames() map[string]struct{} }
Expression is the interface implemented by all expression types.
type FailureLabel ¶ added in v1.1.0
type FailureLabel string
FailureLabel is an identifier, which can by thrown and recovered in a grammar.
type Grammar ¶
Grammar is the top-level node of the AST for the PEG grammar.
func NewGrammar ¶
NewGrammar creates a new grammar at the specified position.
func (*Grammar) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*Grammar) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*Grammar) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type Identifier ¶
type Identifier struct {
// contains filtered or unexported fields
}
Identifier represents an identifier.
func NewIdentifier ¶
func NewIdentifier(p Pos, name string) *Identifier
NewIdentifier creates a new identifier at the specified position and with the specified name.
func (*Identifier) InitialNames ¶ added in v1.2.0
func (i *Identifier) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*Identifier) IsNullable ¶ added in v1.2.0
func (i *Identifier) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*Identifier) NullableVisit ¶ added in v1.2.0
func (i *Identifier) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*Identifier) Pos ¶
func (i *Identifier) Pos() Pos
Pos returns the starting position of the node.
func (*Identifier) String ¶
func (i *Identifier) String() string
String returns the textual representation of a node.
type LabeledExpr ¶
type LabeledExpr struct { Label *Identifier Expr Expression // contains filtered or unexported fields }
LabeledExpr is an expression that has an associated label. Code blocks can access the value of the expression using that label, that becomes a local variable in the code.
func NewLabeledExpr ¶
func NewLabeledExpr(p Pos) *LabeledExpr
NewLabeledExpr creates a new labeled expression at the specified position.
func (*LabeledExpr) InitialNames ¶ added in v1.2.0
func (l *LabeledExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*LabeledExpr) IsNullable ¶ added in v1.2.0
func (l *LabeledExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*LabeledExpr) NullableVisit ¶ added in v1.2.0
func (l *LabeledExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*LabeledExpr) Pos ¶
func (l *LabeledExpr) Pos() Pos
Pos returns the starting position of the node.
func (*LabeledExpr) String ¶
func (l *LabeledExpr) String() string
String returns the textual representation of a node.
type LitMatcher ¶
type LitMatcher struct { IgnoreCase bool // contains filtered or unexported fields }
LitMatcher is a string literal matcher. The value to match may be a double-quoted string, a single-quoted single character, or a back-tick quoted raw string.
func NewLitMatcher ¶
func NewLitMatcher(p Pos, v string) *LitMatcher
NewLitMatcher creates a new literal matcher at the specified position and with the specified value.
func (*LitMatcher) InitialNames ¶ added in v1.2.0
func (l *LitMatcher) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*LitMatcher) IsNullable ¶ added in v1.2.0
func (l *LitMatcher) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*LitMatcher) NullableVisit ¶ added in v1.2.0
func (l *LitMatcher) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*LitMatcher) Pos ¶
func (l *LitMatcher) Pos() Pos
Pos returns the starting position of the node.
func (*LitMatcher) String ¶
func (l *LitMatcher) String() string
String returns the textual representation of a node.
type NotCodeExpr ¶
NotCodeExpr is a zero-length matcher that is considered a match if the code block returns false.
func NewNotCodeExpr ¶
func NewNotCodeExpr(p Pos) *NotCodeExpr
NewNotCodeExpr creates a new not (!) code expression at the specified position.
func (*NotCodeExpr) InitialNames ¶ added in v1.2.0
func (n *NotCodeExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*NotCodeExpr) IsNullable ¶ added in v1.2.0
func (n *NotCodeExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*NotCodeExpr) NullableVisit ¶ added in v1.2.0
func (n *NotCodeExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*NotCodeExpr) Pos ¶
func (n *NotCodeExpr) Pos() Pos
Pos returns the starting position of the node.
func (*NotCodeExpr) String ¶
func (n *NotCodeExpr) String() string
String returns the textual representation of a node.
type NotExpr ¶
type NotExpr struct { Expr Expression // contains filtered or unexported fields }
NotExpr is a zero-length matcher that is considered a match if the expression it contains is not a match.
func NewNotExpr ¶
NewNotExpr creates a new not (!) expression at the specified position.
func (*NotExpr) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*NotExpr) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*NotExpr) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type OneOrMoreExpr ¶
type OneOrMoreExpr struct { Expr Expression // contains filtered or unexported fields }
OneOrMoreExpr is an expression that can be matched one or more times.
func NewOneOrMoreExpr ¶
func NewOneOrMoreExpr(p Pos) *OneOrMoreExpr
NewOneOrMoreExpr creates a new one or more expression at the specified position.
func (*OneOrMoreExpr) InitialNames ¶ added in v1.2.0
func (o *OneOrMoreExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*OneOrMoreExpr) IsNullable ¶ added in v1.2.0
func (o *OneOrMoreExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*OneOrMoreExpr) NullableVisit ¶ added in v1.2.0
func (o *OneOrMoreExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*OneOrMoreExpr) Pos ¶
func (o *OneOrMoreExpr) Pos() Pos
Pos returns the starting position of the node.
func (*OneOrMoreExpr) String ¶
func (o *OneOrMoreExpr) String() string
String returns the textual representation of a node.
type RecoveryExpr ¶ added in v1.1.0
type RecoveryExpr struct { Expr Expression RecoverExpr Expression Labels []FailureLabel Nullable bool // contains filtered or unexported fields }
RecoveryExpr is an ordered sequence of expressions. The parser tries to match any of the alternatives in sequence and stops at the first one that matches.
func NewRecoveryExpr ¶ added in v1.1.0
func NewRecoveryExpr(p Pos) *RecoveryExpr
NewRecoveryExpr creates a choice expression at the specified position.
func (*RecoveryExpr) InitialNames ¶ added in v1.2.0
func (r *RecoveryExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*RecoveryExpr) IsNullable ¶ added in v1.2.0
func (r *RecoveryExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*RecoveryExpr) NullableVisit ¶ added in v1.2.0
func (r *RecoveryExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*RecoveryExpr) Pos ¶ added in v1.1.0
func (r *RecoveryExpr) Pos() Pos
Pos returns the starting position of the node.
func (*RecoveryExpr) String ¶ added in v1.1.0
func (r *RecoveryExpr) String() string
String returns the textual representation of a node.
type Rule ¶
type Rule struct { Name *Identifier DisplayName *StringLit Expr Expression // Fields below to work with left recursion. Visited bool Nullable bool LeftRecursive bool Leader bool // contains filtered or unexported fields }
Rule represents a rule in the PEG grammar. It has a name, an optional display name to be used in error messages, and an expression.
func NewRule ¶
func NewRule(p Pos, name *Identifier) *Rule
NewRule creates a rule with at the specified position and with the specified name as identifier.
func (*Rule) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*Rule) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*Rule) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type RuleRefExpr ¶
type RuleRefExpr struct { Name *Identifier Nullable bool // contains filtered or unexported fields }
RuleRefExpr is an expression that references a rule by name.
func NewRuleRefExpr ¶
func NewRuleRefExpr(p Pos) *RuleRefExpr
NewRuleRefExpr creates a new rule reference expression at the specified position.
func (*RuleRefExpr) InitialNames ¶ added in v1.2.0
func (r *RuleRefExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*RuleRefExpr) IsNullable ¶ added in v1.2.0
func (r *RuleRefExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*RuleRefExpr) NullableVisit ¶ added in v1.2.0
func (r *RuleRefExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*RuleRefExpr) Pos ¶
func (r *RuleRefExpr) Pos() Pos
Pos returns the starting position of the node.
func (*RuleRefExpr) String ¶
func (r *RuleRefExpr) String() string
String returns the textual representation of a node.
type SeqExpr ¶
type SeqExpr struct { Exprs []Expression Nullable bool // contains filtered or unexported fields }
SeqExpr is an ordered sequence of expressions, all of which must match if the SeqExpr is to be a match itself.
func NewSeqExpr ¶
NewSeqExpr creates a new sequence expression at the specified position.
func (*SeqExpr) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*SeqExpr) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*SeqExpr) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type StateCodeExpr ¶ added in v1.1.0
StateCodeExpr is an expression which can modify the internal state of the parser.
func NewStateCodeExpr ¶ added in v1.1.0
func NewStateCodeExpr(p Pos) *StateCodeExpr
NewStateCodeExpr creates a new state (#) code expression at the specified position.
func (*StateCodeExpr) InitialNames ¶ added in v1.2.0
func (s *StateCodeExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*StateCodeExpr) IsNullable ¶ added in v1.2.0
func (s *StateCodeExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*StateCodeExpr) NullableVisit ¶ added in v1.2.0
func (s *StateCodeExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*StateCodeExpr) Pos ¶ added in v1.1.0
func (s *StateCodeExpr) Pos() Pos
Pos returns the starting position of the node.
func (*StateCodeExpr) String ¶ added in v1.1.0
func (s *StateCodeExpr) String() string
String returns the textual representation of a node.
type StringLit ¶
type StringLit struct {
// contains filtered or unexported fields
}
StringLit represents a string literal.
func NewStringLit ¶
NewStringLit creates a new string literal at the specified position and with the specified value.
func (*StringLit) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*StringLit) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*StringLit) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type ThrowExpr ¶ added in v1.1.0
type ThrowExpr struct { Label string // contains filtered or unexported fields }
ThrowExpr is an expression that throws an FailureLabel to be catched by a RecoveryChoiceExpr.
func NewThrowExpr ¶ added in v1.1.0
NewThrowExpr creates a new throw expression at the specified position.
func (*ThrowExpr) InitialNames ¶ added in v1.2.0
InitialNames returns names of nodes with which an expression can begin.
func (*ThrowExpr) IsNullable ¶ added in v1.2.0
IsNullable returns the nullable attribute of the node.
func (*ThrowExpr) NullableVisit ¶ added in v1.2.0
NullableVisit recursively determines whether an object is nullable.
type Visitor ¶ added in v1.1.0
type Visitor interface {
Visit(expr Expression) (w Visitor)
}
A Visitor implements a Visit method, which is invoked for each Expression encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of Expression with the visitor w, followed by a call of w.Visit(nil).
type ZeroOrMoreExpr ¶
type ZeroOrMoreExpr struct { Expr Expression // contains filtered or unexported fields }
ZeroOrMoreExpr is an expression that can be matched zero or more times.
func NewZeroOrMoreExpr ¶
func NewZeroOrMoreExpr(p Pos) *ZeroOrMoreExpr
NewZeroOrMoreExpr creates a new zero or more expression at the specified position.
func (*ZeroOrMoreExpr) InitialNames ¶ added in v1.2.0
func (z *ZeroOrMoreExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*ZeroOrMoreExpr) IsNullable ¶ added in v1.2.0
func (z *ZeroOrMoreExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*ZeroOrMoreExpr) NullableVisit ¶ added in v1.2.0
func (z *ZeroOrMoreExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*ZeroOrMoreExpr) Pos ¶
func (z *ZeroOrMoreExpr) Pos() Pos
Pos returns the starting position of the node.
func (*ZeroOrMoreExpr) String ¶
func (z *ZeroOrMoreExpr) String() string
String returns the textual representation of a node.
type ZeroOrOneExpr ¶
type ZeroOrOneExpr struct { Expr Expression // contains filtered or unexported fields }
ZeroOrOneExpr is an expression that can be matched zero or one time.
func NewZeroOrOneExpr ¶
func NewZeroOrOneExpr(p Pos) *ZeroOrOneExpr
NewZeroOrOneExpr creates a new zero or one expression at the specified position.
func (*ZeroOrOneExpr) InitialNames ¶ added in v1.2.0
func (z *ZeroOrOneExpr) InitialNames() map[string]struct{}
InitialNames returns names of nodes with which an expression can begin.
func (*ZeroOrOneExpr) IsNullable ¶ added in v1.2.0
func (z *ZeroOrOneExpr) IsNullable() bool
IsNullable returns the nullable attribute of the node.
func (*ZeroOrOneExpr) NullableVisit ¶ added in v1.2.0
func (z *ZeroOrOneExpr) NullableVisit(rules map[string]*Rule) bool
NullableVisit recursively determines whether an object is nullable.
func (*ZeroOrOneExpr) Pos ¶
func (z *ZeroOrOneExpr) Pos() Pos
Pos returns the starting position of the node.
func (*ZeroOrOneExpr) String ¶
func (z *ZeroOrOneExpr) String() string
String returns the textual representation of a node.