moonrockz/gleam-parser/parser does not have a README file
pub(all) suberror ParseError {
ParseError(error~ : ParseErrorType, location~ : SrcSpan)
} derive(Eq, Debug)pub(all) enum ParseErrorType {
ExpectedEqual
ExpectedExpr
ExpectedName
ExpectedPattern
ExpectedType
ExpectedUpName
ExpectedValue
ExpectedDefinition
ExpectedDeprecationMessage
ExpectedExternalArguments
ExpectedFunctionDefinition
ExpectedTargetName
ExprLparStart
ExtraSeparator
IncorrectName(IncorrectNamePosition)
IncorrectUpName
InvalidBitArraySegment
InvalidBitArrayUnit
InvalidTailPattern
InvalidTupleAccess
LexError(Diagnostic)
NestedBitArrayPattern
NoLetBinding
NoValueAfterEqual
NotConstType
OpNakedRight
OpaqueTypeAlias
TooManyArgHoles
DuplicateAttribute
UnknownAttribute
UnknownTarget
ListSpreadWithoutElements
ListSpreadFollowedByElements
ListSpreadWithAnotherSpread(first_spread_location~ : SrcSpan)
UnexpectedLabel
UnexpectedEof
UnexpectedReservedWord
UnexpectedToken(token~ : TokenKind, expected~ : ArrayView[String], hint~ : String?)
UnexpectedFunction
ConcatPatternVariableLeftHandSide
ConcatPatternVariableWithSuffix(name~ : String)
ListSpreadWithoutTail
ExpectedFunctionBody
RedundantInternalAttribute
InvalidModuleTypePattern
ListPatternSpreadFollowedByElements
ExpectedRecordConstructor(type_name~ : String, public~ : Bool, opaque_~ : Bool, fields~ : ArrayView[RecordConstructorArg])
CallInClauseGuard
IfExpression
TypeDefinitionNoArguments
UnknownAttributeRecordVariant
IncorrectImportModuleSeparator(module_~ : String, item~ : String)
EmptyGuardBlock
ConstantInsideFunction
FunctionDefinitionAngleGenerics
TypeUsageAngleGenerics(module_~ : String?, name~ : String, arguments~ : ArrayView[TypeAst])
TypeDefinitionAngleGenerics(name~ : String, arguments~ : ArrayView[String])
MissingConstantAsMessage
RecordUpdateAfterFields
TooMuchNesting
} derive(Eq, Debug)pub(all) struct ParseResult {
module_ : Module
extra : ModuleExtra
warnings : ArrayView[Warning]
cst : ModuleCst
diagnostics : ArrayView[Diagnostic]
} derive(Eq, Debug)test {
let r = @parser.parse_text("pub fn main() {\n 1\n}\n")
inspect(r.module_.definitions.length(), content="1")
inspect(r.has_errors(), content="false")
inspect(r.cst.to_source(), content="pub fn main() {\n 1\n}\n")
}let definition_root_depth : Inttest {
let r = @parser.parse_text("const x = 1\n")
// $.location.start, $.name_location.start, $.value.location.start: 3
inspect(@parser.json_depth(r.module_.definitions[0].definition), content="3")
}let max_nesting : Inttest {
let e = @parser.parse_expression_text("1 + 2")
debug_inspect(e.location(), content="{ start: 0, end: 5 }")
}test {
let t = @parser.parse_type_text("List(a)")
debug_inspect(t.location(), content="{ start: 0, end: 7 }")
}Install
Download zipParser and parsing utilities for the Gleam programming language in MoonBit
Dependencies