parsing

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseChunk

func ParseChunk(getToken func() *token.Token) (stat ast.BlockStat, err error)

ParseChunk takes in a function that returns tokens and builds a BlockStat for it (or returns an error).

func ParseExp

func ParseExp(getToken func() *token.Token) (exp ast.ExpNode, err error)

ParseExp takes in a function that returns tokens and builds an ExpNode for it (or returns an error).

Types

type Error

type Error struct {
	Got      *token.Token
	Expected string
}

func (Error) Error

func (e Error) Error() string

type Parser

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

Parser can parse lua statements or expressions

func (*Parser) Args

func (p *Parser) Args(t *token.Token) ([]ast.ExpNode, *token.Token)

Args parses the arguments of a function call. It returns nil rather than panicking if it couldn't parse arguments.

func (*Parser) Block

func (p *Parser) Block(t *token.Token) (ast.BlockStat, *token.Token)

Block parses a block whose starting token (e.g. "do") has already been consumed. Returns the token that closes the block (e.g. "end"). So the caller should check that this is the right kind of closing token.

func (*Parser) Exp

func (p *Parser) Exp(t *token.Token) (ast.ExpNode, *token.Token)

Exp parses any expression.

func (*Parser) ExpList

func (p *Parser) ExpList(t *token.Token) ([]ast.ExpNode, *token.Token)

ExpList parses a comma separated list of expressions.

func (*Parser) Field

func (p *Parser) Field(t *token.Token) (ast.TableField, *token.Token)

Field parses a table constructor field.

func (*Parser) For

func (p *Parser) For(t *token.Token) (ast.Stat, *token.Token)

For parses a for in / for = statement. It assumes that t is the "for" token.

func (*Parser) FunctionDef

func (p *Parser) FunctionDef(startTok *token.Token) (ast.Function, *token.Token)

FunctionDef parses a function definition expression.

func (*Parser) FunctionStat

func (p *Parser) FunctionStat(t *token.Token) (ast.Stat, *token.Token)

FunctionStat parses a function definition statement. It assumes that t is the "function" token.

func (*Parser) If

func (p *Parser) If(t *token.Token) (ast.IfStat, *token.Token)

If parses an if / then / else statement. It assumes that t is the "if" token.

func (*Parser) Local

func (p *Parser) Local(t *token.Token) (ast.Stat, *token.Token)

Local parses a "local" statement (function definition of variable declaration). It assumes that t is the "local" token.

func (*Parser) Name

func (p *Parser) Name(t *token.Token) (ast.Name, *token.Token)

Name parses a name.

func (*Parser) PrefixExp

func (p *Parser) PrefixExp(t *token.Token) (ast.ExpNode, *token.Token)

PrefixExp parses an expression made of a name or and expression in brackets followed by zero or more indexing operations or function applications.

func (*Parser) Return

func (p *Parser) Return(t *token.Token) ([]ast.ExpNode, *token.Token)

Return parses a return statement.

func (*Parser) Scan

func (p *Parser) Scan() *token.Token

Scan returns the next token.

func (*Parser) ShortExp

func (p *Parser) ShortExp(t *token.Token) (ast.ExpNode, *token.Token)

ShortExp parses an expression which is either atomic, a unary operation, a prefix expression or a power operation (right associatively composed). In other words, any expression that doesn't contain a binary operator.

func (*Parser) Stat

func (p *Parser) Stat(t *token.Token) (ast.Stat, *token.Token)

Stat parses any statement.

func (*Parser) TableConstructor

func (p *Parser) TableConstructor(opTok *token.Token) (ast.TableConstructor, *token.Token)

TableConstructor parses a table constructor.

Jump to

Keyboard shortcuts

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