diff options
author | Max Fischer <maxfischer2781@gmail.com> | 2021-06-28 15:33:33 +0200 |
---|---|---|
committer | Max Fischer <maxfischer2781@gmail.com> | 2021-06-28 15:33:33 +0200 |
commit | 48e0f9dc51f0810d1a907600b4834dd9a8514d48 (patch) | |
tree | 832e780435bee81bbe5f1c619b8be544a6426656 /pyparsing/core.py | |
parent | 118e8b9dd0ba3bc4c8e2052decacf31f0471bd58 (diff) | |
download | pyparsing-git-48e0f9dc51f0810d1a907600b4834dd9a8514d48.tar.gz |
adjusted docs for recursion cache
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index c346aeb..d5ee05f 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -807,14 +807,20 @@ class ParserElement(ABC): E = pp.Forward("E") num = pp.Word(pp.nums) + # match `num`, or `num '+' num`, or `num '+' num '+' num`, ... E <<= E + '+' - num | num print(E.parseString("1+2+3")) - Searching the ideal recursion depth requires matching elements at least one - additional time. In addition, recursion search naturally memoizes matches and - may thus skip evaluation during backtracking. This may break existing programs - with parse actions which rely on side-effects. + Recursion search naturally memoizes matches of ``Forward`` elements and may + thus skip reevaluation of parse actions during backtracking. This may break + programs with parse actions which rely on strict ordering of side-effects. + + Parameters: + + - cache_size_limit - (default=``None``) - memoize at most this many + ``Forward`` elements during matching; if ``None`` (the default), + memoize all ``Forward`` elements. Bounded Recursion parsing works similar but not identical to Packrat parsing, thus the two cannot be used together. Use ``force=True`` to disable any |