parser

package
v0.0.0-...-e334538 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message    string
	Start, End token.Position
}

An Error represents a parsing error. Contains a message and two positions for the start and end of the error.

func (*Error) Error

func (e *Error) Error() string

Error returns a string representation of an Error, to comply with the error interface.

type Parser

type Parser struct {
	// Errors contains any errors encountered during parsing.
	Errors []error
	// contains filtered or unexported fields
}

A Parser takes a token generator function and parses it into an AST.

func New

func New(lex func() token.Token) *Parser

New creates a new parser for the given token generator function.

func (*Parser) Parse

func (p *Parser) Parse() (*ast.Program, error)

Parse parses an entire program into an `ast.Program`. Also, returns the first error encountered, if any.

Jump to

Keyboard shortcuts

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