Parser
module Parser
Parses Kex source code into a structured AST at runtime.
Returns Result<Program, ParseError> — the AST includes module definitions, function signatures, type/record definitions, traits, make blocks, and doc-comments extracted from # lines.
Function bodies are intentionally omitted from the output.
parse
parse : String -> Result<Program, ParseError>
parse : String -> String -> Result<Program, ParseError>
Parses a Kex source string into a structured AST.
parseType
parseType : String -> Result<TypeRef, ParseError>
Parses a type expression string into a TypeRef.
parseExpression
parseExpression : String -> Result<Expression, ParseError>
Parses a single expression string into an Expression AST node.
type TypeRef
Structured representation of type expressions.
Variants
NamedType(String, [TypeRef])FunctionType([TypeRef], TypeRef)TupleType([TypeRef])ListType(TypeRef)MapType(TypeRef, TypeRef)UnionType([TypeRef])NullableType(TypeRef)TypeVar(String)AnyTypeNoneType
Methods
type PatternRef
Structured representation of patterns.
Variants
BindPattern(String)LiteralPattern(String)ConstructorPattern(String, [PatternRef])TuplePattern([PatternRef])ListPattern([PatternRef])WildcardPatternGuardedPattern(PatternRef, String)
Methods
type Expression
Structured representation of expression AST nodes.
Variants
LitInt(Int)LitFloat(Float)LitString(String)InterpolatedString([String], [Expression])LitBool(Bool)LitAtom(Atom)LitNoneIdentifier(String)BinaryOp(Expression, String, Expression)UnaryOp(String, Expression)Call(Expression, [Expression])TaggedLiteral(String, [String], [Expression])MethodCall(Expression, String, [Expression])If(Expression, [Expression], [Expression]?)Match(Expression, [Expression])ListLit([Expression])TupleLit([Expression])Block([Expression])Lambda([String], [Expression])Let(String, Expression)Var(String, Expression)Assign(String, Expression)Return(Expression)Spread(Expression)TrailingIf(Expression, Expression)While(Expression, [Expression])Loop([Expression])RangeLit(Expression, Expression)