Revise parser APIs a bit

This commit is contained in:
Richard Feldman 2021-04-29 20:26:18 -04:00
parent 2181558e69
commit 391a4f13db
3 changed files with 82 additions and 54 deletions

View file

@ -380,29 +380,29 @@ walkBackwardsUsv : Str, { start: state, step: (state, U32 -> state) } -> state
## Return the first [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)
## in the string, along with the rest of the string after that USV.
parseUsv : Str -> Result { usv : U32, rest : Str } [ StrWasEmpty ]*
parseUsv : Str -> Result { answer : U32, rest : Str } [ StrWasEmpty ]*
## Return the first [extended grapheme cluster](http://www.unicode.org/glossary/#extended_grapheme_cluster)
## in the string, along with the rest of the string after that grapheme.
parseGrapheme : Str -> Result { grapheme : Str, rest : Str } [ StrWasEmpty ]*
parseGrapheme : Str -> Result { answer : Str, rest : Str } [ Expected [ Grapheme ]* Str ]*
## If the first string begins with the second, return whatever comes
## after the second.
chompStr : Str, Str -> Result Str [ Expected [ ExactStr Str ]* Bytes ]*
chompUsv, U32 -> Result Str [ Expected [ ExactUsv U32 ]* Bytes ]*
chompUsv, U32 -> Result Str [ Expected [ Usv U32 ]* Bytes ]*
## If the string begins with digits which can represent a valid #U8, return
## that number along with the rest of the string after the digits.
parseU8 : Str -> Result { u8 : U8, rest : Str } [ Expected [ NumU8 ]* Str ]*
parseI8 : Str -> Result { i8 : I8, rest : Str } [ Expected [ NumI8 ]* Str ]*
parseU16 : Str -> Result { u16 : U16, rest : Str } [ Expected [ NumU16 ]* Str ]*
parseI16 : Str -> Result { i16 : I16, rest : Str } [ Expected [ NumI16 ]* Str ]*
parseU32 : Str -> Result { u32 : U32, rest : Str } [ Expected [ NumU32 ]* Str ]*
parseI32 : Str -> Result { i32 : I32, rest : Str } [ Expected [ NumI32 ]* Str ]*
parseU64 : Str -> Result { u64 : U64, rest : Str } [ Expected [ NumU64 ]* Str ]*
parseI64 : Str -> Result { i64 : I64, rest : Str } [ Expected [ NumI64 ]* Str ]*
parseU128 : Str -> Result { u128 : U128, rest : Str } [ Expected [ NumU128 ]* Str ]*
parseI128 : Str -> Result { i128 : I128, rest : Str } [ Expected [ NumI128 ]* Str ]*
parseU8 : Str -> Result { answer : U8, rest : Str } [ Expected [ NumU8 ]* Str ]*
parseI8 : Str -> Result { answer : I8, rest : Str } [ Expected [ NumI8 ]* Str ]*
parseU16 : Str -> Result { answer : U16, rest : Str } [ Expected [ NumU16 ]* Str ]*
parseI16 : Str -> Result { answer : I16, rest : Str } [ Expected [ NumI16 ]* Str ]*
parseU32 : Str -> Result { answer : U32, rest : Str } [ Expected [ NumU32 ]* Str ]*
parseI32 : Str -> Result { answer : I32, rest : Str } [ Expected [ NumI32 ]* Str ]*
parseU64 : Str -> Result { answer : U64, rest : Str } [ Expected [ NumU64 ]* Str ]*
parseI64 : Str -> Result { answer : I64, rest : Str } [ Expected [ NumI64 ]* Str ]*
parseU128 : Str -> Result { answer : U128, rest : Str } [ Expected [ NumU128 ]* Str ]*
parseI128 : Str -> Result { answer : I128, rest : Str } [ Expected [ NumI128 ]* Str ]*
parseF64 : Str -> Result { u128 : U128, rest : Str } [ Expected [ NumF64 ]* Str ]*
parseF32 : Str -> Result { i128 : I128, rest : Str } [ Expected [ NumF32 ]* Str ]*
parseF64 : Str -> Result { answer : U128, rest : Str } [ Expected [ NumF64 ]* Str ]*
parseF32 : Str -> Result { answer : I128, rest : Str } [ Expected [ NumF32 ]* Str ]*