parser

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 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 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
	// 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() []error

Errors returns all errors.

Jump to

Keyboard shortcuts

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