Skip to content

Frontend API Reference ​

Generated from the /// XML doc comments in src/Ashes.Frontend/. See the Compilation Pipeline for how this project fits into the compiler. This page is regenerated by tools/docs-api-gen on every docs build — edit the doc comments in the source, not this file.

Types ​

TypeKindSummarySource
AstSpansclassA side table mapping AST nodes to their originating source spans.source
CallArgumentListLayoutenumPreserved source layout for one parenthesized function-argument group.source
CapabilityDeclrecordA capability declaration: capability Clock = | now : Unit -> Int.source
CapabilityOperationrecordOne operation of a capability declaration: | now : Unit -> Int or a bare | log.source
CapabilityRefSyntaxrecordA single capability reference inside a needs row: Clock or State(Int).source
CompileDiagnosticExceptionclassThrown to abort compilation when one or more diagnostics have been collected.source
CompilePhaseTimingclassReports how long each compile phase takes, on stderr, when the ASHES_TIMING environment variable is set.source
DiagnosticCodesclassThe stable ASHnnn string codes attached to compiler diagnostics, used for cross-referencing with the diagnostics reference and for machine-readable filtering.source
DiagnosticEntryrecordA single compiler diagnostic: a source Span, a human-readable Message, and an optional Code from DiagnosticCodes.source
DiagnosticSerializationclassSerializes a program parse's public diagnostic corpus into the versioned, implementation-neutral parity format used by bootstrap tests.source
DiagnosticTextRendererclassRenders structured compiler diagnostics into human-readable, rustc-style text with a path:line:column header and, when the source is available, a caret-underlined snippet of the offending line.source
DiagnosticsclassA collecting sink for compiler diagnostics.source
ExportConstructorsrecordConstructor visibility for an exported type.source
ExportConstructors.AllrecordEvery constructor declared by the type is exported.source
ExportConstructors.HiddenrecordThe type is abstract and none of its constructors are exported.source
ExportConstructors.SelectedrecordOnly the named constructors are exported.source
ExportDeclrecordA module's explicit public interface.source
ExportItemrecordOne entry in an explicit module export interface.source
ExportItem.ModulerecordExports one direct nested module.source
ExportItem.TyperecordExports a type with the requested constructor visibility.source
ExportItem.ValuerecordExports one top-level value binding.source
ExprrecordBase of the expression AST.source
Expr.AddrecordInteger/float addition, Left + Right.source
Expr.AwaitrecordAn await expression that suspends until a task completes.source
Expr.BigIntLitrecordAn arbitrary-precision integer literal (an N-suffixed number).source
Expr.BitwiseAndrecordBitwise and, Left & Right.source
Expr.BitwiseNotrecordBitwise complement, ~Operand.source
Expr.BitwiseOrrecordBitwise or, Left | Right.source
Expr.BitwiseXorrecordBitwise xor, Left ^ Right.source
Expr.BoolLitrecordA boolean literal.source
Expr.CallrecordFunction application, f(x) or f x.source
Expr.ConsrecordA cons cell, Head :: Tail, prepending an element onto a list.source
Expr.DividerecordDivision, Left / Right.source
Expr.EqualrecordEquality comparison, Left == Right.source
Expr.FloatLitrecordA floating-point literal, carrying both its numeric value and the source text so the formatter can round-trip the exact written form.source
Expr.GreaterOrEqualrecordGreater-or-equal comparison, Left >= Right.source
Expr.GreaterThanrecordGreater-than comparison, Left > Right.source
Expr.HandlerecordHandler installation: handle body with | Capability.op(args) -> arm | return(r) -> arm.source
Expr.IfrecordA conditional, if Cond then Then else Else.source
Expr.IntLitrecordA signed integer literal.source
Expr.LambdarecordA single-parameter lambda, given (x) -> expr.source
Expr.LessOrEqualrecordLess-or-equal comparison, Left <= Right.source
Expr.LessThanrecordLess-than comparison, Left < Right.source
Expr.LetrecordA non-recursive binding, let Name = Value in Body.source
Expr.LetRecursiverecordA self-recursive binding, let recursive Name = Value in Body, where Name is in scope within its own Value.source
Expr.LetResultrecordA result-unwrapping binding, let? Name = Value in Body: binds the ok value of Value, short-circuiting the whole expression on error.source
Expr.ListLitrecordA list literal, [a, b, ...].source
Expr.LogicalAndrecordShort-circuit logical and, Left && Right: Right is evaluated only when Left is true.source
Expr.LogicalNotrecordBoolean logical negation, !Operand.source
Expr.LogicalOrrecordShort-circuit logical or, Left || Right: Right is evaluated only when Left is false.source
Expr.MatchrecordA pattern match, `match Value with | ...source
Expr.ModulorecordModulo, Left % Right.source
Expr.MultiplyrecordMultiplication, Left * Right.source
Expr.NotEqualrecordInequality comparison, Left != Right.source
Expr.PerformrecordExplicit capability-operation marker: perform Clock.now(x).source
Expr.QualifiedVarrecordA module-qualified name reference, Module.Name.source
Expr.RecordLitrecordRecord construction: TypeName(field1 = e1, field2 = e2).source
Expr.RecordUpdaterecordRecord update: { expr with field1 = e1, field2 = e2 }.source
Expr.ResultMapErrorPiperecordResult-map-error pipe, Left |!> Right: maps the error value of Left through Right, passing ok values through.source
Expr.ResultPiperecordResult-pipe, Left |?> Right: threads the ok value of Left into Right, short-circuiting on error.source
Expr.RuneLitrecordA Unicode scalar literal.source
Expr.ShiftLeftrecordLeft shift, Left << Right.source
Expr.ShiftRightrecordRight shift, Left >> Right.source
Expr.StrLitrecordA string literal.source
Expr.SubtractrecordSubtraction, Left - Right (also the desugared form of unary minus).source
Expr.TupleLitrecordA tuple literal, (a, b, ...).source
Expr.UIntLitrecordAn unsigned fixed-width integer literal (e.g.source
Expr.VarrecordA reference to an unqualified name.source
ExternalDeclrecordAn external declaration: a foreign function or opaque type imported from native code via the FFI surface.source
ExternalDecl.FunctionrecordAn external function binding, external name(params) -> ret [= "symbol"].source
ExternalDecl.OpaqueTyperecordAn opaque external type whose representation is unknown to the compiler, external type Name.source
ExternalParameterOwnershipenumOwnership declared at an external FFI parameter boundary.source
FfiStringOwnershipenumOwnership contract for a native UTF-8 string pointer.source
HandlerArmrecordOne arm of a `handle ...source
LexerclassForward-only tokenizer that turns source text into a stream of Token values, one per Next call.source
MatchCaserecord structOne arm of a Match: a pattern, its result expression, and an optional when guard.source
NeedsRowSyntaxrecordA written needs row: needs {A, B} (closed), needs {A, B | e} (open), or needs e (open, no required capabilities).source
ParsedTyperecordA type as written in an external FFI signature.source
ParsedType.BufferrecordA call-scoped contiguous input buffer, written FfiBuffer(T).source
ParsedType.NamedrecordA named FFI type, e.g.source
ParsedType.NativeStringrecordA borrowed or owned native UTF-8 string pointer copied at the call boundary.source
ParsedType.OutrecordA compiler-owned nullable output slot, written out T.source
ParsedType.PointerrecordA pointer to another FFI type, written *T.source
ParserclassRecursive-descent parser that turns a source string into an AST.source
PatternrecordBase of the pattern AST used in match arms and irrefutable let bindings.source
Pattern.AsrecordAn as-pattern, pattern as name, binding the complete matched value.source
Pattern.BoolLitrecordA boolean-literal pattern.source
Pattern.ConsrecordA cons pattern, Head :: Tail, matching a non-empty list.source
Pattern.ConstructorrecordA constructor pattern, Name(p1, ...), matching an ADT variant.source
Pattern.EmptyListrecordThe empty-list pattern, [].source
Pattern.IntLitrecordAn integer-literal pattern.source
Pattern.OrrecordAn or-pattern, left | right, sharing one arm body and guard.source
Pattern.RecordrecordA named record pattern, `Type { field = pattern, ...source
Pattern.RuneLitrecordA Unicode scalar literal pattern.source
Pattern.StrLitrecordA string-literal pattern.source
Pattern.TuplerecordA tuple pattern, (p1, p2, ...).source
Pattern.VarrecordA variable pattern that always matches and binds the value to a name.source
Pattern.WildcardrecordThe wildcard pattern, _, that matches anything without binding.source
ProgramrecordA whole compilation unit: an ordered sequence of top-level items followed by an optional trailing expression.source
ProvideBindingrecordOne operation implementation in a provide: | compare = Ashes.Text.compare.source
ProvideDeclrecordA static provider: provide Ord(Str) = | compare = ....source
SourcePositionEncodingenumThe coordinate encoding used for a line-relative character value.source
SourceTextIndexclassImmutable index over valid Unicode source text.source
TextSpanrecord structA half-open range of UTF-8 byte offsets into source text, used to locate diagnostics and AST nodes.source
Tokenrecord structA single lexical token: its Kind, the exact source Text it spanned, decoded numeric payloads, and the source position it occupied.source
TokenKindenumThe lexical category of a Token: keywords, operators, punctuation, literal kinds, and the end-of-input and error sentinels.source
TokenSerializationclassSerializes the public token stream into the versioned, implementation-neutral parity format used by bootstrap tests.source
TopLevelItemrecordA single top-level item, kept in source order.source
TopLevelItem.CapabilityrecordA top-level capability declaration.source
TopLevelItem.ExportrecordA leading module export interface.source
TopLevelItem.ExternalrecordA top-level external declaration.source
TopLevelItem.ImplementationrecordA top-level coherent trait implementation declaration.source
TopLevelItem.LetDeclrecordA top-level value binding: let Name = Value, or let recursive when IsRecursive.source
TopLevelItem.ProviderecordA top-level provide declaration (static capability satisfaction).source
TopLevelItem.RecursiveGrouprecordA mutual-recursion group: `let recursive A = ...source
TopLevelItem.TraitrecordA top-level static trait declaration.source
TopLevelItem.TyperecordA top-level type declaration.source
TopLevelItem.TypeAliasrecordA transparent type-alias declaration.source
TopLevelItem.ZeroCostTyperecordA zero-cost nominal type declaration.source
TraitConstraintSyntaxrecordA written static trait requirement such as Eq(a).source
TraitDeclrecordA top-level trait declaration.source
TraitImplementationDeclrecordA top-level coherent trait implementation declaration.source
TraitImplementationMethodBindingrecordOne method implementation or default override in a trait implementation declaration.source
TraitMethodDeclrecordOne method declared by a trait, with an optional ordinary-expression default.source
TypeAliasDeclrecordA transparent type alias declaration.source
TypeConstructorrecordOne constructor of a type declaration (also the single synthetic constructor of a record type).source
TypeDeclrecordA type declaration: an algebraic data type or (when IsRecord) a record type.source
TypeExprrecordA type expression written by the user in an annotation, e.g.source
TypeExpr.AppliedrecordA parameterised type application: List(Int), Result(Str, Int).source
TypeExpr.ArrowrecordA function type: Int -> Str, optionally carrying a capability row: Str -> Int uses {Prices}.source
TypeExpr.NamedrecordA simple named type or type parameter: Int, Str, T.source
TypeExpr.TupleTyperecordA tuple type: (Int, Str).source
TypeExpr.UnitTyperecordUnit written as an empty tuple: ().source
TypeExprExtensionsclassHelpers over TypeExpr trees.source
TypeParameterrecordA declared type parameter, e.g.source
ZeroCostTypeDeclrecordA zero-cost nominal type declaration.source

