diff --git a/compiler/builtins/docs/Bytes.roc b/compiler/builtins/docs/Bytes.roc index 9d0f4eeb23..104cd495c2 100644 --- a/compiler/builtins/docs/Bytes.roc +++ b/compiler/builtins/docs/Bytes.roc @@ -68,12 +68,17 @@ concat : Bytes, Bytes -> Bytes ## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value) ## (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 ]* parseUtf16Usv : Bytes -> Result { answer : U32, rest : Bytes } [ Expected [ Utf16Usv ]* Bytes ]* parseUtf8Grapheme : Bytes -> Result { answer : Utf8, rest : Bytes } [ Expected [ Utf8Grapheme ]* 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 parseLeU16 : Bytes -> Result { answer : U16, rest : Bytes } [ Expected [ U16 ]* Bytes ]* parseLeI16 : Bytes -> Result { answer : I16, rest : Bytes } [ Expected [ I16 ]* Bytes ]* diff --git a/compiler/builtins/docs/Str.roc b/compiler/builtins/docs/Str.roc index fc08053d95..92be6f6569 100644 --- a/compiler/builtins/docs/Str.roc +++ b/compiler/builtins/docs/Str.roc @@ -346,10 +346,16 @@ walkBackwardsUsv : Str, { start: state, step: (state, U32 -> state) } -> state # Parsing -## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value) -## (USV). +## Parse a [Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value). 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) ]* + +## 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) ]* 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) ]*