Documentation
¶
Overview ¶
Package ast defines the Abstract Syntax Tree node types for ClassAds expressions.
Index ¶
- func QuoteAttributeName(name string) string
- func QuoteString(s string) string
- type AttributeAssignment
- type AttributeReference
- type AttributeScope
- type BinaryOp
- type BooleanLiteral
- type ClassAd
- type ConditionalExpr
- type ElvisExpr
- type ErrorLiteral
- type Expr
- type FunctionCall
- type IntegerLiteral
- type ListLiteral
- type Node
- type ParenExpr
- type RealLiteral
- type RecordLiteral
- type SelectExpr
- type StringLiteral
- type SubscriptExpr
- type UnaryOp
- type UndefinedLiteral
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuoteAttributeName ¶ added in v0.1.0
QuoteAttributeName renders an attribute name so it re-parses: a valid bare identifier is returned as-is; anything else (empty, non-identifier characters, or a name that would lex as a reserved keyword/literal) is single-quoted with '\” and '\\' escaped, matching the lexer's quoted-attribute-name unescaping.
func QuoteString ¶ added in v0.1.0
QuoteString renders a string value as a double-quoted ClassAd string literal that the lexer can read back: it uses only the escapes the lexer decodes (\b \f \n \r \t \\ \"), octal (\NNN) for other control characters, and emits everything else (printable ASCII and valid Unicode) verbatim. It deliberately avoids Go's \xNN hex escapes, which the lexer does not understand.
Types ¶
type AttributeAssignment ¶
AttributeAssignment represents an attribute assignment (name = expr).
func (*AttributeAssignment) String ¶
func (a *AttributeAssignment) String() string
type AttributeReference ¶
type AttributeReference struct {
Name string
Scope AttributeScope
}
AttributeReference represents a reference to an attribute by name.
func (*AttributeReference) String ¶
func (a *AttributeReference) String() string
type AttributeScope ¶
type AttributeScope int
AttributeScope represents the scope of an attribute reference.
const ( // NoScope represents an unscoped attribute reference NoScope AttributeScope = iota // MyScope represents MY.attr (current ClassAd) MyScope // TargetScope represents TARGET.attr (target ClassAd in matching) TargetScope // ParentScope represents PARENT.attr (parent ClassAd) ParentScope )
type BooleanLiteral ¶
type BooleanLiteral struct {
Value bool
}
BooleanLiteral represents a boolean constant (true or false).
func (*BooleanLiteral) String ¶
func (b *BooleanLiteral) String() string
type ClassAd ¶
type ClassAd struct {
Attributes []*AttributeAssignment
}
ClassAd represents a complete ClassAd (a record of attribute assignments).
type ConditionalExpr ¶
ConditionalExpr represents a ternary conditional expression (cond ? true_expr : false_expr).
func (*ConditionalExpr) String ¶
func (c *ConditionalExpr) String() string
type ElvisExpr ¶
type ElvisExpr struct {
Left Expr // The expression to test for undefined
Right Expr // The fallback expression if Left is undefined
}
ElvisExpr represents the Elvis operator (expr1 ?: expr2). If expr1 evaluates to undefined, returns expr2; otherwise returns expr1.
type ErrorLiteral ¶
type ErrorLiteral struct{}
ErrorLiteral represents an error value.
func (*ErrorLiteral) String ¶
func (e *ErrorLiteral) String() string
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr represents a ClassAd expression.
func Parenthesize ¶ added in v0.1.0
Parenthesize wraps an expression in a ParenExpr, recording that the source parenthesized it so unparsing can echo the parentheses (matching the reference engine). The wrapped expression is returned for use in grammar actions.
type FunctionCall ¶
FunctionCall represents a function call with arguments.
func (*FunctionCall) String ¶
func (f *FunctionCall) String() string
type IntegerLiteral ¶
type IntegerLiteral struct {
Value int64
}
IntegerLiteral represents an integer constant.
func (*IntegerLiteral) String ¶
func (i *IntegerLiteral) String() string
type ListLiteral ¶
type ListLiteral struct {
Elements []Expr
}
ListLiteral represents a list of expressions.
func (*ListLiteral) String ¶
func (l *ListLiteral) String() string
type ParenExpr ¶ added in v0.1.0
type ParenExpr struct {
Inner Expr
}
ParenExpr is an expression wrapped in explicit source parentheses. The reference engine echoes parentheses verbatim when unparsing -- around any expression, including primaries ((x), (5)) and nested ((x)) -- so they are preserved as a node rather than a flag. Evaluation is transparent (the inner expression's value).
func (*ParenExpr) String ¶ added in v0.1.0
String is transparent: the AST's String() methods are a debug representation that already always-parenthesizes operators, so echoing the explicit source parentheses here would double them. The reference-faithful unparser (classad/unparse.go) is what emits the preserved parentheses.
type RealLiteral ¶
type RealLiteral struct {
Value float64
}
RealLiteral represents a floating-point constant.
func (*RealLiteral) String ¶
func (r *RealLiteral) String() string
type RecordLiteral ¶
type RecordLiteral struct {
ClassAd *ClassAd
}
RecordLiteral represents a record (nested ClassAd).
func (*RecordLiteral) String ¶
func (r *RecordLiteral) String() string
type SelectExpr ¶
SelectExpr represents attribute selection (expr.attr).
func (*SelectExpr) String ¶
func (s *SelectExpr) String() string
type StringLiteral ¶
type StringLiteral struct {
Value string
}
StringLiteral represents a string constant.
func (*StringLiteral) String ¶
func (s *StringLiteral) String() string
type SubscriptExpr ¶
SubscriptExpr represents list/record subscripting (expr[index]).
func (*SubscriptExpr) String ¶
func (s *SubscriptExpr) String() string
type UndefinedLiteral ¶
type UndefinedLiteral struct{}
UndefinedLiteral represents an undefined value.
func (*UndefinedLiteral) String ¶
func (u *UndefinedLiteral) String() string