Documentation
¶
Overview ¶
Package ast defines the lossless syntax tree. It intentionally contains a NativeStatement node: Ruby/Rails DSLs are open ended, so Ruby-only constructs can survive parsing without weakening the typed, portable subset.
Index ¶
- type ArrayLiteral
- type AssignmentStatement
- type AttemptExpression
- type Attribute
- type Base
- type BinaryExpression
- type BlankStatement
- type BlockExpression
- type BreakStatement
- type CallArgument
- type CallExpression
- type CaseBranch
- type CaseStatement
- type CatchExpression
- type ClassStatement
- type CommentStatement
- type EnumMemberStatement
- type EnumStatement
- type Expression
- type ExpressionStatement
- type FieldStatement
- type GenericExpression
- type HashEntry
- type HashLiteral
- type Identifier
- type IfBranch
- type IfStatement
- type ImportStatement
- type IndexExpression
- type InterfaceStatement
- type InterpolatedString
- type IterationExpression
- type JSXAttribute
- type JSXChild
- type JSXElement
- type JSXExpression
- type JSXText
- type LambdaExpression
- type Literal
- type LiteralKind
- type MemberExpression
- type MethodStatement
- type ModuleStatement
- type NativeBlock
- type NativeExpression
- type NativeIsland
- type NativeStatement
- type NewtypeStatement
- type NextStatement
- type Node
- type Parameter
- type PatternBinding
- type Program
- type RangeExpression
- type RecordFieldStatement
- type RecordStatement
- type ReturnStatement
- type Statement
- type StringPart
- type SymbolLiteral
- type TryExpression
- type TypeAliasStatement
- type TypeParameter
- type TypeRef
- type UnaryExpression
- type VariableStatement
- type WhileStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayLiteral ¶
type ArrayLiteral struct {
Base
Elements []Expression
}
type AssignmentStatement ¶
type AssignmentStatement struct {
Base
Target Expression
Operator string
Value Expression
}
type AttemptExpression ¶ added in v0.2.0
type AttemptExpression struct {
Base
Value Expression
Body []Statement
}
AttemptExpression is recovery-only for pre-0.3 source. The parser diagnoses every authored attempt expression before later compiler phases can run it. Exactly one of Value and Body is populated while recovery is still present.
type Attribute ¶
type Attribute struct {
Base
Name string
Arguments []CallArgument
}
type BinaryExpression ¶
type BinaryExpression struct {
Base
Left Expression
Operator string
Right Expression
}
type BlankStatement ¶
type BlankStatement struct{ Base }
type BlockExpression ¶
type BreakStatement ¶
type BreakStatement struct{ Base }
type CallArgument ¶
type CallArgument struct {
Name string
Value Expression
Splat string
}
type CallExpression ¶
type CallExpression struct {
Base
Callee Expression
Arguments []CallArgument
Block *BlockExpression
}
type CaseBranch ¶
type CaseBranch struct {
Base
Value Expression
Alternatives []Expression
Bindings []PatternBinding
Body []Statement
}
type CaseStatement ¶
type CaseStatement struct {
Base
Value Expression
Leading []Statement
Branches []CaseBranch
Else []Statement
HasElse bool
}
type CatchExpression ¶ added in v0.3.0
type CatchExpression struct {
Base
Value Expression
Binding PatternBinding
Body []Statement
}
CatchExpression unwraps a Result-producing Value or evaluates Body for its Err payload. Body is retained as statements because it may either recover with a final expression or transfer control with return, break, or next.
type ClassStatement ¶
type ClassStatement struct {
Base
Name string
TypeParameters []TypeParameter
Superclass Expression
Implements []TypeRef
Body []Statement
}
type CommentStatement ¶
type EnumMemberStatement ¶
type EnumMemberStatement struct {
Base
Name string
Parameters []Parameter
RawValue Expression
}
type EnumStatement ¶
type EnumStatement struct {
Base
Name string
TypeParameters []TypeParameter
Body []Statement
}
EnumStatement is a closed nominal set of values. Members remain statements so their source spans and comments survive the syntax and formatting passes.
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
type ExpressionStatement ¶
type ExpressionStatement struct {
Base
Expression Expression
}
type FieldStatement ¶
type FieldStatement struct {
Base
Name string
Type TypeRef
Value Expression
ReadOnly bool
}
type GenericExpression ¶
type GenericExpression struct {
Base
Receiver Expression
Arguments []TypeRef
}
type HashEntry ¶
type HashEntry struct {
Key Expression
Value Expression
}
type HashLiteral ¶
type Identifier ¶
type IfBranch ¶
type IfBranch struct {
Condition Expression
Body []Statement
}
type IfStatement ¶
type ImportStatement ¶
type IndexExpression ¶
type IndexExpression struct {
Base
Receiver Expression
Index Expression
}
type InterfaceStatement ¶
type InterfaceStatement struct {
Base
Name string
TypeParameters []TypeParameter
Methods []*MethodStatement
}
type InterpolatedString ¶
type InterpolatedString struct {
Base
Raw string
Parts []StringPart
}
type IterationExpression ¶
type IterationExpression struct {
Base
Source Expression
Operation string
SliceSize Expression
Initial Expression
Limit Expression
WithIndex bool
Block *BlockExpression
}
IterationExpression is the portable collection iteration syntax. It remains an expression in the syntax tree so the original block delimiters can be retained, then lowers to structured iteration IR instead of a target-language callback.
type JSXAttribute ¶ added in v0.2.3
type JSXChild ¶ added in v0.2.3
type JSXChild interface {
Node
// contains filtered or unexported methods
}
type JSXElement ¶ added in v0.2.3
type JSXElement struct {
Base
Name string
Component Expression
Attributes []JSXAttribute
Children []JSXChild
Fragment bool
}
JSXElement is a provider-backed expression parsed into the shared AST. Intrinsic elements keep Name only; component elements additionally retain a normal TypeRB expression so imports and function references remain typed.
type JSXExpression ¶ added in v0.2.3
type JSXExpression struct {
Base
Value Expression
}
type LambdaExpression ¶ added in v0.2.3
type LambdaExpression struct {
Base
Parameters []Parameter
ReturnType TypeRef
// Fails is recovery-only for pre-0.3 lambda signatures.
Fails TypeRef
Body []Statement
}
LambdaExpression is a typed, lexically scoped function value. Unlike an iteration block, it owns return statements and can outlive its declaration.
type Literal ¶
type Literal struct {
Base
Kind LiteralKind
Raw string
}
type LiteralKind ¶
type LiteralKind string
const ( StringLiteral LiteralKind = "string" IntegerLiteral LiteralKind = "integer" FloatLiteral LiteralKind = "float" BooleanLiteral LiteralKind = "boolean" NilLiteral LiteralKind = "nil" )
type MemberExpression ¶
type MemberExpression struct {
Base
Receiver Expression
Name string
Safe bool
Namespace bool
}
type MethodStatement ¶
type MethodStatement struct {
Base
Name string
TypeParameters []TypeParameter
Parameters []Parameter
ReturnType TypeRef
// Fails is recovery-only for pre-0.3 source. The parser diagnoses every
// authored effect signature before later compiler phases can run it.
Fails TypeRef
Body []Statement
Class bool
}
type ModuleStatement ¶
type NativeExpression ¶
type NativeIsland ¶ added in v0.3.25
NativeIsland identifies source text owned by a target-language interop node. Formatters may reindent the island as a whole, but must not rewrite its internal tokens because their meaning is defined by the native language.
type NativeStatement ¶
NativeStatement and NativeBlock are explicit Ruby interoperability nodes. They are rejected by portable backends with a precise diagnostic.
type NewtypeStatement ¶ added in v0.3.18
NewtypeStatement declares a nominal source-level type with one concrete, non-nullable representation. Unlike a transparent alias, ordinary source assignments and calls do not implicitly cross the representation boundary.
type NextStatement ¶
type NextStatement struct{ Base }
type Parameter ¶
type Parameter struct {
Base
Name string
Type TypeRef
Default Expression
NamedOnly bool
Keyword bool
Rest bool
KeywordRest bool
NativeKeyword bool
NativeKeywordDefault Expression
}
type PatternBinding ¶
PatternBinding is a name introduced by a payload enum pattern. The payload type comes from the matched enum member and is attached in typed IR.
type RangeExpression ¶
type RangeExpression struct {
Base
Start Expression
End Expression
Exclusive bool
}
type RecordFieldStatement ¶
type RecordStatement ¶
type RecordStatement struct {
Base
Name string
TypeParameters []TypeParameter
Body []Statement
}
RecordStatement is a closed product type. Unlike ClassStatement it has keyword-only construction, public data fields, value semantics, and no inheritance. Backends lower it to their native data representation.
type ReturnStatement ¶
type ReturnStatement struct {
Base
Value Expression
}
type StringPart ¶
type StringPart struct {
Text string
Expression Expression
}
type SymbolLiteral ¶
type TryExpression ¶ added in v0.3.0
type TryExpression struct {
Base
Value Expression
}
TryExpression propagates the Err payload of a Result-producing Value from the nearest compatible result boundary. The checker attaches that boundary after parsing; the syntax tree retains only the authored operand.
type TypeAliasStatement ¶ added in v0.2.0
type TypeAliasStatement struct {
Base
Name string
TypeParameters []TypeParameter
Target TypeRef
}
TypeAliasStatement declares a transparent source-level alias. The target is retained in the syntax tree so tooling can show the authored name while the checker compares the expanded type.
type TypeParameter ¶
type TypeRef ¶
type UnaryExpression ¶
type UnaryExpression struct {
Base
Operator string
Operand Expression
}
type VariableStatement ¶
type WhileStatement ¶
type WhileStatement struct {
Base
Condition Expression
Body []Statement
}