parser

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package parser translates the linear stream of tokens into ast structures based on the syntax of the ok language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Errors added in v0.17.6

type Errors []error

Errors is a collection of errors.

func (Errors) String added in v0.17.6

func (errs Errors) String() string

type File

type File struct {
	Funcs    map[string]*ast.Func
	Tests    []*ast.Test
	Imports  map[string]string
	Comments []*ast.Comment
	Tokens   []lexer.Token
}

File contains the output state of the parser for a single input.

func (*File) Pos added in v0.13.1

func (file *File) Pos(offset int) string

Pos returns the rendered position of a token.

type Parser

type Parser struct {
	File *File

	Interfaces map[string]map[string]string

	// Constants are variables defined at the package level. They cannot be
	// modified and only allow literals for values.
	//
	// TODO(elliot): We should allow for expressions that can be resolved at
	//  compile time, such as "3600 * 24".
	Constants map[string]*ast.Literal
	// contains filtered or unexported fields
}

func ParseString

func ParseString(s string, fileName string) *Parser

ParseString parses source code and returns the AST for the file.

func (*Parser) AppendError added in v0.13.1

func (p *Parser) AppendError(node ast.Node, message string)

AppendError adds an error to the stack.

func (*Parser) AppendErrorAt added in v0.13.1

func (p *Parser) AppendErrorAt(pos string, message string)

AppendError adds an error to the stack.

func (*Parser) AppendErrorf added in v0.13.1

func (p *Parser) AppendErrorf(node ast.Node, format string, args ...interface{})

AppendErrorf adds an error to the stack.

func (*Parser) AppendFinally added in v0.15.3

func (p *Parser) AppendFinally(finally *ast.Finally)

AppendFinally will track finalizers until the function is finished, then it will be reset.

func (*Parser) Errors

func (p *Parser) Errors() Errors

Errors returns all errors.

func (*Parser) NextFunctionName added in v0.17.0

func (p *Parser) NextFunctionName() string

NextFunctionName returns a unique name to be used internally for anonymous functions.

Jump to

Keyboard shortcuts

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