Documentation ¶
Index ¶
- Variables
- func IsIntersect(start, end lexer.Position, line, column int) bool
- func IsPositionWithinNode(node Node, line, column int) bool
- func Match(root Node, opts MatchOpts, funs ...interface{})
- func StopNodeFilter(n Node) bool
- func Walk(node Node, v Visitor)
- func WithModules(ctx context.Context, mods *ModuleLookup) context.Context
- type As
- type Backtick
- type BasicLit
- type Bind
- type BindClause
- type BindList
- type BindStmt
- type Binding
- type Binds
- type BlockStmt
- type BuiltinDecl
- type CallExpr
- type CallNode
- type CallStmt
- type CloseBrace
- type CloseParen
- type Comment
- type CommentGroup
- type Decl
- type DeprecatedImportDecl
- type Directory
- type EffectsClause
- type Export
- type ExportDecl
- type Expr
- type ExprField
- type ExprList
- type ExprStmt
- type Field
- type FieldList
- type FieldStmt
- type From
- type FuncDecl
- type FuncLit
- type FuncSignature
- type Heredoc
- type HeredocEnd
- type HeredocFragment
- type Ident
- type IdentExpr
- type Import
- type ImportDecl
- type ImportFunc
- type ImportPath
- type Interpolated
- type Introspector
- type Kind
- type KindSet
- type MatchOpts
- type Mixin
- func (m Mixin) End() lexer.Position
- func (m Mixin) Position() lexer.Position
- func (m Mixin) Spanf(t diagnostic.Type, format string, a ...interface{}) diagnostic.Option
- func (m Mixin) String() string
- func (m Mixin) Unparse(opts ...UnparseOption) string
- func (m Mixin) WithError(err error, opts ...diagnostic.Option) error
- type Modifier
- type Module
- type ModuleLookup
- type Newline
- type Node
- type NumericLit
- type ObjKind
- type Object
- type OpenBrace
- type OpenInterpolated
- type OpenParen
- type Quote
- type RawHeredoc
- type RawStringLit
- type Reference
- type Scope
- func (s *Scope) ByLevel(level ScopeLevel) *Scope
- func (s *Scope) Depth() int
- func (s *Scope) Identifiers(kset *KindSet) (idents []string)
- func (s *Scope) Insert(obj *Object)
- func (s *Scope) Locals() []*Object
- func (s *Scope) Lookup(name string) *Object
- func (s *Scope) Suggestion(name string, kset *KindSet) *Object
- type ScopeLevel
- type SearchOption
- type Stmt
- type StmtEnd
- type StopNode
- type StringFragment
- type StringLit
- type Type
- type UnparseInfo
- type UnparseOption
- type Variadic
- type Visitor
- type With
- type WithClause
Constants ¶
This section is empty.
Variables ¶
var ( // Lexer lexes HLB into tokens for the parser. Lexer = lexer.MustStateful(lexer.Rules{ "Root": { {"Keyword", `\b(import|export|with|as)\b`, nil}, {"Numeric", `\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b`, nil}, {"Decimal", `\b(0|[1-9][0-9]*)\b`, nil}, {"Bool", `\b(true|false)\b`, nil}, {"String", `"`, lexer.Push("String")}, {"RawString", "`", lexer.Push("RawString")}, {"Heredoc", `<<[-~]?(\w+)\b`, lexer.Push("Heredoc")}, {"RawHeredoc", "<<[-~]?`(\\w+)`", lexer.Push("RawHeredoc")}, {"Block", `{`, lexer.Push("Block")}, {"Paren", `\(`, lexer.Push("Paren")}, {"Ident", `[\w:]+`, lexer.Push("Reference")}, {"Operator", `;`, nil}, {"Newline", `\n`, nil}, {"Comment", `#[^\n]*\n`, nil}, {"Whitespace", `[\r\t ]+`, nil}, }, "Reference": { {"Dot", `\.`, nil}, {"Ident", `[\w:]+`, nil}, lexer.Return(), }, "String": { {"StringEnd", `"`, lexer.Pop()}, {"Escaped", `\\.`, nil}, {"Interpolated", `\${`, lexer.Push("Interpolated")}, {"Char", `\$|[^"$\\]+`, nil}, }, "RawString": { {"RawStringEnd", "`", lexer.Pop()}, {"RawChar", "[^`]+", nil}, }, "Heredoc": { {"HeredocEnd", `\b\1\b`, lexer.Pop()}, {"Spaces", `\s+`, nil}, {"Escaped", `\\.`, nil}, {"Interpolated", `\${`, lexer.Push("Interpolated")}, {"Text", `\$|[^\s$]+`, nil}, }, "RawHeredoc": { {"RawHeredocEnd", `\b\1\b`, lexer.Pop()}, {"Spaces", `\s+`, nil}, {"RawText", `[^\s]+`, nil}, }, "Interpolated": { {"BlockEnd", `}`, lexer.Pop()}, lexer.Include("Root"), }, "Block": { {"BlockEnd", `}`, lexer.Pop()}, lexer.Include("Root"), }, "Paren": { {"ParenEnd", `\)`, lexer.Pop()}, {"Delimit", `,`, nil}, lexer.Include("Root"), }, }) // Parser parses HLB into a concrete syntax tree rooted from a Module. Parser = participle.MustBuild( &Module{}, participle.Lexer(Lexer), participle.Elide("Whitespace"), ) )
Functions ¶
func IsIntersect ¶
IsIntersect returns true if a line column is within a start and end position.
func IsPositionWithinNode ¶
IsPositionWithinNode returns true if a line column is within a node's position.
func Match ¶
Match walks a CST and invokes given functions if their arguments match a non-contiguous sequence of current path walked. This is useful when you want to walk to a specific type of Node, while having access to specific parents of the Node.
The function arguments must all implement the Node interface, and may be a non-contiguous sequence. That is, you don't have to specify every CST structure.
The sequence is matched right to left, from the deepest node first. The final argument will always be the current node being visited.
When multiple functions are matched, they are invoked in the order given to Match. That way, you can write functions that positively match, and then provide a more general function as a catch all without walking the CST a second time.
For example, you can invoke Match to find CallStmts inside FuncLits: ```go Match(root, MatchOpts{},
func(lit *FuncLit, call *CallStmt) { fmt.Println(lit.Pos, call.Pos) },
) ```
func StopNodeFilter ¶
StopNodeFilter returns true if Node n is a StopNode.
func Walk ¶
Walk traverses an CST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).
func WithModules ¶
func WithModules(ctx context.Context, mods *ModuleLookup) context.Context
Types ¶
type As ¶
As represents the keyword "as".
func (*As) Unparse ¶
func (a *As) Unparse(opts ...UnparseOption) string
type Backtick ¶
Backtick represents the "`" backtick.
func (*Backtick) Unparse ¶
func (b *Backtick) Unparse(opts ...UnparseOption) string
type BasicLit ¶
type BasicLit struct { Mixin Decimal *int `parser:"( @Decimal"` Numeric *NumericLit `parser:"| @Numeric"` Bool *bool `parser:"| @Bool"` Str *StringLit `parser:"| @@"` RawString *RawStringLit `parser:"| @@"` Heredoc *Heredoc `parser:"| @@"` RawHeredoc *RawHeredoc `parser:"| @@ )"` }
BasicLit represents a literal of basic type.
func (*BasicLit) Unparse ¶
func (bl *BasicLit) Unparse(opts ...UnparseOption) string
type Bind ¶
Bind represents the binding of a CallStmt's side effect Source to the identifier Target.
func (*Bind) Unparse ¶
func (b *Bind) Unparse(opts ...UnparseOption) string
type BindClause ¶
type BindClause struct { Mixin Closure *FuncDecl Effects *FieldList As *As `parser:"@@"` Ident *Ident `parser:"( @@"` Binds *BindList `parser:"| @@ )?"` }
BindClause represents the entire "as ..." clause on a CallStmt, with either a default side effect or a list of Binds.
func (*BindClause) SourceBinding ¶
func (bc *BindClause) SourceBinding(source string) *Binding
func (*BindClause) String ¶
func (bc *BindClause) String() string
func (*BindClause) TargetBinding ¶
func (bc *BindClause) TargetBinding(target string) *Binding
func (*BindClause) Unparse ¶
func (bc *BindClause) Unparse(opts ...UnparseOption) string
type BindList ¶
type BindList struct { Mixin Start *OpenParen `parser:"@@"` Stmts []*BindStmt `parser:"@@*"` Terminate *CloseParen `parser:"@@"` }
BindList is a parenthetical list of Binds.
func (*BindList) Unparse ¶
func (bl *BindList) Unparse(opts ...UnparseOption) string
type BindStmt ¶
type BindStmt struct { Mixin Bind *Bind `parser:"( @@ Delimit?"` Newline *Newline `parser:"| @@"` Comments *CommentGroup `parser:"| @@ )"` }
BindStmt represents a statement in list of binds.
func (*BindStmt) Unparse ¶
func (bs *BindStmt) Unparse(opts ...UnparseOption) string
type Binding ¶
type Binding struct { Name *Ident Bind *BindClause Field *Field }
Binding is a value type that represents the call site where a single side effect is bound.
type Binds ¶
Binds represents the keyword "binds".
func (*Binds) Unparse ¶
func (b *Binds) Unparse(opts ...UnparseOption) string
type BlockStmt ¶
type BlockStmt struct { Mixin Scope *Scope Type *Type Closure *FuncDecl Start *OpenBrace `parser:"@@"` List []*Stmt `parser:"@@*"` Terminate *CloseBrace `parser:"@@"` }
BlockStmt represents a braced statement list.
func NewBlockStmt ¶
func (*BlockStmt) Unparse ¶
func (bs *BlockStmt) Unparse(opts ...UnparseOption) string
type BuiltinDecl ¶
BuiltinDecl is a synthetic declaration representing a builtin name. Special type checking rules apply to builtins.
func (*BuiltinDecl) FuncDecl ¶
func (bd *BuiltinDecl) FuncDecl(kind Kind) *FuncDecl
func (*BuiltinDecl) String ¶
func (bd *BuiltinDecl) String() string
func (*BuiltinDecl) Unparse ¶
func (bd *BuiltinDecl) Unparse(opts ...UnparseOption) string
type CallExpr ¶
type CallExpr struct { Mixin Sig []Kind Name *IdentExpr `parser:"@@"` List *ExprList `parser:"@@?"` }
CallExpr represents a short-hand way of invoking a function as an expression.
func (*CallExpr) Breakpoint ¶
func (*CallExpr) Unparse ¶
func (ce *CallExpr) Unparse(opts ...UnparseOption) string
type CallStmt ¶
type CallStmt struct { Mixin Doc *CommentGroup Sig []Kind Name *IdentExpr `parser:"@@"` Args []*Expr `parser:"@@*"` WithClause *WithClause `parser:"@@?"` BindClause *BindClause `parser:"@@?"` Terminate *StmtEnd `parser:"@@?"` }
CallStmt represents an function name followed by an argument list, and an optional WithClause.
func (*CallStmt) Breakpoint ¶
func (*CallStmt) Unparse ¶
func (cs *CallStmt) Unparse(opts ...UnparseOption) string
type CloseBrace ¶
CloseBrace represents the "}" brace.
type CloseParen ¶
CloseParent represents the ")" parenthese.
type Comment ¶
Comment represents a single comment.
func (*Comment) Unparse ¶
func (c *Comment) Unparse(opts ...UnparseOption) string
type CommentGroup ¶
CommentGroup represents a sequence of comments with no other tokens and no empty lines between.
func (*CommentGroup) NumComments ¶
func (g *CommentGroup) NumComments() int
NumComments returns the number of comments in CommentGroup.
func (*CommentGroup) String ¶
func (cg *CommentGroup) String() string
func (*CommentGroup) Unparse ¶
func (cg *CommentGroup) Unparse(opts ...UnparseOption) string
type Decl ¶
type Decl struct { Mixin Import *ImportDecl `parser:"( @@"` Export *ExportDecl `parser:"| @@"` Func *FuncDecl `parser:"| @@"` Newline *Newline `parser:"| @@"` Comments *CommentGroup `parser:"| @@ )"` }
Decl represents a declaration node.
func (*Decl) Unparse ¶
func (d *Decl) Unparse(opts ...UnparseOption) string
type DeprecatedImportDecl ¶
type DeprecatedImportDecl struct { Pos lexer.Position Import *Import `parser:"@@"` Ident *Ident `parser:"@@"` ImportFunc *ImportFunc `parser:"( @@"` ImportPath *ImportPath `parser:"| @@ )"` }
DeprecatedImportDecl represents an import declaration.
func (*DeprecatedImportDecl) End ¶
func (d *DeprecatedImportDecl) End() lexer.Position
func (*DeprecatedImportDecl) Position ¶
func (d *DeprecatedImportDecl) Position() lexer.Position
type Directory ¶
type Directory interface { Path() string Digest() digest.Digest Definition() *llb.Definition Open(filename string) (io.ReadCloser, error) Stat(filename string) (os.FileInfo, error) Close() error }
Directory represents the abstract directory that modules can be read from. The directory can be a local path or the filesystem of a remote import.
type EffectsClause ¶
EffectsClause represents the side effect "binds ..." clause for a function.
func NewEffectsClause ¶
func NewEffectsClause(effect ...*Field) *EffectsClause
func (*EffectsClause) String ¶
func (ec *EffectsClause) String() string
func (*EffectsClause) Unparse ¶
func (ec *EffectsClause) Unparse(opts ...UnparseOption) string
type Export ¶
Export represents the keyword "export".
func (*Export) Unparse ¶
func (e *Export) Unparse(opts ...UnparseOption) string
type ExportDecl ¶
ExportDecl represents an export declaration.
func (*ExportDecl) String ¶
func (ed *ExportDecl) String() string
func (*ExportDecl) Unparse ¶
func (ed *ExportDecl) Unparse(opts ...UnparseOption) string
type Expr ¶
type Expr struct { Mixin FuncLit *FuncLit `parser:"( @@"` BasicLit *BasicLit `parser:"| @@"` CallExpr *CallExpr `parser:"| @@ )"` }
Expr represents an expression node.
func NewBoolExpr ¶
func NewDecimalExpr ¶
func NewFuncLitExpr ¶
func NewNumericExpr ¶
func NewStringExpr ¶
func (*Expr) Unparse ¶
func (e *Expr) Unparse(opts ...UnparseOption) string
type ExprField ¶
type ExprField struct { Mixin Expr *Expr `parser:"( @@ Delimit?"` Newline *Newline `parser:"| @@"` Comments *CommentGroup `parser:"| @@ )"` }
ExprField represents a statement in a list of expressions.
func (*ExprField) Unparse ¶
func (ef *ExprField) Unparse(opts ...UnparseOption) string
type ExprList ¶
type ExprList struct { Mixin Start *OpenParen `parser:"@@"` Fields []*ExprField `parser:"@@*"` Terminate *CloseParen `parser:"@@"` }
ExprList represents a list of expressions enclosed in parentheses.
func (*ExprList) Unparse ¶
func (el *ExprList) Unparse(opts ...UnparseOption) string
type ExprStmt ¶
ExprStmt represents a statement returning an expression.
func (*ExprStmt) Unparse ¶
func (es *ExprStmt) Unparse(opts ...UnparseOption) string
type Field ¶
type Field struct { Mixin Modifier *Modifier `parser:"@@?"` Type *Type `parser:"@@"` Name *Ident `parser:"@@"` }
Field represents a parameter declaration in a signature.
func (*Field) Unparse ¶
func (f *Field) Unparse(opts ...UnparseOption) string
type FieldList ¶
type FieldList struct { Mixin Start *OpenParen `parser:"@@"` Stmts []*FieldStmt `parser:"@@*"` Terminate *CloseParen `parser:"@@"` }
FieldList represents a list of Fields, enclosed by parentheses.
func NewFieldList ¶
func (*FieldList) Unparse ¶
func (fl *FieldList) Unparse(opts ...UnparseOption) string
type FieldStmt ¶
type FieldStmt struct { Mixin Field *Field `parser:"( @@ Delimit?"` Newline *Newline `parser:"| @@"` Comments *CommentGroup `parser:"| @@ )"` }
FieldStmt represents a statement in a list of fields.
func (*FieldStmt) Unparse ¶
func (fs *FieldStmt) Unparse(opts ...UnparseOption) string
type From ¶
From represents the keyword "from".
func (*From) Unparse ¶
func (f *From) Unparse(opts ...UnparseOption) string
type FuncDecl ¶
type FuncDecl struct { Mixin Scope *Scope Doc *CommentGroup Sig *FuncSignature `parser:"@@"` Body *BlockStmt `parser:"@@?"` }
FuncDecl represents a function declaration.
func (*FuncDecl) Unparse ¶
func (fd *FuncDecl) Unparse(opts ...UnparseOption) string
type FuncLit ¶
FuncLit represents a literal block prefixed by its type. If the type is missing then it's assumed to be a fs block literal.
func NewFuncLit ¶
func (*FuncLit) Unparse ¶
func (fl *FuncLit) Unparse(opts ...UnparseOption) string
type FuncSignature ¶
type FuncSignature struct { Mixin Type *Type `parser:"@@"` Name *Ident `parser:"@@"` Params *FieldList `parser:"@@"` Effects *EffectsClause `parser:"@@?"` }
FuncSignature represents a function signature.
func (*FuncSignature) Kind ¶
func (fs *FuncSignature) Kind() Kind
func (*FuncSignature) String ¶
func (fs *FuncSignature) String() string
func (*FuncSignature) Subject ¶
func (fs *FuncSignature) Subject() Node
func (*FuncSignature) Unparse ¶
func (fs *FuncSignature) Unparse(opts ...UnparseOption) string
type Heredoc ¶
type Heredoc struct { Mixin Value string Start string `parser:"@Heredoc"` Fragments []*HeredocFragment `parser:"@@*"` Terminate *HeredocEnd `parser:"@@"` }
Heredoc represents a multiline heredoc type that supports string interpolation.
func (*Heredoc) Unparse ¶
func (h *Heredoc) Unparse(opts ...UnparseOption) string
type HeredocEnd ¶
HeredocEnd represents the same identifier used to begin the heredoc block.
func (*HeredocEnd) String ¶
func (he *HeredocEnd) String() string
func (*HeredocEnd) Unparse ¶
func (he *HeredocEnd) Unparse(opts ...UnparseOption) string
type HeredocFragment ¶
type HeredocFragment struct { Mixin Spaces *string `parser:"( @Spaces"` Escaped *string `parser:"| @Escaped"` Interpolated *Interpolated `parser:"| @@"` Text *string `parser:"| @(Text | RawText) )"` }
HeredocFragment represents a piece of a heredoc.
func (*HeredocFragment) String ¶
func (hf *HeredocFragment) String() string
func (*HeredocFragment) Unparse ¶
func (hf *HeredocFragment) Unparse(opts ...UnparseOption) string
type Ident ¶
Ident represents an identifier.
func (*Ident) Unparse ¶
func (i *Ident) Unparse(opts ...UnparseOption) string
type IdentExpr ¶
IdentExpr represents an identifier that may be referencing an identifier from an imported module.
func NewIdentExpr ¶
func (*IdentExpr) Unparse ¶
func (ie *IdentExpr) Unparse(opts ...UnparseOption) string
type Import ¶
Import represents the keyword "import".
func (*Import) Unparse ¶
func (i *Import) Unparse(opts ...UnparseOption) string
type ImportDecl ¶
type ImportDecl struct { Mixin Import *Import `parser:"@@"` Name *Ident `parser:"@@"` DeprecatedPath *StringLit `parser:"( @@"` From *From `parser:"| @@"` Expr *Expr `parser:"@@ )"` }
ImportDecl represents an import declaration.
func (*ImportDecl) String ¶
func (id *ImportDecl) String() string
func (*ImportDecl) Unparse ¶
func (id *ImportDecl) Unparse(opts ...UnparseOption) string
type ImportFunc ¶
Import represents the function for a remote import.
func (*ImportFunc) End ¶
func (i *ImportFunc) End() lexer.Position
func (*ImportFunc) Position ¶
func (i *ImportFunc) Position() lexer.Position
type ImportPath ¶
ImportPath represents the relative path to a local import.
func (*ImportPath) End ¶
func (i *ImportPath) End() lexer.Position
func (*ImportPath) Position ¶
func (i *ImportPath) Position() lexer.Position
type Interpolated ¶
type Interpolated struct { Mixin Start *OpenInterpolated `parser:"@@"` Expr *Expr `parser:"@@?"` Terminate *CloseBrace `parser:"@@"` }
Interpolated represents an interpolated expression in a string or heredoc fragment.
func (*Interpolated) String ¶
func (i *Interpolated) String() string
func (*Interpolated) Unparse ¶
func (i *Interpolated) Unparse(opts ...UnparseOption) string
type Introspector ¶
type Introspector interface { // Path returns the full CST path including the current node. Path() []Node }
Introspector provides methods for visitors introspect the current node.
type MatchOpts ¶
type MatchOpts struct { // Filter is called to see if the node should be walked. If nil, then all // nodes are walked. Filter func(Node) bool // AllowDuplicates is enabled to allow duplicate CST structures between // arguments in the functions provided. // // For example, if a function is defined as `func(*FuncDecl, *CallStmt)` // sequences like `[*FuncDecl, ..., *CallStmt, ..., *CallStmt]` are not // matched by default. Allowing duplicates will match instead. AllowDuplicates bool }
MatchOpts provides options while walking the CST.
type Mixin ¶
func (Mixin) Spanf ¶
func (m Mixin) Spanf(t diagnostic.Type, format string, a ...interface{}) diagnostic.Option
func (Mixin) Unparse ¶
func (m Mixin) Unparse(opts ...UnparseOption) string
type Modifier ¶
Modifier represents a term to modify the behaviour of a field.
func (*Modifier) Unparse ¶
func (m *Modifier) Unparse(opts ...UnparseOption) string
type Module ¶
type Module struct { Mixin Scope *Scope Directory Directory URI string Doc *CommentGroup Decls []*Decl `parser:"@@*"` }
Module represents a HLB source file. HLB is file-scoped, so every file represents a module.
Initially, the Parser will fill in this struct as a parse tree / concrete syntax tree, but a second pass from the Checker will type check and fill in fields without parser struct tags like scopes and doc linking.
func (*Module) Unparse ¶
func (m *Module) Unparse(opts ...UnparseOption) string
type ModuleLookup ¶
type ModuleLookup struct {
// contains filtered or unexported fields
}
func Modules ¶
func Modules(ctx context.Context) *ModuleLookup
func NewModules ¶
func NewModules() *ModuleLookup
func (*ModuleLookup) Get ¶
func (ml *ModuleLookup) Get(filename string) *Module
func (*ModuleLookup) Set ¶
func (ml *ModuleLookup) Set(filename string, mod *Module)
type Newline ¶
Newline represents the "\n" newline.
func (*Newline) Unparse ¶
func (n *Newline) Unparse(opts ...UnparseOption) string
type Node ¶
type Node interface { // Stringer is implemented to unparse a node back into formatted HLB. fmt.Stringer Unparse(opts ...UnparseOption) string // Position returns position of the first character belonging to the node. Position() lexer.Position // End returns position of the first character immediately after the node. End() lexer.Position // WithError returns an error decorated with diagnostics for the node. WithError(err error, opts ...diagnostic.Option) error // Spanf returns an annotation for the node. Spanf(t diagnostic.Type, format string, a ...interface{}) diagnostic.Option }
Node is implemented by all nodes in the CST.
type NumericLit ¶
NumericLit represents a number literal with a non-decimal base.
func (*NumericLit) Capture ¶
func (nl *NumericLit) Capture(tokens []string) error
func (*NumericLit) End ¶
func (nl *NumericLit) End() lexer.Position
func (*NumericLit) Position ¶
func (nl *NumericLit) Position() lexer.Position
func (*NumericLit) String ¶
func (nl *NumericLit) String() string
func (*NumericLit) Unparse ¶
func (nl *NumericLit) Unparse(opts ...UnparseOption) string
type OpenInterpolated ¶
OpenInterpolated represents the "${" dollar brace of a interpolated expression.
func (*OpenInterpolated) String ¶
func (oi *OpenInterpolated) String() string
func (*OpenInterpolated) Unparse ¶
func (oi *OpenInterpolated) Unparse(opts ...UnparseOption) string
type Quote ¶
Quote represents the `"` double quote.
func (*Quote) Unparse ¶
func (q *Quote) Unparse(opts ...UnparseOption) string
type RawHeredoc ¶
type RawHeredoc struct { Mixin Start string `parser:"@RawHeredoc"` Fragments []*HeredocFragment `parser:"@@*"` Terminate *HeredocEnd `parser:"@@"` }
RawHeredoc represents a heredoc with no string interpolation.
func (*RawHeredoc) String ¶
func (rh *RawHeredoc) String() string
func (*RawHeredoc) Unparse ¶
func (rh *RawHeredoc) Unparse(opts ...UnparseOption) string
type RawStringLit ¶
type RawStringLit struct { Mixin Start *Backtick `parser:"@@"` Text string `parser:"@RawChar"` Terminate *Backtick `parser:"@@"` }
RawStringLit represents a string literal that has only regular string characters. Nothing can be escaped or interpolated.
func (*RawStringLit) String ¶
func (rsl *RawStringLit) String() string
func (*RawStringLit) Unparse ¶
func (rsl *RawStringLit) Unparse(opts ...UnparseOption) string
type Reference ¶
Reference represents the exported identifier from an imported module.
func (*Reference) Unparse ¶
func (r *Reference) Unparse(opts ...UnparseOption) string
type Scope ¶
type Scope struct { Node Level ScopeLevel Outer *Scope Objects map[string]*Object }
Scope maintains the set of named language entities declared in the scope and a link to the immediately surrounding (outer) scope.
func NewScope ¶
func NewScope(outer *Scope, level ScopeLevel, node Node) *Scope
NewScope creates a new scope linking to an outer scope.
func (*Scope) ByLevel ¶
func (s *Scope) ByLevel(level ScopeLevel) *Scope
func (*Scope) Identifiers ¶
type ScopeLevel ¶
type ScopeLevel string
var ( BuiltinScope ScopeLevel = "Builtins" ModuleScope ScopeLevel = "Module" FunctionScope ScopeLevel = "Function" BlockScope ScopeLevel = "Block" ArgsScope ScopeLevel = "Arguments" )
type SearchOption ¶
type SearchOption func(*searcher)
SearchOption provides configuration for Search.
func WithSkip ¶
func WithSkip(skip int) SearchOption
WithSkip specifies how many matches to skip before returning.
type Stmt ¶
type Stmt struct { Mixin Call *CallStmt `parser:"( @@"` Expr *ExprStmt `parser:"| @@"` Newline *Newline `parser:"| @@"` Comments *CommentGroup `parser:"| @@ )"` }
Stmt represents a statement node.
func NewCallStmt ¶
func NewCallStmt(name string, args []*Expr, with *WithClause, binds *BindClause) *Stmt
func (*Stmt) Unparse ¶
func (s *Stmt) Unparse(opts ...UnparseOption) string
type StmtEnd ¶
type StmtEnd struct { Mixin Semicolon *string `parser:"( @';'"` Newline *Newline `parser:"| @@"` Comment *Comment `parser:"| @@ )"` }
StmtEnd represents the end of a statement.
func (*StmtEnd) Unparse ¶
func (se *StmtEnd) Unparse(opts ...UnparseOption) string
type StringFragment ¶
type StringFragment struct { Mixin Escaped *string `parser:"( @Escaped"` Interpolated *Interpolated `parser:"| @@"` Text *string `parser:"| @Char )"` }
StringFragment represents a piece of a string literal.
func (*StringFragment) String ¶
func (sf *StringFragment) String() string
func (*StringFragment) Unparse ¶
func (sf *StringFragment) Unparse(opts ...UnparseOption) string
type StringLit ¶
type StringLit struct { Mixin Start *Quote `parser:"@@"` Fragments []*StringFragment `parser:"@@*"` Terminate *Quote `parser:"@@"` }
StringLit represents a string literal that can contain escaped characters, interpolated expressions and regular string characters.
func (*StringLit) Unparse ¶
func (sl *StringLit) Unparse(opts ...UnparseOption) string
func (*StringLit) Unquoted ¶
func (sl *StringLit) Unquoted(opts ...UnparseOption) string
type Type ¶
Type represents an object type.
func (*Type) Unparse ¶
func (t *Type) Unparse(opts ...UnparseOption) string
type UnparseInfo ¶
type UnparseOption ¶
type UnparseOption func(*UnparseInfo)
func WithIndent ¶
func WithIndent(depth int) UnparseOption
func WithNoNewline ¶
func WithNoNewline() UnparseOption
func WithNoStmtEnd ¶
func WithNoStmtEnd() UnparseOption
type Variadic ¶
Variadic represents a modifier for variadic fields. Variadic must only modify the last field of a FieldList.
func (*Variadic) Unparse ¶
func (v *Variadic) Unparse(opts ...UnparseOption) string
type Visitor ¶
type Visitor interface { // Visit visits the current node. Visit(i Introspector, n Node) (w Visitor) }
A Visitor's Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).
type With ¶
With represents the keyword "with".
func (*With) Unparse ¶
func (w *With) Unparse(opts ...UnparseOption) string
type WithClause ¶
type WithClause struct { Mixin Closure *FuncDecl With *With `parser:"@@"` Expr *Expr `parser:"@@"` }
WithClause represents optional arguments for a CallStmt.
func (*WithClause) String ¶
func (wc *WithClause) String() string
func (*WithClause) Unparse ¶
func (wc *WithClause) Unparse(opts ...UnparseOption) string