parser

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOWEST int
	NORMAL
	ASSIGN
	LOGIC
	RANGE
	EQUALS
	COMPARE
	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
	// MethodDefinitionError means there's an error on method definition's method name
	MethodDefinitionError
	// InvalidAssignmentError means user assigns value to wrong type of expressions
	InvalidAssignmentError
	// SyntaxError means there's a grammatical in the source code
	SyntaxError
)
View Source
const (
	NormalMode int = iota
	REPLMode
	TestMode
)

These are the enums for marking parser's mode, which decides whether it should pop unused values.

Variables

This section is empty.

Functions

This section is empty.

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

	Mode int
	// 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