From d7fddce0c3184c758827b53ef18b7f744ddee871 Mon Sep 17 00:00:00 2001 From: Lukas Renggli Date: Fri, 22 Sep 2023 17:25:54 +0300 Subject: [PATCH] Fix some missing pieces in README.md. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 019eabef..c41d68cb 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,10 @@ The operators `&` and `|` are overloaded and create a sequence and a choice pars ```dart final id1 = letter().seq(letter().or(digit()).star()); // (1): Parser> final id2 = [letter(), [letter(), digit()].toChoiceParser().star()].toSequenceParser(); // (2): Parser> -final id3 = seq2(letter(), [letter(), digit()].toChoiceParser().star()); // (3): Parser>> +final id3 = seq2(letter(), [letter(), digit()].toChoiceParser().star()); // (3): Parser<(String, List)> ``` -Note that the inferred type of the 3 parsers is not equivalent: Due to [github.com/dart-lang/language/issues/1557](https://github.com/dart-lang/language/issues/1557) the inferred type of sequence and choice parsers created with operators (0) or chained function calls (1) is `Parser`. The parser built from lists (2) provides the most generic type, `List` in this example. The last variation (3) is the only one that doesn't loose type information and produces a sequence (tuple) with two typed elements `String` and `List`. +Note that the inferred type of the 3 parsers is not equivalent: Due to [github.com/dart-lang/language/issues/1557](https://github.com/dart-lang/language/issues/1557) the inferred type of sequence and choice parsers created with operators (0) or chained function calls (1) is `Parser`. The parser built from lists (2) provides the most generic type, `List` in this example. The last variation (3) is the only one that doesn't loose type information and produces a [record](https://dart.dev/language/records) (tuple) with two typed elements `String` and `List`. ### Parsing Some Input @@ -120,6 +120,7 @@ Terminal parsers are the simplest. We've already seen a few of those: - `char('a')` (or `'a'.toParser()`) parses the character *a*. - `digit()` parses a single digit from *0* to *9*. - `letter()` parses a single letter from *a* to *z* and *A* to *Z*. +- `newline()` parses a newline character sequence, i.e. *\n* (Linux) and *\r\n* (Windows). - `pattern('a-f')` (or `'a-f'.toParser(isPattern: true)`) parses a single character between *a* and *f*. - `patternIgnoreCase('a-f')` (or `'a-f'.toParser(isPattern: true, caseInsensitive: true)`) parses a single character between *a* and *f*, or *A* and *F*. - `string('abc')` (or `'abc'.toParser()`) parses the string *abc*.