Documentation ¶
Index ¶
- type FileOpener
- type Mode
- type Parser
- func (p *Parser) ClearErrors()
- func (p *Parser) CurrToken() token.Token
- func (p *Parser) Errors() token.ErrorList
- func (p *Parser) Init(file *token.File, src io.Reader, mode Mode, lang config.Lang)
- func (p *Parser) InitParseDir(fset *token.FileSet, opener FileOpener, mode Mode, lang config.Lang) *ast.Dir
- func (p *Parser) InitParseFile(fset *token.FileSet, opener FileOpener, mode Mode, lang config.Lang) *ast.File
- func (p *Parser) InitString(source string, mode Mode, lang config.Lang)
- func (p *Parser) Parse() (node ast.Node)
- func (p *Parser) ParseExpr() ast.Node
- func (p *Parser) ParseFile() *ast.File
- func (p *Parser) ParseStmt() (node ast.Node)
- func (p *Parser) ParseTopLevelDecl() (node ast.Node)
- func (p *Parser) ParseType(isTypeDecl bool) (node ast.Node)
- func (p *Parser) SkipToken() token.Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileOpener ¶
type FileOpener = func() (filename string, src io.ReadCloser)
type Parser ¶
type Parser struct { Mode Mode // Parser Mode is exported Lang config.Lang // Parser Lang is exported // contains filtered or unexported fields }
Go syntax parser. Supports reading from a io.Reader. callers should invoke Init() before any Parse*() method. The only method that clears accumulated errors is ClearErrors()
func (*Parser) Init ¶
initialize parser and read the first non-comment token from src does NOT clear accumulated errors
func (*Parser) InitParseDir ¶
func (p *Parser) InitParseDir(fset *token.FileSet, opener FileOpener, mode Mode, lang config.Lang) *ast.Dir
parse all files in a directory. repeatedly calls Parser.InitParseFile() until opener returns nil. does NOT clear accumulated errors
func (*Parser) InitParseFile ¶
func (p *Parser) InitParseFile(fset *token.FileSet, opener FileOpener, mode Mode, lang config.Lang) *ast.File
open and parse a single file in a directory. calls in sequence: opener(), Parser.Init(), Parser.ParseFile() does NOT clear accumulated errors
func (*Parser) InitString ¶
initialize parser to read from specified string. does NOT clear accumulated errors
func (*Parser) ParseTopLevelDecl ¶
parse a top-level declaration. does NOT consume the following ';' if present