parser

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignDocStrings

func AssignDocStrings(mod *ast.Module)

AssignDocStrings assigns the comment group immediately before a function declaration as the function's doc string.

func ExpandHomeDir

func ExpandHomeDir(path string) (string, error)

ExpandHomeDir expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func FormatPos

func FormatPos(pos lexer.Position) string

FormatPos returns a lexer.Position formatted as a string.

func NewLocalDirectory

func NewLocalDirectory(root string, dgst digest.Digest) ast.Directory

NewLocalDirectory returns an ast.Directory representing a directory on the local system. It is also used to abstract the difference between reading remote modules that has been vendored.

func Parse

func Parse(ctx context.Context, r io.Reader, opts ...filebuffer.Option) (*ast.Module, error)

func ParseMultiple

func ParseMultiple(ctx context.Context, rs []io.Reader) ([]*ast.Module, error)

func ResolvePath

func ResolvePath(root, path string) (string, error)

ResolvePath resolves the path relative to root, and expands `~` to the user's home directory.

Types

type NamedReader

type NamedReader struct {
	io.Reader
	Value string
}

func (NamedReader) Close

func (nr NamedReader) Close() error

func (*NamedReader) Name

func (nr *NamedReader) Name() string

type NewlinedReader

type NewlinedReader struct {
	io.Reader
	// contains filtered or unexported fields
}

NewlinedReader appends one more newline after an EOF is reached, so that parsing is made easier when inputs that don't end with a newline.

func (*NewlinedReader) Read

func (nr *NewlinedReader) Read(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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