ast

package
v3.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ast is an Abstract Syntax Tree for gogll, used for code generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any struct {
	// contains filtered or unexported fields
}

func (*Any) Equal

func (*Any) Equal(other LexBase) bool

func (*Any) Lext

func (a *Any) Lext() int

func (*Any) String

func (*Any) String() string

type AnyOf

type AnyOf struct {
	Set *runeset.RuneSet
	// contains filtered or unexported fields
}

func (*AnyOf) Equal

func (ao *AnyOf) Equal(other LexBase) bool

func (*AnyOf) Lext

func (a *AnyOf) Lext() int

func (*AnyOf) String

func (a *AnyOf) String() string

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

func Build(root bsr.BSR, l *lexer.Lexer) *GoGLL

Build builds an AST from the BSR root. `root` is the root of a disambiguated BSR forest

func (*GoGLL) GetLexRule

func (g *GoGLL) GetLexRule(id string) *LexRule

func (*GoGLL) GetStringLiterals

func (g *GoGLL) GetStringLiterals() []string

GetStringLiterals returns a sorted slice of the string literals

func (*GoGLL) GetStringLiteralsSet

func (g *GoGLL) GetStringLiteralsSet() *stringset.StringSet

GetStringLiteralsSet returns a stringset containing the string literals

func (*GoGLL) GetSymbols

func (g *GoGLL) GetSymbols() []string

func (*GoGLL) GetSyntaxRule

func (g *GoGLL) GetSyntaxRule(nt string) *SyntaxRule

func (*GoGLL) StartSymbol

func (g *GoGLL) StartSymbol() string

type LexBase

type LexBase interface {
	LexSymbol
	Equal(LexBase) bool
	// contains filtered or unexported methods
}

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 LexRule

type LexRule struct {
	Suppress bool
	TokID    *TokID
	RegExp   *RegExp
}

func (*LexRule) ID

func (l *LexRule) ID() string

Returns the id of the lex rule

func (*LexRule) Lext

func (l *LexRule) Lext() int

func (*LexRule) String

func (l *LexRule) String() string

type LexSymbol

type LexSymbol interface {
	Lext() int
	String() string
	// contains filtered or unexported methods
}

type NT

type NT struct {
	// contains filtered or unexported fields
}

func (*NT) ID

func (n *NT) ID() string

ID returns the identifier of n

func (*NT) Lext

func (n *NT) Lext() int

func (*NT) String

func (n *NT) String() string

type Not

type Not struct {
	Set *runeset.RuneSet
	// contains filtered or unexported fields
}

func (*Not) Equal

func (n *Not) Equal(other LexBase) bool

func (*Not) Lext

func (n *Not) Lext() int

func (*Not) String

func (n *Not) String() string

type Package

type Package struct {
	// contains filtered or unexported fields
}

func (*Package) GetString

func (p *Package) GetString() string

type RegExp

type RegExp struct {
	Symbols []LexSymbol
}

func (*RegExp) String

func (re *RegExp) String() string

type StringLit

type StringLit struct {
	// contains filtered or unexported fields
}

func (*StringLit) ContainsWhiteSpace

func (sl *StringLit) ContainsWhiteSpace() bool

func (*StringLit) ID

func (sl *StringLit) ID() string

func (*StringLit) Lext

func (s *StringLit) Lext() int

func (*StringLit) Literal

func (sl *StringLit) Literal() []rune

func (*StringLit) String

func (s *StringLit) String() string

func (*StringLit) Value

func (sl *StringLit) Value() []rune

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) ID

func (r *SyntaxRule) ID() string

ID returns the head of rule r

func (*SyntaxRule) Lext

func (r *SyntaxRule) Lext() int

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

	String() string
	// contains filtered or unexported methods
}

type Terminal

type Terminal interface {
	// contains filtered or unexported methods
}

type TokID

type TokID struct {
	// contains filtered or unexported fields
}

func StringLitToTokID

func StringLitToTokID(id *StringLit) *TokID

StringLitToTokID returns a dummy TokID with ID = id

func (*TokID) ID

func (t *TokID) ID() string

func (*TokID) Lext

func (t *TokID) Lext() int

func (*TokID) String

func (t *TokID) String() string

type TriState

type TriState int

TriState has values: {Undefined, False, True}

const (
	// Undefined is a TriState value
	Undefined TriState = iota
	// False is a TriState value
	False
	// True is a TriState value
	True
)

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL