Skip to content

Commit 3947568

Browse files
committed
Improve README.md
1 parent ab541c6 commit 3947568

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ final id3 = seq2(letter(), [letter(), digit()].toChoiceParser().star()); // (3)
6161
> [!NOTE]
6262
> 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<dynamic>`. The parser built from lists (2) provides the most generic type, `List<Object>` in this example. The last variation (3) is the only one that doesn't lose type information and produces a [record](https://dart.dev/language/records) (tuple) with two typed elements `String` and `List<String>`.
6363
64+
> [!IMPORTANT]
65+
> Parsers read input greedily: if a parser fails, it does not retry. Only `ChoiceParser` provides backtracking by trying its children in order until one succeeds; if none do, the whole choice fails.
66+
6467
### Parsing Some Input
6568

6669
To actually consume an input string we use the method `Parser.parse`:
@@ -409,7 +412,7 @@ trace(parser).parse('f1');
409412

410413
The above snippet produces the following output:
411414

412-
```
415+
```text
413416
SequenceParser<dynamic>
414417
SingleCharacterParser[letter expected]
415418
Success<String>[1:2]: f

0 commit comments

Comments
 (0)