From 9727eb02264331b3771084ab58778dfbd7fff756 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Sun, 17 Nov 2019 20:12:44 +0200 Subject: [PATCH] Added info to the docs about maybe_placeholders (Issue #451) --- docs/tree_construction.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/tree_construction.md b/docs/tree_construction.md index 6b581e0..9e61d4d 100644 --- a/docs/tree_construction.md +++ b/docs/tree_construction.md @@ -7,6 +7,10 @@ For example, the rule `node: child1 child2` will create a tree node with two chi Using `item+` or `item*` will result in a list of items, equivalent to writing `item item item ..`. +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. + ### Terminals Terminals are always values in the tree, never branches.