Versions in this module Expand all Collapse all v0 v0.4.0 Mar 4, 2022 Changes in this version + var Lexer = lexer.MustStateful(lexer.Rules{ ... }) + var Parser = participle.MustBuild(&Module{}, participle.Lexer(Lexer), participle.Elide("Whitespace")) + 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 struct + Text string + func (a *As) String() string + func (a *As) Unparse(opts ...UnparseOption) string + type Backtick struct + Text string + func (b *Backtick) String() string + func (b *Backtick) Unparse(opts ...UnparseOption) string + type BasicLit struct + Bool *bool + Decimal *int + Heredoc *Heredoc + Numeric *NumericLit + RawHeredoc *RawHeredoc + RawString *RawStringLit + Str *StringLit + func (bl *BasicLit) Kind() Kind + func (bl *BasicLit) String() string + func (bl *BasicLit) Unparse(opts ...UnparseOption) string + type Bind struct + Field *Field + Source *Ident + Target *Ident + func (b *Bind) String() string + func (b *Bind) Unparse(opts ...UnparseOption) string + type BindClause struct + As *As + Binds *BindList + Closure *FuncDecl + Effects *FieldList + Ident *Ident + func (bc *BindClause) SourceBinding(source string) *Binding + func (bc *BindClause) String() string + func (bc *BindClause) TargetBinding(target string) *Binding + func (bc *BindClause) Unparse(opts ...UnparseOption) string + type BindList struct + Start *OpenParen + Stmts []*BindStmt + Terminate *CloseParen + func (bl *BindList) Binds() []*Bind + func (bl *BindList) String() string + func (bl *BindList) Unparse(opts ...UnparseOption) string + type BindStmt struct + Bind *Bind + Comments *CommentGroup + Newline *Newline + func (bs *BindStmt) String() string + func (bs *BindStmt) Unparse(opts ...UnparseOption) string + type Binding struct + Bind *BindClause + Field *Field + Name *Ident + func (b *Binding) Binds() string + type Binds struct + Text string + func (b *Binds) String() string + func (b *Binds) Unparse(opts ...UnparseOption) string + type BlockStmt struct + Closure *FuncDecl + List []*Stmt + Scope *Scope + Start *OpenBrace + Terminate *CloseBrace + Type *Type + func NewBlockStmt(stmts ...*Stmt) *BlockStmt + func (bs *BlockStmt) Kind() Kind + func (bs *BlockStmt) Stmts() []*Stmt + func (bs *BlockStmt) String() string + func (bs *BlockStmt) Unparse(opts ...UnparseOption) string + type BuiltinDecl struct + FuncDeclByKind map[Kind]*FuncDecl + Kinds []Kind + Name string + func (bd *BuiltinDecl) FuncDecl(kind Kind) *FuncDecl + func (bd *BuiltinDecl) String() string + func (bd *BuiltinDecl) Unparse(opts ...UnparseOption) string + type CallExpr struct + List *ExprList + Name *IdentExpr + Sig []Kind + func (ce *CallExpr) Arguments() []*Expr + func (ce *CallExpr) Breakpoint() bool + func (ce *CallExpr) Ident() *Ident + func (ce *CallExpr) Signature() []Kind + func (ce *CallExpr) String() string + func (ce *CallExpr) Subject() Node + func (ce *CallExpr) Unparse(opts ...UnparseOption) string + type CallNode interface + Arguments func() []*Expr + Ident func() *Ident + Signature func() []Kind + type CallStmt struct + Args []*Expr + BindClause *BindClause + Doc *CommentGroup + Name *IdentExpr + Sig []Kind + Terminate *StmtEnd + WithClause *WithClause + func (cs *CallStmt) Arguments() []*Expr + func (cs *CallStmt) Breakpoint() bool + func (cs *CallStmt) Ident() *Ident + func (cs *CallStmt) Signature() []Kind + func (cs *CallStmt) String() string + func (cs *CallStmt) Subject() Node + func (cs *CallStmt) Unparse(opts ...UnparseOption) string + type CloseBrace struct + Text string + type CloseParen struct + Text string + type Comment struct + Text string + func (c *Comment) String() string + func (c *Comment) Unparse(opts ...UnparseOption) string + type CommentGroup struct + List []*Comment + func (cg *CommentGroup) String() string + func (cg *CommentGroup) Unparse(opts ...UnparseOption) string + func (g *CommentGroup) NumComments() int + type Decl struct + Comments *CommentGroup + Export *ExportDecl + Func *FuncDecl + Import *ImportDecl + Newline *Newline + func (d *Decl) String() string + func (d *Decl) Unparse(opts ...UnparseOption) string + type DeprecatedImportDecl struct + Ident *Ident + Import *Import + ImportFunc *ImportFunc + ImportPath *ImportPath + Pos lexer.Position + func (d *DeprecatedImportDecl) End() lexer.Position + func (d *DeprecatedImportDecl) Position() lexer.Position + type Directory interface + Close func() error + Definition func() *llb.Definition + Digest func() digest.Digest + Open func(filename string) (io.ReadCloser, error) + Path func() string + Stat func(filename string) (os.FileInfo, error) + type EffectsClause struct + Binds *Binds + Effects *FieldList + func NewEffectsClause(effect ...*Field) *EffectsClause + func (ec *EffectsClause) String() string + func (ec *EffectsClause) Unparse(opts ...UnparseOption) string + type Export struct + Text string + func (e *Export) String() string + func (e *Export) Unparse(opts ...UnparseOption) string + type ExportDecl struct + Export *Export + Name *Ident + func (ed *ExportDecl) String() string + func (ed *ExportDecl) Unparse(opts ...UnparseOption) string + type Expr struct + BasicLit *BasicLit + CallExpr *CallExpr + FuncLit *FuncLit + func NewBoolExpr(v bool) *Expr + func NewDecimalExpr(v int) *Expr + func NewFuncLitExpr(kind Kind, stmts ...*Stmt) *Expr + func NewNumericExpr(v int64, base int) *Expr + func NewStringExpr(v string) *Expr + func (e *Expr) Kind() Kind + func (e *Expr) String() string + func (e *Expr) Unparse(opts ...UnparseOption) string + type ExprField struct + Comments *CommentGroup + Expr *Expr + Newline *Newline + func (ef *ExprField) String() string + func (ef *ExprField) Unparse(opts ...UnparseOption) string + type ExprList struct + Fields []*ExprField + Start *OpenParen + Terminate *CloseParen + func (el *ExprList) String() string + func (el *ExprList) Unparse(opts ...UnparseOption) string + type ExprStmt struct + Expr *Expr + Terminate *StmtEnd + func (es *ExprStmt) String() string + func (es *ExprStmt) Unparse(opts ...UnparseOption) string + type Field struct + Modifier *Modifier + Name *Ident + Type *Type + func NewField(kind Kind, name string, variadic bool) *Field + func (f *Field) Kind() Kind + func (f *Field) String() string + func (f *Field) Unparse(opts ...UnparseOption) string + type FieldList struct + Start *OpenParen + Stmts []*FieldStmt + Terminate *CloseParen + func NewFieldList(params ...*Field) *FieldList + func (fl *FieldList) Fields() []*Field + func (fl *FieldList) NumFields() int + func (fl *FieldList) String() string + func (fl *FieldList) Unparse(opts ...UnparseOption) string + type FieldStmt struct + Comments *CommentGroup + Field *Field + Newline *Newline + func (fs *FieldStmt) String() string + func (fs *FieldStmt) Unparse(opts ...UnparseOption) string + type From struct + Text string + func (f *From) String() string + func (f *From) Unparse(opts ...UnparseOption) string + type FuncDecl struct + Body *BlockStmt + Doc *CommentGroup + Scope *Scope + Sig *FuncSignature + func (fd *FuncDecl) Kind() Kind + func (fd *FuncDecl) String() string + func (fd *FuncDecl) Unparse(opts ...UnparseOption) string + type FuncLit struct + Body *BlockStmt + Type *Type + func NewFuncLit(kind Kind, stmts ...*Stmt) *FuncLit + func (fl *FuncLit) Kind() Kind + func (fl *FuncLit) String() string + func (fl *FuncLit) Unparse(opts ...UnparseOption) string + type FuncSignature struct + Effects *EffectsClause + Name *Ident + Params *FieldList + Type *Type + func (fs *FuncSignature) Kind() Kind + func (fs *FuncSignature) String() string + func (fs *FuncSignature) Subject() Node + func (fs *FuncSignature) Unparse(opts ...UnparseOption) string + type Heredoc struct + Fragments []*HeredocFragment + Start string + Terminate *HeredocEnd + Value string + func (h *Heredoc) String() string + func (h *Heredoc) Unparse(opts ...UnparseOption) string + type HeredocEnd struct + Text string + func (he *HeredocEnd) String() string + func (he *HeredocEnd) Unparse(opts ...UnparseOption) string + type HeredocFragment struct + Escaped *string + Interpolated *Interpolated + Spaces *string + Text *string + func (hf *HeredocFragment) String() string + func (hf *HeredocFragment) Unparse(opts ...UnparseOption) string + type Ident struct + Text string + func NewIdent(name string) *Ident + func (i *Ident) String() string + func (i *Ident) Unparse(opts ...UnparseOption) string + type IdentExpr struct + Ident *Ident + Reference *Reference + func NewIdentExpr(name string) *IdentExpr + func (ie *IdentExpr) String() string + func (ie *IdentExpr) Unparse(opts ...UnparseOption) string + type Import struct + Text string + func (i *Import) String() string + func (i *Import) Unparse(opts ...UnparseOption) string + type ImportDecl struct + DeprecatedPath *StringLit + Expr *Expr + From *From + Import *Import + Name *Ident + func (id *ImportDecl) String() string + func (id *ImportDecl) Unparse(opts ...UnparseOption) string + type ImportFunc struct + From *From + Func *FuncLit + Pos lexer.Position + func (i *ImportFunc) End() lexer.Position + func (i *ImportFunc) Position() lexer.Position + type ImportPath struct + Path *StringLit + Pos lexer.Position + func (i *ImportPath) End() lexer.Position + func (i *ImportPath) Position() lexer.Position + type Interpolated struct + Expr *Expr + Start *OpenInterpolated + Terminate *CloseBrace + func (i *Interpolated) String() string + func (i *Interpolated) Unparse(opts ...UnparseOption) string + type Introspector interface + Path func() []Node + type Kind string + const Bool + const Filesystem + const Int + const None + const Option + const Pipeline + const String + func (k Kind) Primary() Kind + func (k Kind) Secondary() Kind + type KindSet struct + func NewKindSet(kinds ...Kind) *KindSet + func (ks *KindSet) Has(kind Kind) bool + func (ks *KindSet) Kinds() (kinds []Kind) + type MatchOpts struct + AllowDuplicates bool + Filter func(Node) bool + type Mixin struct + EndPos lexer.Position + Pos lexer.Position + 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 struct + Variadic *Variadic + func (m *Modifier) String() string + func (m *Modifier) Unparse(opts ...UnparseOption) string + type Module struct + Decls []*Decl + Directory Directory + Doc *CommentGroup + Scope *Scope + URI string + func (m *Module) String() string + func (m *Module) Unparse(opts ...UnparseOption) string + type ModuleLookup struct + func Modules(ctx context.Context) *ModuleLookup + func NewModules() *ModuleLookup + func (ml *ModuleLookup) Get(filename string) *Module + func (ml *ModuleLookup) Set(filename string, mod *Module) + type Newline struct + Text string + func (n *Newline) String() string + func (n *Newline) Unparse(opts ...UnparseOption) string + type Node interface + End func() lexer.Position + Position func() lexer.Position + Spanf func(t diagnostic.Type, format string, a ...interface{}) diagnostic.Option + Unparse func(opts ...UnparseOption) string + WithError func(err error, opts ...diagnostic.Option) error + func Find(root Node, line, column int, filter func(Node) bool) Node + func Search(root Node, query string, opts ...SearchOption) Node + type NumericLit struct + Base int + Value int64 + func (nl *NumericLit) Capture(tokens []string) error + func (nl *NumericLit) End() lexer.Position + func (nl *NumericLit) Position() lexer.Position + func (nl *NumericLit) String() string + func (nl *NumericLit) Unparse(opts ...UnparseOption) string + type ObjKind int + const BadKind + const DeclKind + const FieldKind + type Object struct + Data interface{} + Exported bool + Ident *Ident + Kind Kind + Node Node + type OpenBrace struct + Text string + type OpenInterpolated struct + Text string + func (oi *OpenInterpolated) String() string + func (oi *OpenInterpolated) Unparse(opts ...UnparseOption) string + type OpenParen struct + Text string + type Quote struct + Text string + func (q *Quote) String() string + func (q *Quote) Unparse(opts ...UnparseOption) string + type RawHeredoc struct + Fragments []*HeredocFragment + Start string + Terminate *HeredocEnd + func (rh *RawHeredoc) String() string + func (rh *RawHeredoc) Unparse(opts ...UnparseOption) string + type RawStringLit struct + Start *Backtick + Terminate *Backtick + Text string + func (rsl *RawStringLit) String() string + func (rsl *RawStringLit) Unparse(opts ...UnparseOption) string + type Reference struct + Dot string + Ident *Ident + func (r *Reference) String() string + func (r *Reference) Unparse(opts ...UnparseOption) string + type Scope struct + Level ScopeLevel + Objects map[string]*Object + Outer *Scope + func NewScope(outer *Scope, level ScopeLevel, node Node) *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 string + var ArgsScope ScopeLevel = "Arguments" + var BlockScope ScopeLevel = "Block" + var BuiltinScope ScopeLevel = "Builtins" + var FunctionScope ScopeLevel = "Function" + var ModuleScope ScopeLevel = "Module" + type SearchOption func(*searcher) + func WithSkip(skip int) SearchOption + type Stmt struct + Call *CallStmt + Comments *CommentGroup + Expr *ExprStmt + Newline *Newline + func NewCallStmt(name string, args []*Expr, with *WithClause, binds *BindClause) *Stmt + func (s *Stmt) String() string + func (s *Stmt) Unparse(opts ...UnparseOption) string + type StmtEnd struct + Comment *Comment + Newline *Newline + Semicolon *string + func (se *StmtEnd) String() string + func (se *StmtEnd) Unparse(opts ...UnparseOption) string + type StopNode interface + Subject func() Node + type StringFragment struct + Escaped *string + Interpolated *Interpolated + Text *string + func (sf *StringFragment) String() string + func (sf *StringFragment) Unparse(opts ...UnparseOption) string + type StringLit struct + Fragments []*StringFragment + Start *Quote + Terminate *Quote + func (sl *StringLit) String() string + func (sl *StringLit) Unparse(opts ...UnparseOption) string + func (sl *StringLit) Unquoted(opts ...UnparseOption) string + type Type struct + Kind Kind + func NewType(kind Kind) *Type + func (t *Type) String() string + func (t *Type) Unparse(opts ...UnparseOption) string + type UnparseInfo struct + Indent int + NoNewline bool + NoStmtEnd bool + type UnparseOption func(*UnparseInfo) + func WithIndent(depth int) UnparseOption + func WithNoNewline() UnparseOption + func WithNoStmtEnd() UnparseOption + type Variadic struct + Text string + func (v *Variadic) String() string + func (v *Variadic) Unparse(opts ...UnparseOption) string + type Visitor interface + Visit func(i Introspector, n Node) (w Visitor) + type With struct + Text string + func (w *With) String() string + func (w *With) Unparse(opts ...UnparseOption) string + type WithClause struct + Closure *FuncDecl + Expr *Expr + With *With + func (wc *WithClause) String() string + func (wc *WithClause) Unparse(opts ...UnparseOption) string