Documentation
¶
Overview ¶
Package parse converts GN syntax tokens into an AST.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessorNode ¶
type AccessorNode struct { Base syntax.Token Subscript ParseNode Member *IdentifierNode }
AccessorNode represents accessing an array or scope element.
func (*AccessorNode) Dump ¶
func (n *AccessorNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*AccessorNode) LocationRange ¶
func (n *AccessorNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type BinaryOpNode ¶
func (*BinaryOpNode) Dump ¶
func (n *BinaryOpNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*BinaryOpNode) LocationRange ¶
func (n *BinaryOpNode) LocationRange() syntax.LocationRange
type BlockCommentNode ¶
BlockCommentNode represents standalone comments (that is, those not specifically attached to another syntax element. The most common of these is a standard header block. This node contains only the last line of such a comment block as the anchor, and other lines of the block comment are hung off of it as Before comments, similar to other syntax elements.
func (*BlockCommentNode) Dump ¶
func (n *BlockCommentNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*BlockCommentNode) LocationRange ¶
func (n *BlockCommentNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type BlockNode ¶
type BlockNode struct { // ResultMode sets execution option for handling scope and results. ResultMode BlockNodeResultMode // BeginToken corresponds to "{" token of this block. BeginToken syntax.Token // End is the end token of this block. End EndNode // Statements is the list of statements in this block. Statements []ParseNode }
BlockNode represents a block in the AST.
func (*BlockNode) LocationRange ¶
func (n *BlockNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type BlockNodeResultMode ¶
type BlockNodeResultMode int
BlockNodeResultMode sets execution option for the scopes and results.
const ( // ReturnsScope is option to create new scope for the execution of a block // and returning it as a Value. ReturnsScope BlockNodeResultMode = iota // DiscardResults is option to execute block in the context of the calling // scope (variables set will go into the invoking scope) and return an // empty Value. DiscardsResult )
type ConditionNode ¶
type ConditionNode struct { // IfToken represents the if token this node starts at. IfToken syntax.Token // Condition represents the conditional for this node. Condition ParseNode // IfTrue is the block to be executed if the conditional evaluates to true. IfTrue *BlockNode // IfFalse should be a *BlockNode or *ConditionNode to represent either the "else" block or "else if" condition, respectively. IfFalse ParseNode }
ConditionNode represents a conditional in the AST.
func (*ConditionNode) Dump ¶
func (n *ConditionNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*ConditionNode) LocationRange ¶
func (n *ConditionNode) LocationRange() syntax.LocationRange
type EndNode ¶
EndNode is used as the end object for lists and blocks (rather than just the end ']', '}', or ')' syntax.Token). This is so that during formatting traversal there is a node that appears at the end of the block to which comments can be attached.
type FunctionCallNode ¶
FunctionCallNode represents a function call in the AST.
func (*FunctionCallNode) Dump ¶
func (n *FunctionCallNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*FunctionCallNode) LocationRange ¶
func (n *FunctionCallNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type IdentifierNode ¶
IdentifierNode represents an identifier in the AST.
func (*IdentifierNode) Dump ¶
func (n *IdentifierNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*IdentifierNode) LocationRange ¶
func (n *IdentifierNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type ListNode ¶
ListNode represents a list in the AST.
func (*ListNode) LocationRange ¶
func (n *ListNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type LiteralNode ¶
LiteralNode represents a literal in the AST.
func (*LiteralNode) Dump ¶
func (n *LiteralNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*LiteralNode) LocationRange ¶
func (n *LiteralNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.
type NodeDump ¶
type NodeDump struct { Type string `json:"type"` Value string `json:"value,omitempty"` Children []NodeDump `json:"child,omitempty"` BeginToken string `json:"begin_token,omitempty"` End *NodeDump `json:"end,omitempty"` AccessorKind string `json:"accessor_kind,omitempty"` }
NodeDump is a JSON-serializable representation of a ParseNode.
type ParseNode ¶
type ParseNode interface { // LocationRange is the file range this node represents. LocationRange() syntax.LocationRange // Dump returns a JSON-serializable representation of this node. Dump() NodeDump }
ParseNode is a node in the AST.
type UnaryOpNode ¶
type UnaryOpNode struct { // Op is the operator token. Op syntax.Token // Operand represents the operand of the operation. Operand ParseNode }
UnaryOpNode represents a unary operation in the AST.
func (*UnaryOpNode) Dump ¶
func (n *UnaryOpNode) Dump() NodeDump
Dump returns a JSON-serializable of this node.
func (*UnaryOpNode) LocationRange ¶
func (n *UnaryOpNode) LocationRange() syntax.LocationRange
LocationRange returns the location range for this node.