Documentation
¶
Overview ¶
Package syntax provides functions for parsing req scripts into their ASTs for evaluation.
Index ¶
- type Array
- type AssignStmt
- type BlockStmt
- type BranchStmt
- type CaseStmt
- type ChainExpr
- type CommandStmt
- type DotExpr
- type ExprList
- type ForStmt
- type IfStmt
- type IndExpr
- type KeyExpr
- type Lit
- type LitType
- type MatchStmt
- type Name
- type Node
- type Object
- type Op
- type Operation
- type Pos
- type Range
- type Ref
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct { Items []Node // contains filtered or unexported fields }
Array represents an array of operands. Arrays defined by the user will contain only a single type, either being a literal, or an array or object. [Items[0], Items[1], ...]
type AssignStmt ¶
AssignStmt for assigning values to variables. Left = Right
type BlockStmt ¶
type BlockStmt struct { Nodes []Node // contains filtered or unexported fields }
BlockStmt for a list of top-level statements, each separated by a semi. {Nodes[0]; Nodes[1]; ...}
type BranchStmt ¶
type BranchStmt struct { Tok token // contains filtered or unexported fields }
BranchStmt for break or continue statements within a for-loop.
type CaseStmt ¶
CaseStmt for use within a match statement. If the condition of the match statement matches the value, the Then block is executed. Value -> Then Value -> { Then }
type ChainExpr ¶
type ChainExpr struct { Commands []*CommandStmt // contains filtered or unexported fields }
ChainExpr for using the output of one command as the first argument to a subsequent command. Commands[0] -> Commands[1] -> ...
type CommandStmt ¶
CommandStmt for the invocation of a command. The arguments passed to the command are space separated. Name Args[0] Args[1] ...
type DotExpr ¶
DotExpr for selecting fields on an entity. The left most node of this expression will always be a Ref. $Left.Right
type ExprList ¶
type ExprList struct { Nodes []Node // contains filtered or unexported fields }
ExprList is a list of comma separated expressions. Node[0], Node[1], ...
type ForStmt ¶
type ForStmt struct { Init Node Cond Node Post Node Body *BlockStmt // contains filtered or unexported fields }
ForStmt for executing a block code multiple times. for Cond { Body } for Init; Cond; Post { Body }
type IfStmt ¶
IfStmt for checking the condition and executing the given Then node if that condition evaluates to a truthy value. if Cond { Then } else { Else }
type IndExpr ¶
IndExpr for accessing items in an indexable type such as an array or an object. The left most node of this expression will always be a Ref. $Left[Right]
type KeyExpr ¶
KeyExpr for defining a key-value pair within an object. The key of this pair is a name and not a string literal. Key: Value
type MatchStmt ¶
type MatchStmt struct { Cond Node Cases []*CaseStmt Default Node // contains filtered or unexported fields }
MatchStmt for checking the condition against different literals. The default condition for a match statement is defined with the name _.
match Cond { Cases[0]; Cases[1]; Default; }
type Name ¶
type Name struct { Value string // contains filtered or unexported fields }
Name represents an identifier, such as a variable name, object key, or reference name. Value
type Node ¶
type Node interface { // Pos returns the position the node can be found out in the original // source. Pos() Pos // Err reports an error that occurred at the node's position. Err(msg string) error }
func Parse ¶
Parse reads all content from the given reader and parses it into an AST. The given callback is used to reporting any and all errors that may occur during parsing, using the given name for uniquely identifying the parser (typically a filename).
func ParseExpr ¶
ParseExpr parses all of the expressions from the given string. This is would be used as part of a REPL to parse each line that is input.
type Object ¶
type Object struct { Pairs []*KeyExpr // contains filtered or unexported fields }
Object is the type for key-value pairs. {Pairs[0], Pairs[1], ...}