parser

package
v0.0.0-...-017d103 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Overview

This file contains the exported entry points for invoking the parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseExpr

func ParseExpr(str string) (ast.Expr, error)

func ParseFile

func ParseFile(fset *gotok.FileSet, filename string, src interface{}, mode Mode) (f *ast.File, err error)

ParseFile parses the source code of a single bibtex source file and returns the corresponding ast.File node. The source code may be provided via the filename of the source file, or via the src parameter.

If src != nil, ParseFile parses the source from src and the filename is only used when recording position information. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, ParseFile parses the file specified by filename.

The mode parameter controls the amount of source text parsed and other optional parser functionality. Position information is recorded in the file set fset, which must not be nil.

If the source couldn't be read, the returned AST is nil and the error indicates the specific failure. If the source was read but syntax errors were found, the result is a partial AST (with ast.Bad* nodes representing the fragments of erroneous source code). Multiple errors are returned via a scanner.ErrorList which is sorted by source position.

func ParsePackage

func ParsePackage(paths []string, mode Mode) (pkg *ast.Package, first error)

ParsePackage calls ParseFile for all files specified by paths.

The mode bits are passed to ParseFile unchanged.

If a parse error occurred, an incomplete package and the first error encountered are returned.

Types

type Mode

type Mode uint

A Mode value is a set of flags (or 0). They control the amount of source code parsed and other optional parser functionality.

const (
	ParseComments     Mode = 1 << iota // parse comments and add them to AST
	ParseStrings                       // parse contents of strings, "{F}oo{"}"
	Trace                              // print a trace of parsed productions
	DeclarationErrors                  // report declaration errors
	AllErrors                          // report all errors (not just the first 10 on different lines)
)

Jump to

Keyboard shortcuts

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