Documentation
¶
Overview ¶
Package ast defines the Abstract Syntax Tree node types for ClassAds expressions.
Index ¶
- func AppendQuoteAttributeName(dst []byte, name string) []byte
- func AppendQuoteString(dst []byte, s string) []byte
- func AppendQuoteStringBytes(dst, s []byte) []byte
- func AppendQuoteStringOld(dst []byte, s string) []byte
- func AppendQuoteStringOldBytes(dst, s []byte) []byte
- 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 AppendQuoteAttributeName ¶ added in v0.2.0
AppendQuoteAttributeName appends QuoteAttributeName(name) to dst and returns the extended slice, the append-to-buffer variant used when rendering many attribute names into a shared buffer (record keys, scoped/selected attr refs) without a per-name string allocation.
func AppendQuoteString ¶ added in v0.2.0
AppendQuoteString appends QuoteString(s) to dst and returns the extended slice, so a caller building a larger buffer (e.g. an ad's "Name = Value" line) does not allocate an intermediate string per value.
func AppendQuoteStringBytes ¶ added in v0.2.0
AppendQuoteStringBytes is AppendQuoteString for a value that already lives in a byte slice (e.g. a string literal's bytes inside a wire buffer): it quotes s without first copying it into a Go string, producing output identical to AppendQuoteString(dst, string(s)). The common no-escape case is a plain byte copy; the escape path iterates runes via `range string(s)`, which the compiler lowers without allocating a string.
func AppendQuoteStringOld ¶ added in v0.10.0
AppendQuoteStringOld quotes s as an OLD-ClassAd string literal: it wraps s in double quotes and escapes ONLY an embedded double-quote (as \"). A backslash is emitted literally, because old-ClassAd string lexing (C++ Lexer::tokenizeStringOld) does no escape processing and treats every backslash as a literal character -- so this is the exact inverse of that lexer (and of the collections old-ClassAd ingest fast path).
This is the correct serialization for values sent over the wire in old-ClassAd form, e.g. a collector forwarding a startd ad whose OSIssue is the two bytes `\` `S`. Using the new-ClassAd quoter (AppendQuoteString) there would double the backslash to `\\` on every hop, and for a value ending in a backslash would emit an unterminated string the receiver rejects (a forwarding connection reset). A value ending in a lone backslash, or containing a backslash immediately before a quote, cannot be represented unambiguously in old-ClassAd at all -- the same inherent limitation C++ has; such values do not occur in the machine/job ads this serves.
func AppendQuoteStringOldBytes ¶ added in v0.10.0
AppendQuoteStringOldBytes is AppendQuoteStringOld for a value already in a byte slice (e.g. a string literal's bytes inside a wire buffer), quoting it without first copying it into a Go string.
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
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
// contains filtered or unexported fields
}
AttributeReference represents a reference to an attribute by name.
func NewAttributeReference ¶ added in v0.5.3
func NewAttributeReference(name string, scope AttributeScope) *AttributeReference
NewAttributeReference builds an attribute reference with its case-folded name precomputed, so evaluation can resolve it without a per-lookup allocation.
func (*AttributeReference) NormalizedName ¶ added in v0.5.3
func (a *AttributeReference) NormalizedName() string
NormalizedName returns the case-folded attribute name used for lookup. It returns the value precomputed by NewAttributeReference when present, else lowercases Name on demand (for nodes built via a struct literal).
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