Parser ​

Recursive-descent parser that turns a source string into an AST. It drives a forward-only Lexer, reports recoverable errors into a Diagnostics sink rather than throwing, and produces either a full Program (ParseProgram) or a single Expr (ParseExpression).

MemberSignatureSummary
ParseExpressionExpr ParseExpression()Parses the input as a single expression and verifies that no tokens remain afterward. Used for contexts that expect one expression rather than a whole compilation unit (e.g. the REPL).
ParseProgramProgram ParseProgram()Parses a whole compilation unit — an ordered sequence of top-level declarations followed by an optional trailing expression (declaration* expr?) — into a Program. Imports are assumed stripped upstream. A file with no declarations must be a single expression.

Lexer ​

Forward-only tokenizer that turns source text into a stream of Token values, one per Next call. It skips whitespace and // line comments, recognizes keywords, operators, and literals (integer, unsigned-suffixed, float, big-int, string), and reports lexical errors into a Diagnostics sink. SavePosition / RestorePosition give the parser bounded backtracking.

MemberSignatureSummary
NextToken Next()Scans and returns the next token, advancing past it. Whitespace and // line comments are skipped first; at end of input a EOF token is returned.
RestorePositionvoid RestorePosition(int pos)Rewinds the lexer to a position previously returned by SavePosition.
SavePositionint SavePosition()Captures the current byte offset so it can later be handed back to RestorePosition for bounded lookahead/backtracking.