Documentation ¶
Overview ¶
This package contains the Abstract Syntax Tree (AST) elements used by gocc to generate a target lexer and parser.
The top-level node is Grammar in grammar.go ¶
The EBNF accepted by gocc consists of two parts:
1. The lexical part, containing the definition of tokens.
2. The grammar or syntax part, containing the grammar or syntax of the language. Files containing grammar objects are prefixed with "g", e.g.: galts.go
Index ¶
- Variables
- type FileHeader
- type Grammar
- type LexAlt
- type LexCharLit
- type LexCharRange
- type LexDot
- type LexGroupPattern
- type LexIgnoredTokDef
- type LexImport
- type LexImports
- type LexNTNode
- type LexNode
- type LexNodeVisitor
- type LexOptPattern
- type LexPart
- func (this *LexPart) ProdIndex(id string) LexProdIndex
- func (this *LexPart) Production(id string) LexProduction
- func (this *LexPart) String() string
- func (this *LexPart) StringLitTokDef(id string) *LexTokDef
- func (this *LexPart) TokenIds() []string
- func (this *LexPart) UpdateStringLitTokens(tokens []string)
- type LexPattern
- type LexProdIndex
- type LexProdMap
- type LexProduction
- type LexProductions
- type LexRegDef
- type LexRegDefId
- type LexRepPattern
- type LexTNode
- type LexTerm
- type LexTokDef
- type SyntaxAlts
- type SyntaxBody
- type SyntaxEmpty
- type SyntaxEof
- type SyntaxError
- type SyntaxPart
- type SyntaxProd
- type SyntaxProdId
- type SyntaxProdList
- type SyntaxStringLit
- type SyntaxSymbol
- type SyntaxSymbols
- type SyntaxTokId
Constants ¶
This section is empty.
Variables ¶
View Source
var LexDOT = &LexDot{}
Functions ¶
This section is empty.
Types ¶
type FileHeader ¶
type FileHeader struct { SDTLit string // contains filtered or unexported fields }
func NewFileHeader ¶
func NewFileHeader(sdtLit interface{}) (*FileHeader, error)
func (*FileHeader) String ¶
func (this *FileHeader) String() string
type LexAlt ¶
type LexAlt struct {
Terms []LexTerm
}
func AppendLexTerm ¶
func (LexAlt) LexTerminal ¶
func (*LexAlt) Walk ¶
func (this *LexAlt) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexCharLit ¶
func NewLexCharLit ¶
func NewLexCharLit(tok interface{}) (*LexCharLit, error)
func (*LexCharLit) IsTerminal ¶
func (this *LexCharLit) IsTerminal() bool
func (*LexCharLit) LexTerminal ¶
func (*LexCharLit) LexTerminal() bool
func (*LexCharLit) String ¶
func (this *LexCharLit) String() string
func (*LexCharLit) Walk ¶
func (this *LexCharLit) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexCharRange ¶
type LexCharRange struct { From *LexCharLit To *LexCharLit // contains filtered or unexported fields }
func NewLexCharRange ¶
func NewLexCharRange(from, to interface{}) (*LexCharRange, error)
func (*LexCharRange) IsTerminal ¶
func (this *LexCharRange) IsTerminal() bool
func (*LexCharRange) LexTerminal ¶
func (*LexCharRange) LexTerminal() bool
func (*LexCharRange) String ¶
func (this *LexCharRange) String() string
func (*LexCharRange) Walk ¶
func (this *LexCharRange) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexDot ¶
type LexDot struct{}
func (*LexDot) IsTerminal ¶
func (LexDot) LexTerminal ¶
func (*LexDot) Walk ¶
func (this *LexDot) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexGroupPattern ¶
type LexGroupPattern struct {
*LexPattern
}
func NewLexGroupPattern ¶
func NewLexGroupPattern(pattern interface{}) (*LexGroupPattern, error)
func (*LexGroupPattern) Element ¶
func (this *LexGroupPattern) Element(i int) LexNode
func (*LexGroupPattern) IsTerminal ¶
func (this *LexGroupPattern) IsTerminal() bool
func (*LexGroupPattern) Len ¶
func (this *LexGroupPattern) Len() int
func (LexGroupPattern) LexTerminal ¶
func (LexGroupPattern) LexTerminal() bool
func (*LexGroupPattern) String ¶
func (this *LexGroupPattern) String() string
func (*LexGroupPattern) Walk ¶
func (this *LexGroupPattern) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexIgnoredTokDef ¶
type LexIgnoredTokDef struct {
// contains filtered or unexported fields
}
func NewLexIgnoredTokDef ¶
func NewLexIgnoredTokDef(tokId, lexPattern interface{}) (*LexIgnoredTokDef, error)
func (*LexIgnoredTokDef) Id ¶
func (this *LexIgnoredTokDef) Id() string
func (*LexIgnoredTokDef) LexPattern ¶
func (this *LexIgnoredTokDef) LexPattern() *LexPattern
func (*LexIgnoredTokDef) LexTerminal ¶
func (*LexIgnoredTokDef) LexTerminal() bool
func (*LexIgnoredTokDef) RegDef ¶
func (*LexIgnoredTokDef) RegDef() bool
func (*LexIgnoredTokDef) String ¶
func (this *LexIgnoredTokDef) String() string
func (*LexIgnoredTokDef) Walk ¶
func (this *LexIgnoredTokDef) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexImports ¶
func AddLexImport ¶
func AddLexImport(imports, lexImport interface{}) (*LexImports, error)
func NewLexImports ¶
func NewLexImports(lexImport interface{}) (*LexImports, error)
func (*LexImports) Add ¶
func (this *LexImports) Add(lexImport *LexImport) (*LexImports, error)
Add will return true if a new lex import has been added, otherwise false.
func (LexImports) LexTerminal ¶
func (LexImports) LexTerminal() bool
func (*LexImports) String ¶
func (this *LexImports) String() string
func (*LexImports) Walk ¶
func (this *LexImports) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexNTNode ¶
type LexNTNode interface { LexNode Element(int) LexNode Len() int Walk(LexNodeVisitor) LexNodeVisitor }
type LexNodeVisitor ¶
type LexNodeVisitor interface {
Visit(LexNode) LexNodeVisitor
}
type LexOptPattern ¶
type LexOptPattern struct {
*LexPattern
}
func NewLexOptPattern ¶
func NewLexOptPattern(pattern interface{}) (*LexOptPattern, error)
func (*LexOptPattern) Element ¶
func (this *LexOptPattern) Element(i int) LexNode
func (*LexOptPattern) IsTerminal ¶
func (this *LexOptPattern) IsTerminal() bool
func (*LexOptPattern) Len ¶
func (this *LexOptPattern) Len() int
func (LexOptPattern) LexTerminal ¶
func (LexOptPattern) LexTerminal() bool
func (*LexOptPattern) String ¶
func (this *LexOptPattern) String() string
func (*LexOptPattern) Walk ¶
func (this *LexOptPattern) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexPart ¶
type LexPart struct { Header *FileHeader *LexImports TokDefsList []*LexTokDef TokDefs map[string]*LexTokDef RegDefsList []*LexRegDef RegDefs map[string]*LexRegDef IgnoredTokDefsList []*LexIgnoredTokDef IgnoredTokDefs map[string]*LexIgnoredTokDef ProdList *LexProductions ProdMap *LexProdMap // contains filtered or unexported fields }
All maps are indexed by production id
func NewLexPart ¶
func (*LexPart) ProdIndex ¶
func (this *LexPart) ProdIndex(id string) LexProdIndex
func (*LexPart) Production ¶
func (this *LexPart) Production(id string) LexProduction
func (*LexPart) StringLitTokDef ¶
func (*LexPart) UpdateStringLitTokens ¶
type LexPattern ¶
type LexPattern struct {
Alternatives []*LexAlt
}
func AppendLexAlt ¶
func AppendLexAlt(lexPattern, lexAlt interface{}) (*LexPattern, error)
func NewLexPattern ¶
func NewLexPattern(lexAlt interface{}) (*LexPattern, error)
func (*LexPattern) Element ¶
func (this *LexPattern) Element(i int) LexNode
func (*LexPattern) Len ¶
func (this *LexPattern) Len() int
func (LexPattern) LexTerminal ¶
func (LexPattern) LexTerminal() bool
func (*LexPattern) String ¶
func (this *LexPattern) String() string
func (*LexPattern) Walk ¶
func (this *LexPattern) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexProdIndex ¶
type LexProdIndex int
type LexProdMap ¶
type LexProdMap struct {
// contains filtered or unexported fields
}
func NewLexProdMap ¶
func NewLexProdMap(prodList *LexProductions) *LexProdMap
func (*LexProdMap) Add ¶
func (this *LexProdMap) Add(prods ...LexProduction)
func (*LexProdMap) Id ¶
func (this *LexProdMap) Id(index LexProdIndex) string
func (*LexProdMap) Index ¶
func (this *LexProdMap) Index(id string) LexProdIndex
type LexProduction ¶
type LexProduction interface { LexNode Id() string LexPattern() *LexPattern RegDef() bool }
type LexProductions ¶
type LexProductions struct {
Productions []LexProduction
}
func AppendLexProduction ¶
func AppendLexProduction(lexProds, prod interface{}) (*LexProductions, error)
func NewLexProductions ¶
func NewLexProductions(lexProd interface{}) (*LexProductions, error)
func (LexProductions) LexTerminal ¶
func (LexProductions) LexTerminal() bool
func (*LexProductions) String ¶
func (this *LexProductions) String() string
func (*LexProductions) Walk ¶
func (this *LexProductions) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexRegDef ¶
type LexRegDef struct {
// contains filtered or unexported fields
}
func NewLexRegDef ¶
func (*LexRegDef) LexPattern ¶
func (this *LexRegDef) LexPattern() *LexPattern
func (*LexRegDef) LexTerminal ¶
func (*LexRegDef) Walk ¶
func (this *LexRegDef) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexRegDefId ¶
type LexRegDefId struct {
Id string
}
func NewLexRegDefId ¶
func NewLexRegDefId(regDefId interface{}) (*LexRegDefId, error)
func (*LexRegDefId) IsTerminal ¶
func (this *LexRegDefId) IsTerminal() bool
func (LexRegDefId) LexTerminal ¶
func (LexRegDefId) LexTerminal() bool
func (*LexRegDefId) String ¶
func (this *LexRegDefId) String() string
func (*LexRegDefId) Walk ¶
func (this *LexRegDefId) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexRepPattern ¶
type LexRepPattern struct {
*LexPattern
}
func NewLexRepPattern ¶
func NewLexRepPattern(pattern interface{}) (*LexRepPattern, error)
func (*LexRepPattern) Element ¶
func (this *LexRepPattern) Element(i int) LexNode
func (*LexRepPattern) IsTerminal ¶
func (this *LexRepPattern) IsTerminal() bool
func (*LexRepPattern) Len ¶
func (this *LexRepPattern) Len() int
func (LexRepPattern) LexTerminal ¶
func (LexRepPattern) LexTerminal() bool
func (*LexRepPattern) String ¶
func (this *LexRepPattern) String() string
func (*LexRepPattern) Walk ¶
func (this *LexRepPattern) Walk(visitor LexNodeVisitor) LexNodeVisitor
type LexTokDef ¶
type LexTokDef struct {
// contains filtered or unexported fields
}
func NewLexStringLitTokDef ¶
func NewLexTokDef ¶
func (*LexTokDef) LexPattern ¶
func (this *LexTokDef) LexPattern() *LexPattern
func (*LexTokDef) LexTerminal ¶
func (*LexTokDef) Walk ¶
func (this *LexTokDef) Walk(visitor LexNodeVisitor) LexNodeVisitor
type SyntaxAlts ¶
type SyntaxAlts []*SyntaxBody
func AddSyntaxAlt ¶
func AddSyntaxAlt(alts, body interface{}) (SyntaxAlts, error)
func NewSyntaxAlts ¶
func NewSyntaxAlts(body interface{}) (SyntaxAlts, error)
type SyntaxBody ¶
type SyntaxBody struct { Error bool Symbols SyntaxSymbols SDT string }
func NewEmptyBody ¶
func NewEmptyBody() (*SyntaxBody, error)
func NewErrorBody ¶
func NewErrorBody(symbols, sdtLit interface{}) (*SyntaxBody, error)
func NewSyntaxBody ¶
func NewSyntaxBody(symbols, sdtLit interface{}) (*SyntaxBody, error)
func (*SyntaxBody) Empty ¶
func (this *SyntaxBody) Empty() bool
func (*SyntaxBody) String ¶
func (this *SyntaxBody) String() string
type SyntaxEmpty ¶
type SyntaxEmpty int
const EMPTY SyntaxEmpty = 0
func (SyntaxEmpty) String ¶
func (SyntaxEmpty) String() string
func (SyntaxEmpty) SymbolString ¶
func (SyntaxEmpty) SymbolString() string
type SyntaxError ¶
type SyntaxError int
func (SyntaxError) String ¶
func (SyntaxError) String() string
func (SyntaxError) SymbolString ¶
func (SyntaxError) SymbolString() string
type SyntaxPart ¶
type SyntaxPart struct { Header *FileHeader ProdList SyntaxProdList }
func NewSyntaxPart ¶
func NewSyntaxPart(header, prodList interface{}) (*SyntaxPart, error)
type SyntaxProd ¶
type SyntaxProd struct { Id string Body *SyntaxBody }
func NewSyntaxProd ¶
func NewSyntaxProd(prodId, alts interface{}) ([]*SyntaxProd, error)
func (*SyntaxProd) String ¶
func (this *SyntaxProd) String() string
type SyntaxProdId ¶
type SyntaxProdId string
Id or name of a grammar(syntax) production
func NewSyntaxProdId ¶
func NewSyntaxProdId(tok interface{}) (SyntaxProdId, error)
func (SyntaxProdId) String ¶
func (this SyntaxProdId) String() string
func (SyntaxProdId) SymbolString ¶
func (this SyntaxProdId) SymbolString() string
type SyntaxProdList ¶
type SyntaxProdList []*SyntaxProd
func AddSyntaxProds ¶
func AddSyntaxProds(prodList, prods interface{}) (SyntaxProdList, error)
func NewSyntaxProdList ¶
func NewSyntaxProdList(prods interface{}) (SyntaxProdList, error)
type SyntaxStringLit ¶
type SyntaxStringLit string
func NewStringLit ¶
func NewStringLit(tok interface{}) (SyntaxStringLit, error)
func (SyntaxStringLit) Bytes ¶
func (this SyntaxStringLit) Bytes() []byte
func (SyntaxStringLit) String ¶
func (this SyntaxStringLit) String() string
func (SyntaxStringLit) SymbolString ¶
func (this SyntaxStringLit) SymbolString() string
type SyntaxSymbol ¶
type SyntaxSymbol interface { SymbolString() string String() string // contains filtered or unexported methods }
All syntax symbols are types of string.
type SyntaxSymbols ¶
type SyntaxSymbols []SyntaxSymbol
func AddSyntaxSymbol ¶
func AddSyntaxSymbol(symbols, symbol interface{}) (SyntaxSymbols, error)
func NewSyntaxSymbols ¶
func NewSyntaxSymbols(sym interface{}) (SyntaxSymbols, error)
func (SyntaxSymbols) String ¶
func (this SyntaxSymbols) String() string
type SyntaxTokId ¶
type SyntaxTokId string
func NewTokId ¶
func NewTokId(tokId interface{}) (SyntaxTokId, error)
func (SyntaxTokId) String ¶
func (this SyntaxTokId) String() string
func (SyntaxTokId) SymbolString ¶
func (this SyntaxTokId) SymbolString() string
Source Files ¶
- doc.go
- fileheader.go
- grammar.go
- lexalt.go
- lexcharlit.go
- lexcharrange.go
- lexdot.go
- lexgrouppattern.go
- lexignoredtokdef.go
- leximport.go
- leximports.go
- lexnode.go
- lexnodevisitor.go
- lexnodewalker.go
- lexntnode.go
- lexoptpattern.go
- lexpart.go
- lexpattern.go
- lexprodmap.go
- lexproduction.go
- lexproductions.go
- lexregdef.go
- lexregdefid.go
- lexreppattern.go
- lexterm.go
- lextnode.go
- lextokdef.go
- syntaxalts.go
- syntaxbody.go
- syntaxempty.go
- syntaxeof.go
- syntaxerror.go
- syntaxpart.go
- syntaxprod.go
- syntaxprodid.go
- syntaxprodlist.go
- syntaxstringlit.go
- syntaxsymbol.go
- syntaxsymbols.go
- syntaxtokid.go
Click to show internal directories.
Click to hide internal directories.