parser

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MPL-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package parser parses Encore applications into an Encore Syntax Tree (EST).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMeta

func ParseMeta(appRevision string, appHasUncommittedChanges bool, appRoot string, app *est.Application, fset *token.FileSet, exp *experiments.Set) (*meta.Data, map[*est.Package]TraceNodes, error)

ParseMeta parses app metadata.

Types

type Config

type Config struct {
	AppRoot                  string
	Experiments              *experiments.Set
	AppRevision              string
	AppHasUncommittedChanges bool
	ModulePath               string
	WorkingDir               string
	ParseTests               bool

	// ScriptMainPkg specifies the relative path to the main package,
	// when running in script mode. It's used to mark that package
	// as a synthetic "main" service.
	ScriptMainPkg string
}

Config represents the configuration options for parsing. TODO(domblack): Remove AppRevision and AppHasUncommittedChanges from here as it's compiler concern not a parser concern

type LiteralStruct added in v1.3.0

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

LiteralStruct represents a struct literal at compile time

func (*LiteralStruct) DynamicFields added in v1.3.0

func (l *LiteralStruct) DynamicFields() map[string]ast.Expr

DynamicFields returns the names of the fields and ast.Expr that are not constant

Child structs will be included with the field name prefixed with the struct name; i.e. `parentField.childField`

func (*LiteralStruct) Expr added in v1.3.0

func (l *LiteralStruct) Expr(fieldName string) ast.Expr

Expr returns ast.Expr for the given field name.

If the field is known, it returns the ast.Expr If the field is not known, it returns nil

You can reference a child struct field with `.`; i.e. `parent.child`

func (*LiteralStruct) FullyConstant added in v1.3.0

func (l *LiteralStruct) FullyConstant() bool

FullyConstant returns true if every value in this struct and the child structs fully known as compile time as a constant value

func (*LiteralStruct) Int64 added in v1.3.0

func (l *LiteralStruct) Int64(fieldName string, defaultValue int64) int64

Int64 returns the value of the field as an int64

This function will convert other number types into an Int64, but will not convert strings. If after conversion the value is 0, the defaultValue will be returned

You can reference a child struct field with `.`; i.e. `parent.child`

func (*LiteralStruct) IsSet added in v1.3.0

func (l *LiteralStruct) IsSet(fieldName string) bool

IsSet returns true if the given field is set in this struct

You can reference a child struct field with `.`; i.e. `parent.child`

func (*LiteralStruct) Lit added in v1.7.0

func (l *LiteralStruct) Lit() *ast.CompositeLit

func (*LiteralStruct) Pos added in v1.3.0

func (l *LiteralStruct) Pos(fieldName string) token.Pos

Pos returns the position of the field in the source code

If the field is not found, the closest position to where the field should have been will be returned

You can reference a child struct field with `.`; i.e. `parent.child`

func (*LiteralStruct) Str added in v1.3.0

func (l *LiteralStruct) Str(fieldName string, defaultValue string) string

Str returns the value of the field as an string

This function will convert all types to a string If after conversion the value is "", the defaultValue will be returned

You can reference a child struct field with `.`; i.e. `parent.child`

func (*LiteralStruct) Value added in v1.3.0

func (l *LiteralStruct) Value(fieldName string) constant.Value

Value returns the value of the field as a constant.Value. If the field is not constant or does not exist, an unknown value will be returned

You can reference a child struct field with `.`; i.e. `parent.child`

type Result

type Result struct {
	FileSet *token.FileSet
	App     *est.Application
	Meta    *meta.Data
	Nodes   map[*est.Package]TraceNodes
}

func Parse

func Parse(cfg *Config) (*Result, error)

type TraceNodes

type TraceNodes map[ast.Node]*meta.TraceNode

Directories

Path Synopsis
Package est provides the Encore Syntax Tree (EST).
Package est provides the Encore Syntax Tree (EST).
Package paths parses API paths.
Package paths parses API paths.

Jump to

Keyboard shortcuts

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