parser

package
v0.0.0-...-bf9f4d5 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parser contains the definition of the parser element of the glif interpreter.

If also declare the following:

  • Precedence constants
  • map of token/precedence
  • prefix and infix functions
  • parsing method for recognize tokens

Index

Constants

View Source
const (
	LOWEST      int
	TO          // ->
	EQUALS      // ==
	LESSGREATER // < or >
	SUM         // +
	PRODUCT     // *
	PREFIX      // -X or !X
	CALL        // myFunction(X)
	INDEX       // array[index]
)

Contant used in the precedence parsing for operator

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

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

Parser is the representation of the glif parser It contains the following:

  • A slice of errors (parsing error)
  • The current token AND the next (peek) token
  • Maps containing the prefix AND infix parse functions

func New

func New(l *lexer.Lexer) *Parser

New creates a new parser from a lexer and register the prefix/infix parsing functions

func NewWithOptions

func NewWithOptions(l *lexer.Lexer, showTrace bool) *Parser

NewWithOptions creates a new parser from a lexer and additionnal bool options The creation of the parser is done via the New function and not directly here, that way there is only one place where the parser is instantiated.

func (*Parser) Errors

func (p *Parser) Errors() []string

Errors returns the errors found (if any) while parsing

func (*Parser) ParseProgram

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

ParseProgram is the entry point of the parser. It returns the *ast.Program node which represents the entire script.

Jump to

Keyboard shortcuts

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