parser

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: MIT Imports: 5 Imported by: 16

Documentation

Index

Constants

View Source
const (
	LOWEST int
	NORMAL
	LOGIC
	RANGE
	EQUALS
	COMPARE
	ASSIGN
	SUM
	PRODUCT
	PREFIX
	INDEX
	CALL
)

Constants for denoting precedence

View Source
const (

	// EndOfFileError represents normal EOF error
	EndOfFileError int
	// WrongTokenError means that token is not what we expected
	WrongTokenError
	// UnexpectedTokenError means that token is not expected to appear in current condition
	UnexpectedTokenError
	// UnexpectedEndError means we get unexpected "end" keyword (this is mainly created for REPL)
	UnexpectedEndError
)

Variables

This section is empty.

Functions

func BuildAST

func BuildAST(file []byte) *ast.Program

BuildAST tokenizes and parses given file to build AST

Types

type Error

type Error struct {
	// Message contains the readable message of error
	Message string
	// contains filtered or unexported fields
}

Error represents parser's parsing error

func (*Error) IsEOF

func (e *Error) IsEOF() bool

IsEOF checks if error is end of file error

func (*Error) IsUnexpectedEnd

func (e *Error) IsUnexpectedEnd() bool

IsUnexpectedEnd checks if error is unexpected "end" keyword error

type Parser

type Parser struct {
	Lexer *lexer.Lexer
	// contains filtered or unexported fields
}

Parser represents lexical analyzer struct

func New

func New(l *lexer.Lexer) *Parser

New initializes a parser and returns it

func (*Parser) ParseProgram

func (p *Parser) ParseProgram() (*ast.Program, *Error)

ParseProgram update program statements and return program

Jump to

Keyboard shortcuts

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