Documentation
¶
Overview ¶
Package parser consumes tokens from the lexer and returns a program as a set of AST-nodes.
Later we walk the AST tree and generate a series of bytecode instructions.
Index ¶
Constants ¶
const ( LOWEST int TERNARY // ? : ASSIGN // = COND // OR or AND EQUALS // == or != CMP LESSGREATER // > or < SUM // + or - PRODUCT // * or / POWER // ** MOD // % PREFIX // -X or !X CALL // myFunction(X) INDEX // array[index], map[key] )
Here we define values for precedence, lowest to highest.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the object which maintains our parser state.
We consume tokens, produced by our lexer, and so we need to keep track of our current token, the next token, and any errors we've seen, for example.
func New ¶
New returns a new parser.
Once constructed it can be used to parse an input-program into an AST.
func (*Parser) Parse ¶ added in v2.1.14
Parse is the main public-facing method to parse an input program.
It will return any error-encountered in parsing the input, but to avoid confusion it will only return the first error.
To access any subsequent errors please see `Errors`.
func (*Parser) ParseProgram ¶
ParseProgram used to parse the whole program