Documentation ¶
Overview ¶
Package parse implements the elvish parser.
Index ¶
- Variables
- func IsArray(n Node) bool
- func IsAssignment(n Node) bool
- func IsChunk(n Node) bool
- func IsCompound(n Node) bool
- func IsExitusRedir(n Node) bool
- func IsForm(n Node) bool
- func IsIndexing(n Node) bool
- func IsMapPair(n Node) bool
- func IsPipeline(n Node) bool
- func IsPrimary(n Node) bool
- func IsRedir(n Node) bool
- func IsSep(n Node) bool
- func IsSpace(r rune) bool
- func IsSpaceOrNewline(r rune) bool
- func PprintAST(n Node, wr io.Writer)
- func PprintParseTree(n Node, wr io.Writer)
- func Quote(s string) string
- type Array
- type Assignment
- type Chunk
- type Compound
- type Error
- type ErrorEntry
- type ExitusRedir
- type Form
- type Indexing
- type MapPair
- type Node
- type Pipeline
- type Primary
- type PrimaryType
- type Redir
- type RedirMode
- type Sep
Constants ¶
This section is empty.
Variables ¶
var QuotingStyles = []struct { Type PrimaryType Quoter string }{ {SingleQuoted, "'"}, {DoubleQuoted, "\""}, }
Functions ¶
func IsAssignment ¶ added in v0.6.0
func IsCompound ¶ added in v0.6.0
func IsExitusRedir ¶ added in v0.6.0
func IsIndexing ¶ added in v0.6.0
func IsPipeline ¶ added in v0.6.0
func IsSpaceOrNewline ¶ added in v0.6.0
func PprintParseTree ¶
PprintParseTree pretty prints the parse tree part of a Node.
Types ¶
type Array ¶
type Array struct { Compounds []*Compound // When non-empty, records the occurrences of semicolons by the indices of // the compounds they appear before. For instance, [; ; a b; c d;] results // in Semicolons={0 0 2 4}. Semicolons []int // contains filtered or unexported fields }
Array = { Space | '\n' } { Compound { Space | '\n' } }
func (*Array) SourceText ¶
func (n *Array) SourceText() string
type Assignment ¶
Assignment = Indexing '=' Compound
func GetAssignment ¶ added in v0.6.0
func GetAssignment(n Node) *Assignment
func (*Assignment) SourceText ¶
func (n *Assignment) SourceText() string
type Chunk ¶
type Chunk struct { Pipelines []*Pipeline // contains filtered or unexported fields }
Chunk = { PipelineSep | Space } { Pipeline { PipelineSep | Space } }
func (*Chunk) SourceText ¶
func (n *Chunk) SourceText() string
type Compound ¶
type Compound struct { Indexings []*Indexing // contains filtered or unexported fields }
Compound = { Indexing }
func GetCompound ¶ added in v0.6.0
func (*Compound) SourceText ¶
func (n *Compound) SourceText() string
type Error ¶ added in v0.8.0
type Error struct {
Entries []*ErrorEntry
}
Error stores multiple ErrorEntry's and can pretty print them.
type ErrorEntry ¶ added in v0.8.0
type ErrorEntry struct { Message string Context util.SourceContext }
ErrorEntry represents one parse error.
type ExitusRedir ¶
type ExitusRedir struct { Dest *Compound // contains filtered or unexported fields }
ExitusRedir = '?' '>' { Space } Compound
func GetExitusRedir ¶ added in v0.6.0
func GetExitusRedir(n Node) *ExitusRedir
func (*ExitusRedir) SourceText ¶
func (n *ExitusRedir) SourceText() string
type Form ¶
type Form struct { Assignments []*Assignment Head *Compound // Left-hand-sides for the spacey assignment. Right-hand-sides are in Args. Vars []*Compound Args []*Compound Opts []*MapPair Redirs []*Redir ExitusRedir *ExitusRedir // contains filtered or unexported fields }
Form = { Space } { { Assignment } { Space } }
{ Compound } { Space } { ( Compound | MapPair | Redir | ExitusRedir ) { Space } }
func (*Form) SourceText ¶
func (n *Form) SourceText() string
type Indexing ¶
Indexing = Primary { '[' Array ']' }
func GetIndexing ¶ added in v0.6.0
func (*Indexing) SourceText ¶
func (n *Indexing) SourceText() string
type MapPair ¶
type MapPair struct {
Key, Value *Compound
// contains filtered or unexported fields
}
MapPair = '&' { Space } Compound { Space } Compound
func GetMapPair ¶ added in v0.6.0
func (*MapPair) SourceText ¶
func (n *MapPair) SourceText() string
type Node ¶
type Node interface { Parent() Node Begin() int End() int SourceText() string Children() []Node // contains filtered or unexported methods }
Node represents a parse tree as well as an AST.
type Pipeline ¶
Pipeline = Form { '|' Form }
func GetPipeline ¶ added in v0.6.0
func (*Pipeline) SourceText ¶
func (n *Pipeline) SourceText() string
type Primary ¶
type Primary struct { Type PrimaryType // The unquoted string value. Valid for Bareword, SingleQuoted, // DoubleQuoted, Variable, Wildcard and Tilde. Value string List *Array // Valid for List and Lambda Chunk *Chunk // Valid for OutputCapture, ExitusCapture and Lambda MapPairs []*MapPair // Valid for Map Braced []*Compound // Valid for Braced IsRange []bool // Valid for Braced // contains filtered or unexported fields }
Primary is the smallest expression unit.
func GetPrimary ¶ added in v0.6.0
func (*Primary) SourceText ¶
func (n *Primary) SourceText() string
type PrimaryType ¶
type PrimaryType int
PrimaryType is the type of a Primary.
const ( BadPrimary PrimaryType = iota Bareword SingleQuoted DoubleQuoted Variable Wildcard Tilde ExceptionCapture OutputCapture List Lambda Map Braced )
Possible values for PrimaryType.
func QuoteAs ¶
func QuoteAs(s string, q PrimaryType) (string, PrimaryType)
QuoteAs returns a representation of s in elvish syntax, using the syntax specified by q, which must be one of Bareword, SingleQuoted, or DoubleQuoted. It returns the quoted string and the actual quoting.
func (PrimaryType) String ¶
func (i PrimaryType) String() string
type Redir ¶
type Redir struct { Left *Compound Mode RedirMode RightIsFd bool Right *Compound // contains filtered or unexported fields }
Redir = { Compound } { '<'|'>'|'<>'|'>>' } { Space } ( '&'? Compound )
func (*Redir) SourceText ¶
func (n *Redir) SourceText() string
type Sep ¶
type Sep struct {
// contains filtered or unexported fields
}
Sep is the catch-all node type for leaf nodes that lack internal structures and semantics, and serve solely for syntactic purposes. The parsing of separators depend on the Parent node; as such it lacks a genuine parse method.
func (*Sep) SourceText ¶
func (n *Sep) SourceText() string