mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
Add parsePast functions
This commit is contained in:
parent
72d5cc6351
commit
01bf309e38
2 changed files with 14 additions and 3 deletions
|
@ -68,12 +68,17 @@ concat : Bytes, Bytes -> Bytes
|
||||||
## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)
|
## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)
|
||||||
## (USV) encoded as UTF-8.
|
## (USV) encoded as UTF-8.
|
||||||
##
|
##
|
||||||
## To parse a fixed-length UTF-8 string, you can use #Bytes.take and #Bytes.toUtf8.
|
## To parse an entire UTF-8 string, you can use #Bytes.toUtf8 or #Bytes.parsePastUtf8.
|
||||||
parseUtf8Usv : Bytes -> Result { answer : U32, rest : Bytes } [ Expected [ Utf8Usv ]* Bytes ]*
|
parseUtf8Usv : Bytes -> Result { answer : U32, rest : Bytes } [ Expected [ Utf8Usv ]* Bytes ]*
|
||||||
parseUtf16Usv : Bytes -> Result { answer : U32, rest : Bytes } [ Expected [ Utf16Usv ]* Bytes ]*
|
parseUtf16Usv : Bytes -> Result { answer : U32, rest : Bytes } [ Expected [ Utf16Usv ]* Bytes ]*
|
||||||
parseUtf8Grapheme : Bytes -> Result { answer : Utf8, rest : Bytes } [ Expected [ Utf8Grapheme ]* Bytes ]*
|
parseUtf8Grapheme : Bytes -> Result { answer : Utf8, rest : Bytes } [ Expected [ Utf8Grapheme ]* Bytes ]*
|
||||||
parseUtf16Grapheme : Bytes -> Result { answer : Utf16, rest : Bytes } [ Expected [ Utf16Grapheme ]* Bytes ]*
|
parseUtf16Grapheme : Bytes -> Result { answer : Utf16, rest : Bytes } [ Expected [ Utf16Grapheme ]* Bytes ]*
|
||||||
|
|
||||||
|
## If the bytes begin with the given UTF-8 string, return whatever bytes come
|
||||||
|
## after it.
|
||||||
|
parsePastUtf8 : Bytes, Utf8 -> Result Bytes [ Expected [ ExactUtf8 Utf8 ]* Bytes ]*
|
||||||
|
parsePastUtf16 : Bytes, Utf16 -> Result Bytes [ Expected [ ExactUtf16 Utf16 ]* Bytes ]*
|
||||||
|
|
||||||
# Little-Endian
|
# Little-Endian
|
||||||
parseLeU16 : Bytes -> Result { answer : U16, rest : Bytes } [ Expected [ U16 ]* Bytes ]*
|
parseLeU16 : Bytes -> Result { answer : U16, rest : Bytes } [ Expected [ U16 ]* Bytes ]*
|
||||||
parseLeI16 : Bytes -> Result { answer : I16, rest : Bytes } [ Expected [ I16 ]* Bytes ]*
|
parseLeI16 : Bytes -> Result { answer : I16, rest : Bytes } [ Expected [ I16 ]* Bytes ]*
|
||||||
|
|
|
@ -346,10 +346,16 @@ walkBackwardsUsv : Str, { start: state, step: (state, U32 -> state) } -> state
|
||||||
|
|
||||||
# Parsing
|
# Parsing
|
||||||
|
|
||||||
## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)
|
## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value).
|
||||||
## (USV).
|
|
||||||
parseUsv : Str a -> Result { answer : U32, rest : Str a } [ Expected [ Usv ]* (Str a) ]*
|
parseUsv : Str a -> Result { answer : U32, rest : Str a } [ Expected [ Usv ]* (Str a) ]*
|
||||||
|
## Parse an [extended grapheme cluster](http://www.unicode.org/glossary/#extended_grapheme_cluster).
|
||||||
parseGrapheme : Str a -> Result { answer : Str a, rest : Str a } [ Expected [ Grapheme ]* (Str a) ]*
|
parseGrapheme : Str a -> Result { answer : Str a, rest : Str a } [ Expected [ Grapheme ]* (Str a) ]*
|
||||||
|
|
||||||
|
## If the first string begins with the second, return whatever comes
|
||||||
|
## after the second.
|
||||||
|
parsePastStr : Str a, Str a -> Result (Str a) [ Expected [ ExactStr (Str a) ]* Bytes ]*
|
||||||
|
parsePastUsv : Str a, U32 -> Result (Str a) [ Expected [ ExactUsv U32 ]* Bytes ]*
|
||||||
|
|
||||||
parseU8 : Str a -> Result { answer : U8, rest : Str a } [ Expected [ U8 ]* (Str a) ]*
|
parseU8 : Str a -> Result { answer : U8, rest : Str a } [ Expected [ U8 ]* (Str a) ]*
|
||||||
parseI8 : Str a -> Result { answer : I8, rest : Str a } [ Expected [ I8 ]* (Str a) ]*
|
parseI8 : Str a -> Result { answer : I8, rest : Str a } [ Expected [ I8 ]* (Str a) ]*
|
||||||
parseU16 : Str a -> Result { answer : U16, rest : Str a } [ Expected [ U16 ]* (Str a) ]*
|
parseU16 : Str a -> Result { answer : U16, rest : Str a } [ Expected [ U16 ]* (Str a) ]*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue