From 93976e360ecc1470ae0653cff92e02ec36966f92 Mon Sep 17 00:00:00 2001 From: Erez Sh Date: Sat, 1 Feb 2020 09:14:07 +0200 Subject: [PATCH] Fixed docs for maybe_placeholders --- docs/classes.md | 2 +- docs/tree_construction.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/classes.md b/docs/classes.md index 284ce73..fd9ee3d 100644 --- a/docs/classes.md +++ b/docs/classes.md @@ -34,7 +34,7 @@ The Lark class accepts a grammar string or file object, and keyword options: * **propagate_positions** - Propagate line/column count to tree nodes, at the cost of performance (default=`False`) -* **maybe_placeholders** - The `[]` operator returns `None` when not matched. Setting this to `False` makes it behave like the `?` operator, and return no value at all, which may be a little faster (default=`True`) +* **maybe_placeholders** - When True, the `[]` operator returns `None` when not matched. When `False`, `[]` behaves like the `?` operator, and return no value at all, which may be a little faster (default=`False`) * **lexer_callbacks** - A dictionary of callbacks of type f(Token) -> Token, used to interface with the lexer Token generation. Only works with the standard and contextual lexers. See [Recipes](recipes.md) for more information. diff --git a/docs/tree_construction.md b/docs/tree_construction.md index 9e61d4d..a4d6088 100644 --- a/docs/tree_construction.md +++ b/docs/tree_construction.md @@ -9,7 +9,9 @@ Using `item+` or `item*` will result in a list of items, equivalent to writing ` Using `item?` will return the item if it matched, or nothing. -Using `[item]` will return the item if it matched, or the value `None`, if it didn't. It's possible to force `[]` to behave like `()?`, by using the `maybe_placeholders=False` option when initializing Lark. +If `maybe_placeholders=False` (the default), then `[]` behaves like `()?`. + +If `maybe_placeholders=True`, then using `[item]` will return the item if it matched, or the value `None`, if it didn't. ### Terminals