Documentation
¶
Overview ¶
Package ast is an Abstract Syntax Tree for gogll, used for code generation.
Index ¶
- type Any
- type AnyOf
- type BracketType
- type CharLiteral
- type GoGLL
- type LexBase
- type LexBracket
- type LexRule
- type LexSymbol
- type Lookahead
- type NT
- type Not
- type Package
- type RegExp
- type StringLit
- type SyntaxAlternate
- type SyntaxRule
- type SyntaxSuffix
- type SyntaxSymbol
- type Terminal
- type TokID
- type TriState
- type UnicodeClass
- type UnicodeClassType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BracketType ¶
type BracketType int
const ( LexGroup BracketType = iota LexOptional LexZeroOrMore LexOneOrMore )
type CharLiteral ¶
type CharLiteral struct { Literal []rune // contains filtered or unexported fields }
func CharLitFromStringLit ¶
func CharLitFromStringLit(sl *StringLit, i int) *CharLiteral
CharLitFromStringLit returns a dummy CharLiteral with Literal sl.Literal[i]
func NewCharLiteral ¶
func NewCharLiteral(tok *token.Token, literal []rune) *CharLiteral
func (*CharLiteral) Char ¶
func (c *CharLiteral) Char() rune
func (*CharLiteral) Equal ¶
func (c *CharLiteral) Equal(other LexBase) bool
func (*CharLiteral) Lext ¶
func (c *CharLiteral) Lext() int
func (*CharLiteral) String ¶
func (c *CharLiteral) String() string
type GoGLL ¶
type GoGLL struct { Package *Package LexRules []*LexRule SyntaxRules []*SyntaxRule Terminals *stringset.StringSet NonTerminals *stringset.StringSet Lookaheads *stringset.StringSet StringLiterals map[string]*StringLit }
func Build ¶
Build builds an AST from the BSR root. `root` is the root of a disambiguated BSR forest
func (*GoGLL) GetLexRule ¶
func (*GoGLL) GetStringLiterals ¶
GetStringLiterals returns a sorted slice of the string literals
func (*GoGLL) GetStringLiteralsSet ¶
GetStringLiteralsSet returns a stringset containing the string literals
func (*GoGLL) GetSymbols ¶
func (*GoGLL) GetSyntaxRule ¶
func (g *GoGLL) GetSyntaxRule(nt string) *SyntaxRule
func (*GoGLL) StartSymbol ¶
type LexBracket ¶
type LexBracket struct { Type BracketType Alternates []*RegExp // contains filtered or unexported fields }
func (*LexBracket) LeftBracket ¶
func (l *LexBracket) LeftBracket() string
func (*LexBracket) Lext ¶
func (b *LexBracket) Lext() int
func (*LexBracket) RightBracket ¶
func (l *LexBracket) RightBracket() string
func (*LexBracket) String ¶
func (lb *LexBracket) String() string
type Lookahead ¶
type Lookahead struct { // operator for expression Op *token.Token // operator subexpression. (should not be lookahead) Expr SyntaxSymbol }
A lookahead expression
type SyntaxAlternate ¶
type SyntaxAlternate struct {
Symbols []SyntaxSymbol
}
An alternate expression
func (*SyntaxAlternate) Empty ¶
func (a *SyntaxAlternate) Empty() bool
func (*SyntaxAlternate) GetSymbols ¶
func (a *SyntaxAlternate) GetSymbols() []string
type SyntaxRule ¶
type SyntaxRule struct { Head *NT Alternates []*SyntaxAlternate IsOrdered bool }
A syntax rule
func (*SyntaxRule) AlwaysMatches ¶
func (r *SyntaxRule) AlwaysMatches() bool
true if always matches; false if unable to guarantee always matches
func (*SyntaxRule) Lext ¶
func (r *SyntaxRule) Lext() int
type SyntaxSuffix ¶
type SyntaxSuffix struct { // expression made optional Expr SyntaxSymbol // token for operator Tok *token.Token // signifies the type of suffix // 0: optional (?) // 1: repeat zero or more times (*) // 2: repeat one or more times (+) Type int }
A syntax suffix operator
func (*SyntaxSuffix) Lext ¶
func (opt *SyntaxSuffix) Lext() int
func (*SyntaxSuffix) String ¶
func (opt *SyntaxSuffix) String() string
type SyntaxSymbol ¶
type SyntaxSymbol interface { // Lext returns the left extent of SyntaxSymbol in the input string Lext() int // The ID of the symbol // which is the literal string of a LexRule, SyntaxRule or StringLit. ID() string // The string of the symbol String() string // contains filtered or unexported methods }
A syntax symbol
type TokID ¶
type TokID struct {
// contains filtered or unexported fields
}
func StringLitToTokID ¶
StringLitToTokID returns a dummy TokID with ID = id
type UnicodeClass ¶
type UnicodeClass struct { Type UnicodeClassType // contains filtered or unexported fields }
func (*UnicodeClass) Equal ¶
func (u *UnicodeClass) Equal(other LexBase) bool
func (*UnicodeClass) Lext ¶
func (u *UnicodeClass) Lext() int
func (*UnicodeClass) String ¶
func (u *UnicodeClass) String() string
type UnicodeClassType ¶
type UnicodeClassType int
const ( Letter UnicodeClassType = iota Upcase Lowcase Number Space )
Click to show internal directories.
Click to hide internal directories.