moonrockz/gleam-parser/ast does not have a README file
pub(all) enum ArgNames {
Discard(name~ : String, location~ : SrcSpan)
LabelledDiscard(label~ : String, label_location~ : SrcSpan, name~ : String, name_location~ : SrcSpan)
Named(name~ : String, location~ : SrcSpan)
NamedLabelled(label~ : String, label_location~ : SrcSpan, name~ : String, name_location~ : SrcSpan)
} derive(Eq, Debug)pub(all) enum AssignmentKind {
Let
Generated
Assert(location~ : SrcSpan, assert_keyword_start~ : ByteOffset, message~ : Expr?)
} derive(Eq, Debug)pub(all) enum BitArrayOption[V] {
Bytes(location~ : SrcSpan)
Int(location~ : SrcSpan)
Float(location~ : SrcSpan)
Bits(location~ : SrcSpan)
Utf8(location~ : SrcSpan)
Utf16(location~ : SrcSpan)
Utf32(location~ : SrcSpan)
Utf8Codepoint(location~ : SrcSpan)
Utf16Codepoint(location~ : SrcSpan)
Utf32Codepoint(location~ : SrcSpan)
Signed(location~ : SrcSpan)
Unsigned(location~ : SrcSpan)
Big(location~ : SrcSpan)
Little(location~ : SrcSpan)
Native(location~ : SrcSpan)
Size(location~ : SrcSpan, value~ : V, short_form~ : Bool)
Unit(location~ : SrcSpan, value~ : BitArrayUnit)
} derive(Eq, Debug)pub(all) struct BitArraySegment[V] {
location : SrcSpan
value : V
options : ArrayView[BitArrayOption[V]]
} derive(Eq, Debug)pub(all) enum BitArraySize {
Int(location~ : SrcSpan, value~ : String, int_value~ : BigInt)
Variable(location~ : SrcSpan, name~ : String)
BinaryOperator(location~ : SrcSpan, operator~ : IntOperator, left~ : BitArraySize, right~ : BitArraySize)
Block(location~ : SrcSpan, inner~ : BitArraySize)
}impl Eq for BitArraySizeimpl Debug for BitArraySizetest {
assert_eq(@ast.BitArrayUnit(255).to_int(), 255)
}#alias(new, deprecated="Use `BitArrayUnit::from_int(...)` instead")
fn BitArrayUnit::from_int(value : Int) -> BitArrayUnit?test {
debug_inspect(@ast.BitArrayUnit::from_int(256), content="None")
assert_eq(@ast.BitArrayUnit::from_int(255).unwrap().to_int(), 255)
}pub(all) struct CallArg[A] {
label : String?
location : SrcSpan
value : A
implicit : ImplicitCallArgOrigin?
} derive(Eq, Debug)pub(all) enum ClauseGuard {
Block(location~ : SrcSpan, value~ : ClauseGuard)
BinaryOperator(location~ : SrcSpan, operator~ : BinOp, operator_start~ : ByteOffset, left~ : ClauseGuard, right~ : ClauseGuard)
Not(location~ : SrcSpan, expression~ : ClauseGuard)
Var(location~ : SrcSpan, name~ : String)
TupleIndex(location~ : SrcSpan, index~ : TupleIndex, tuple~ : ClauseGuard)
FieldAccess(label_location~ : SrcSpan, index~ : TupleIndex?, label~ : String, container~ : ClauseGuard)
Constant(Constant)
}impl Eq for ClauseGuardimpl Debug for ClauseGuardpub(all) enum Constant {
Int(location~ : SrcSpan, value~ : String, int_value~ : BigInt)
Float(location~ : SrcSpan, value~ : String, float_value~ : Double)
String(location~ : SrcSpan, value~ : String)
Tuple(location~ : SrcSpan, elements~ : ArrayView[Constant])
List(location~ : SrcSpan, elements~ : ArrayView[Constant], tail~ : Constant?)
Record(location~ : SrcSpan, arguments_start_position~ : ByteOffset, module_~ : SpannedString?, name~ : String, arguments~ : ArrayView[CallArg[Constant]]?)
RecordUpdate(location~ : SrcSpan, constructor_location~ : SrcSpan, module_~ : SpannedString?, name~ : String, record~ : RecordBeingUpdated[Constant], arguments~ : ArrayView[RecordUpdateArg[Constant]])
BitArray(location~ : SrcSpan, segments~ : ArrayView[BitArraySegment[Constant]])
Var(location~ : SrcSpan, module_~ : SpannedString?, name~ : String)
BinaryOperator(location~ : SrcSpan, operator_start~ : ByteOffset, operator~ : BinOp, left~ : Constant, right~ : Constant)
Todo(location~ : SrcSpan, message~ : Constant?)
}pub(all) struct CustomType {
location : SrcSpan
end_position : ByteOffset
name : String
name_location : SrcSpan
publicity : Publicity
constructors : ArrayView[RecordConstructor]
documentation : Documentation?
deprecation : Deprecation
opaque_ : Bool
parameters : ArrayView[SpannedString]
external_erlang : External?
external_javascript : External?
} derive(Eq, Debug)pub(all) enum Definition {
Function(Function)
TypeAlias(TypeAlias)
CustomType(CustomType)
Import(Import)
ModuleConstant(ModuleConstant)
} derive(Eq, Debug)pub(all) enum Expr {
Int(location~ : SrcSpan, value~ : String, int_value~ : BigInt)
Float(location~ : SrcSpan, value~ : String, float_value~ : Double)
String(location~ : SrcSpan, value~ : String)
Block(location~ : SrcSpan, statements~ : ArrayView[Statement])
Var(location~ : SrcSpan, name~ : String)
Fn(location~ : SrcSpan, kind~ : FunctionLiteralKind, end_of_head_byte_index~ : ByteOffset, arguments~ : ArrayView[Arg], body~ : ArrayView[Statement], return_annotation~ : TypeAst?)
List(location~ : SrcSpan, elements~ : ArrayView[Expr], tail~ : Expr?)
Call(location~ : SrcSpan, fun~ : Expr, arguments~ : ArrayView[CallArg[Expr]], open_parenthesis~ : ByteOffset)
BinOp(location~ : SrcSpan, operator~ : BinOp, operator_start~ : ByteOffset, left~ : Expr, right~ : Expr)
Pipeline(expressions~ : ArrayView[Expr])
Case(location~ : SrcSpan, subjects~ : ArrayView[Expr], clauses~ : ArrayView[Clause]?)
FieldAccess(location~ : SrcSpan, label_location~ : SrcSpan, label~ : String, container~ : Expr)
Tuple(location~ : SrcSpan, elements~ : ArrayView[Expr])
TupleIndex(location~ : SrcSpan, index~ : TupleIndex, tuple~ : Expr)
Todo(kind~ : TodoKind, location~ : SrcSpan, message~ : Expr?)
Panic(location~ : SrcSpan, message~ : Expr?)
Echo(location~ : SrcSpan, keyword_end~ : ByteOffset, expression~ : Expr?, message~ : Expr?)
BitArray(location~ : SrcSpan, segments~ : ArrayView[BitArraySegment[Expr]])
RecordUpdate(location~ : SrcSpan, spread_start~ : ByteOffset, constructor_~ : Expr, record~ : RecordBeingUpdated[Expr], arguments~ : ArrayView[RecordUpdateArg[Expr]])
NegateBool(location~ : SrcSpan, value~ : Expr)
NegateInt(location~ : SrcSpan, value~ : Expr)
}pub(all) struct Function {
location : SrcSpan
body_start : ByteOffset?
end_position : ByteOffset
name : SpannedString?
arguments : ArrayView[Arg]
body : ArrayView[Statement]
publicity : Publicity
deprecation : Deprecation
return_annotation : TypeAst?
documentation : Documentation?
external_erlang : External?
external_javascript : External?
} derive(Eq, Debug)pub(all) struct Import {
documentation : String?
location : SrcSpan
module_location : SrcSpan
module_ : String
as_name : ImportAlias?
unqualified_values : ArrayView[UnqualifiedImport]
unqualified_types : ArrayView[UnqualifiedImport]
} derive(Eq, Debug)pub(all) struct ModuleConstant {
documentation : Documentation?
location : SrcSpan
publicity : Publicity
name : String
name_location : SrcSpan
annotation : TypeAst?
value : Constant
deprecation : Deprecation
} derive(Eq, Debug)pub(all) struct ModuleExtra {
module_comments : ArrayView[SrcSpan]
doc_comments : ArrayView[SrcSpan]
comments : ArrayView[SrcSpan]
empty_lines : ArrayView[ByteOffset]
new_lines : ArrayView[ByteOffset]
trailing_commas : ArrayView[ByteOffset]
} derive(Eq, Debug)pub(all) enum Pattern {
Int(location~ : SrcSpan, value~ : String, int_value~ : BigInt)
Float(location~ : SrcSpan, value~ : String, float_value~ : Double)
String(location~ : SrcSpan, value~ : String)
Variable(location~ : SrcSpan, name~ : String)
BitArraySize(BitArraySize)
Assign(name~ : String, location~ : SrcSpan, pattern~ : Pattern)
Discard(name~ : String, location~ : SrcSpan)
List(location~ : SrcSpan, elements~ : ArrayView[Pattern], tail~ : TailPattern?)
Constructor(location~ : SrcSpan, name_location~ : SrcSpan, name~ : String, arguments~ : ArrayView[CallArg[Pattern]], module_~ : SpannedString?, spread~ : SrcSpan?)
Tuple(location~ : SrcSpan, elements~ : ArrayView[Pattern])
BitArray(location~ : SrcSpan, segments~ : ArrayView[BitArraySegment[Pattern]])
StringPrefix(location~ : SrcSpan, left_location~ : SrcSpan, left_side_assignment~ : StringPrefixLeftSideAssignment?, right_location~ : SrcSpan, left_side_string~ : String, right_side_assignment~ : AssignName)
}pub(all) struct RecordConstructor {
location : SrcSpan
name_location : SrcSpan
name : String
arguments : ArrayView[RecordConstructorArg]
documentation : Documentation?
deprecation : Deprecation
} derive(Eq, Debug)pub(all) struct RecordConstructorArg {
label : SpannedString?
ast : TypeAst
location : SrcSpan
doc : Documentation?
} derive(Eq, Debug)pub(all) struct StringPrefixLeftSideAssignment {
name : String
name_start_position : ByteOffset
location : SrcSpan
} derive(Eq, Debug)test {
let index : @ast.TupleIndex = @ast.TupleIndex(18446744073709551615UL)
assert_eq(index.to_uint64(), 18446744073709551615UL)
}#alias(new, deprecated="Use `TupleIndex::from_int64(...)` instead")
fn TupleIndex::from_int64(value : Int64) -> TupleIndex?#deprecated("Use `TupleIndex(value)` instead")
fn TupleIndex::from_uint64(value : UInt64) -> TupleIndexpub(all) struct TypeAlias {
location : SrcSpan
alias_ : String
name_location : SrcSpan
parameters : ArrayView[SpannedString]
type_ast : TypeAst
publicity : Publicity
documentation : Documentation?
deprecation : Deprecation
} derive(Eq, Debug)pub(all) enum TypeAst {
Constructor(TypeAstConstructor)
Fn(TypeAstFn)
Var(TypeAstVar)
Tuple(TypeAstTuple)
Hole(TypeAstHole)
}pub(all) struct TypeAstConstructor {
location : SrcSpan
name : TypeAstConstructorName
arguments : ArrayView[TypeAst]
start_parentheses : ByteOffset?
} derive(Eq, Debug)pub(all) enum TypeAstConstructorName {
Qualified(module_~ : String, module_location~ : SrcSpan, dot_location~ : ByteOffset, name~ : SpannedString?)
Unqualified(name~ : String, location~ : SrcSpan)
} derive(Eq, Debug)pub(all) struct UnqualifiedImport {
location : SrcSpan
name : String
name_position : ByteOffset
as_name : String?
} derive(Eq, Debug)pub(all) enum Warning {
DeprecatedListPrepend(location~ : SrcSpan)
DeprecatedListPattern(location~ : SrcSpan)
DeprecatedListCatchAllPattern(location~ : SrcSpan)
DeprecatedListSpreadAsVariablePattern(location~ : SrcSpan, name~ : String)
DeprecatedRecordSpreadPattern(location~ : SrcSpan)
DeprecatedEmptyClauseGuard(location~ : SrcSpan)
DeprecatedTargetShorthand(target~ : Target, location~ : SrcSpan)
DetachedDocComment(location~ : SrcSpan)
} derive(Eq, Debug)test {
let value : @ast.Expr = Var(
location=@span.SrcSpan::from_ints(0, 1).unwrap(),
name="x",
)
assert_eq(@ast.decode_expr(@ast.encode_expr(value)), value)
}test {
let p = @ast.Parsed::{
module_: { definitions: [][:], },
extra: @ast.ModuleExtra::empty(),
warnings: [][:],
}
assert_eq(@ast.decode_parsed(@ast.encode_parsed(p)), p)
}test {
let value : @ast.Expr = Var(
location=@span.SrcSpan::from_ints(0, 1).unwrap(),
name="x",
)
assert_eq(@ast.decode_expr(@ast.encode_expr(value)), value)
}test {
let value : @ast.OracleOutput = Error(
kind="UnexpectedEof",
lexical_kind=None,
location=@span.SrcSpan::from_ints(0, 0).unwrap(),
)
assert_eq(@ast.decode_oracle_output(@ast.encode_oracle_output(value)), value)
}test {
let p = @ast.Parsed::{
module_: { definitions: [][:], },
extra: @ast.ModuleExtra::empty(),
warnings: [][:],
}
assert_eq(@ast.decode_parsed(@ast.encode_parsed(p)), p)
}Install
Download zipParser and parsing utilities for the Gleam programming language in MoonBit