Documentation
¶
Index ¶
- type BaseParser
- func (p *BaseParser) Errors() []ParserError
- func (p *BaseParser) ExpectType(expected ...tokens.TokenType) bool
- func (p *BaseParser) HasErrors() bool
- func (p *BaseParser) HasTooManyErrors() bool
- func (p *BaseParser) RegisterError(msg string)
- func (p *BaseParser) RegisterErrorWithToken(msg string, token *tokens.Token)
- type Parser
- type ParserError
- type PrattCurTokenFn
- type PrattInfixFn
- type PrattIsEndOfExprFn
- type PrattParser
- func (p *PrattParser) ParseExpression(precedence int) asts.Node
- func (p *PrattParser) RegisterInfixFn(tokenType tokens.TokenType, fn PrattInfixFn)
- func (p *PrattParser) RegisterPostfixFn(tokenType tokens.TokenType, fn PrattPostfixFn)
- func (p *PrattParser) RegisterPrefixFn(tokenType tokens.TokenType, fn PrattPrefixFn)
- type PrattParserOption
- type PrattPostfixFn
- type PrattPrecedenceFn
- type PrattPrefixFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseParser ¶
type BaseParser struct { MaxErrors int Lexer lexers.Lexer // contains filtered or unexported fields }
func NewBaseParser ¶
func NewBaseParser(lexer lexers.Lexer) *BaseParser
Creates a new parser with the given lexer.
func (*BaseParser) Errors ¶
func (p *BaseParser) Errors() []ParserError
Returns the errors found by the lexer.
func (*BaseParser) ExpectType ¶ added in v0.1.1
func (p *BaseParser) ExpectType(expected ...tokens.TokenType) bool
Checks if the next token is the given types.
func (*BaseParser) HasErrors ¶
func (p *BaseParser) HasErrors() bool
Returns true if the lexer has errors.
func (*BaseParser) HasTooManyErrors ¶
func (p *BaseParser) HasTooManyErrors() bool
Returns true if the lexer has too many errors.
func (*BaseParser) RegisterError ¶ added in v0.1.1
func (p *BaseParser) RegisterError(msg string)
Register an error with the given message.
func (*BaseParser) RegisterErrorWithToken ¶ added in v0.1.1
func (p *BaseParser) RegisterErrorWithToken(msg string, token *tokens.Token)
Register an error with the given message and token.
type Parser ¶
type Parser interface { Errors() []ParserError HasErrors() bool }
type ParserError ¶
func NewParserError ¶ added in v0.2.0
func NewParserError(token *tokens.Token, msg string) ParserError
Creates a new parser error with the given message.
func (ParserError) At ¶
func (e ParserError) At() (line, column int)
Returns the initial position of the error.
func (ParserError) Range ¶ added in v0.2.0
func (e ParserError) Range() (fromLine, fromColumn, toLine, toColumn int)
Returns the range of the error.
type PrattCurTokenFn ¶
type PrattIsEndOfExprFn ¶
type PrattParser ¶
type PrattParser struct { *BaseParser IsEndOfExpr PrattIsEndOfExprFn PrecedenceFn PrattPrecedenceFn // contains filtered or unexported fields }
func NewPrattParser ¶
func NewPrattParser(lexer lexers.Lexer, options ...PrattParserOption) *PrattParser
func (*PrattParser) ParseExpression ¶
func (p *PrattParser) ParseExpression(precedence int) asts.Node
func (*PrattParser) RegisterInfixFn ¶
func (p *PrattParser) RegisterInfixFn(tokenType tokens.TokenType, fn PrattInfixFn)
func (*PrattParser) RegisterPostfixFn ¶
func (p *PrattParser) RegisterPostfixFn(tokenType tokens.TokenType, fn PrattPostfixFn)
func (*PrattParser) RegisterPrefixFn ¶
func (p *PrattParser) RegisterPrefixFn(tokenType tokens.TokenType, fn PrattPrefixFn)
type PrattParserOption ¶
type PrattParserOption func(*PrattParser)
type PrattPostfixFn ¶
type PrattPrecedenceFn ¶
type PrattPrefixFn ¶
Click to show internal directories.
Click to hide internal directories.