Module: Fusion::AST

Included in:
Interpreter, Parser
Defined in:
lib/fusion/ast.rb

Defined Under Namespace

Modules: Expression, Pattern, Statement

Constant Summary collapse

Identifier =

A syntactic identifier: a bound/looked-up name, a ‘.key`, or a `…rest` binder. Mirrors the lexer’s ident rule (Lexer#ident_start? / #ident_part?). Object keys are arbitrary strings, not identifiers, so they stay ‘String`.

/\A[A-Za-z_][A-Za-z0-9_]*\z/
ArrayItem =

Auxiliary typed parts: the elements a collection node holds. NOT themselves expressions or patterns, so they live outside the marker families and never satisfy an ‘Expression`/`Pattern` field.

TypedData.define(value: Expression)
ArraySpread =

…expr inside an array

TypedData.define(value: Expression)
KeyValuePair =

“k”: expr inside an object

TypedData.define(key: String, value: Expression)
ObjectSpread =

…expr inside an object

TypedData.define(value: Expression)
Clause =

one pattern => body of a function

TypedData.define(pattern: Pattern, body: Expression)
PatternItem =

a sub-pattern of an array pattern

TypedData.define(pattern: Pattern)
PatternPair =

“k”: pat inside an object pattern

TypedData.define(key: String, pattern: Pattern)
PatternRest =

…name (name nil = ignore) in either

TypedData.define(name: ->(v) { Identifier === v || v.nil? })