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 NT
- type Not
- type Package
- type Position
- type RegExp
- type StringLit
- type SyntaxAlternate
- type SyntaxRule
- type SyntaxSymbol
- type Terminal
- type TokID
- type TriState
- type UnicodeClass
- type UnicodeClassType
- type UnicodeRange
- func (u *UnicodeRange) ContainsClass(c *UnicodeClass) bool
- func (u *UnicodeRange) Equals(u1 *UnicodeRange) bool
- func (u *UnicodeRange) EqualsRange(u1 *UnicodeRange) bool
- func (u *UnicodeRange) GetRangeTable() *unicode.RangeTable
- func (u *UnicodeRange) In(rng *UnicodeRange) bool
- func (u *UnicodeRange) String() string
- func (u *UnicodeRange) Subset(sup *UnicodeSet) bool
- type UnicodeRangeType
- type UnicodeRanges
- func (u UnicodeRanges) Contain(rng *UnicodeRange) bool
- func (u UnicodeRanges) ContainRange(rng *UnicodeRange) bool
- func (u UnicodeRanges) Equal(other UnicodeRanges) bool
- func (u UnicodeRanges) EqualRange(other UnicodeRanges) bool
- func (u UnicodeRanges) Lext() int
- func (u UnicodeRanges) String() string
- type UnicodeSet
- func (u *UnicodeSet) ContainsClass(c *UnicodeClass) bool
- func (u *UnicodeSet) ContainsRangeTable(rngTab *unicode.RangeTable) bool
- func (u *UnicodeSet) ContainsRune(r rune) bool
- func (u *UnicodeSet) ContainsRunes(runes ...rune) bool
- func (u *UnicodeSet) ContainsSet(u1 *UnicodeSet) bool
- func (u *UnicodeSet) Equal(other LexBase) bool
- func (u *UnicodeSet) GetRangeTables() (incl, excl []*unicode.RangeTable)
- func (u *UnicodeSet) Lext() int
- func (u *UnicodeSet) String() string
- func (u *UnicodeSet) Subset(sup *UnicodeSet) bool
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, escaped bool) *CharLiteral
CharLitFromStringLit returns a dummy CharLiteral with Literal sl.Literal[i] If escaped sl.Literal[i] == '\\' and sl.Literal[i+1] is the escaped char.
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 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 StringLit ¶
type StringLit struct {
// contains filtered or unexported fields
}
func (*StringLit) ContainsWhiteSpace ¶
type SyntaxAlternate ¶
type SyntaxAlternate struct {
Symbols []SyntaxSymbol
}
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 }
func (*SyntaxRule) Lext ¶
func (r *SyntaxRule) Lext() int
type SyntaxSymbol ¶
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) ContainsSet ¶ added in v3.3.1
func (u *UnicodeClass) ContainsSet(s *UnicodeSet) bool
func (*UnicodeClass) Equal ¶
func (u *UnicodeClass) Equal(other LexBase) bool
func (*UnicodeClass) GetRangeTable ¶ added in v3.3.1
func (u *UnicodeClass) GetRangeTable() *unicode.RangeTable
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 )
type UnicodeRange ¶ added in v3.3.1
type UnicodeRange struct { Pos *Position Type UnicodeRangeType Exclude bool Range string // contains filtered or unexported fields }
func (*UnicodeRange) ContainsClass ¶ added in v3.3.1
func (u *UnicodeRange) ContainsClass(c *UnicodeClass) bool
func (*UnicodeRange) Equals ¶ added in v3.3.1
func (u *UnicodeRange) Equals(u1 *UnicodeRange) bool
func (*UnicodeRange) EqualsRange ¶ added in v3.3.1
func (u *UnicodeRange) EqualsRange(u1 *UnicodeRange) bool
EqualsRange ignores the Exclude field
func (*UnicodeRange) GetRangeTable ¶ added in v3.3.1
func (u *UnicodeRange) GetRangeTable() *unicode.RangeTable
GetRangeTable returns the category or property RangeTable of r
func (*UnicodeRange) In ¶ added in v3.3.1
func (u *UnicodeRange) In(rng *UnicodeRange) bool
In returns true iff rng contains u
func (*UnicodeRange) String ¶ added in v3.3.1
func (u *UnicodeRange) String() string
func (*UnicodeRange) Subset ¶ added in v3.3.1
func (u *UnicodeRange) Subset(sup *UnicodeSet) bool
Subset returns true iff f is a subset or equal of sup
type UnicodeRangeType ¶ added in v3.3.1
type UnicodeRangeType int
const ( UnicodeCategory UnicodeRangeType = iota UnicodeProperty )
type UnicodeRanges ¶ added in v3.3.1
type UnicodeRanges []*UnicodeRange
func (UnicodeRanges) Contain ¶ added in v3.3.1
func (u UnicodeRanges) Contain(rng *UnicodeRange) bool
func (UnicodeRanges) ContainRange ¶ added in v3.3.1
func (u UnicodeRanges) ContainRange(rng *UnicodeRange) bool
ContainRanges ignores the Exclude field
func (UnicodeRanges) Equal ¶ added in v3.3.1
func (u UnicodeRanges) Equal(other UnicodeRanges) bool
func (UnicodeRanges) EqualRange ¶ added in v3.3.1
func (u UnicodeRanges) EqualRange(other UnicodeRanges) bool
EqualRange ignores Exclude field
func (UnicodeRanges) Lext ¶ added in v3.3.1
func (u UnicodeRanges) Lext() int
func (UnicodeRanges) String ¶ added in v3.3.1
func (u UnicodeRanges) String() string
type UnicodeSet ¶ added in v3.3.1
type UnicodeSet struct { Pos *Position Ranges UnicodeRanges // contains filtered or unexported fields }
func (*UnicodeSet) ContainsClass ¶ added in v3.3.1
func (u *UnicodeSet) ContainsClass(c *UnicodeClass) bool
func (*UnicodeSet) ContainsRangeTable ¶ added in v3.3.1
func (u *UnicodeSet) ContainsRangeTable(rngTab *unicode.RangeTable) bool
func (*UnicodeSet) ContainsRune ¶ added in v3.3.1
func (u *UnicodeSet) ContainsRune(r rune) bool
func (*UnicodeSet) ContainsRunes ¶ added in v3.3.1
func (u *UnicodeSet) ContainsRunes(runes ...rune) bool
func (*UnicodeSet) ContainsSet ¶ added in v3.3.1
func (u *UnicodeSet) ContainsSet(u1 *UnicodeSet) bool
func (*UnicodeSet) Equal ¶ added in v3.3.1
func (u *UnicodeSet) Equal(other LexBase) bool
func (*UnicodeSet) GetRangeTables ¶ added in v3.3.1
func (u *UnicodeSet) GetRangeTables() (incl, excl []*unicode.RangeTable)
func (*UnicodeSet) Lext ¶ added in v3.3.1
func (u *UnicodeSet) Lext() int
func (*UnicodeSet) String ¶ added in v3.3.1
func (u *UnicodeSet) String() string
func (*UnicodeSet) Subset ¶ added in v3.3.1
func (u *UnicodeSet) Subset(sup *UnicodeSet) bool
Subset returns true iff u is a subset or equal of sup