parser

package
v0.0.0-...-4ed146b Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package parser implements means to parse ECMAScript code that can be provided by different sources. Subpackages contain a lexer implementation and token types. When creating a parser, a lexer is implicitely created and used.

Package parser implements means to create an AST from a given input source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error represents an error that occurred while parsing. Inside the parser package, an instance of this struct can be panicked. The panic will be recovered from, and will be propagated to outside the package as a common error. If anything else is panicked, the panic will not be recovered from.

func (Error) Error

func (e Error) Error() string

type Parser

type Parser struct {
}

Parser parses ECMAScript code and generates an AST that can be evaluated by the runtime.

func New

func New() *Parser

New creates a new ready to use parser.

func (*Parser) Parse

func (p *Parser) Parse(srcName string, r io.Reader) (*ast.Script, error)

Parse parses frmo the given reader, which will be handled with the given srcName as source name. If this method is used to parse a file, srcName should be the file name.

func (*Parser) ParseFile

func (p *Parser) ParseFile(path string) (*ast.Script, error)

ParseFile parses the given file and returns the resulting AST.

func (*Parser) ParseFiles

func (p *Parser) ParseFiles(paths ...string) (*ast.Script, error)

ParseFiles parses all given files. The file must exist and must be a file (not a directory). Effectively, all files will be parsed with parser.Parser.ParseFile, and the resulting ASTs will be merged.

Directories

Path Synopsis
Code generated by "aststring"; DO NOT EDIT.
Code generated by "aststring"; DO NOT EDIT.
Package matcher implements matchers that efficiently let you determine whether a rune is part of a previously defined rune set.
Package matcher implements matchers that efficiently let you determine whether a rune is part of a previously defined rune set.
Package token contains token types and a token stream implementation that can be used by lexers and parsers.
Package token contains token types and a token stream implementation that can be used by lexers and parsers.

Jump to

Keyboard shortcuts

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