diff options
author | Eric Wald <gitter@brainshell.org> | 2019-03-10 14:53:14 -0600 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2019-03-10 15:53:14 -0500 |
commit | ed2f5ec744ddc25242f947be8ba798d9fca6a674 (patch) | |
tree | 8d06927cb0810d13c2f0ecb314f8c3faca8785e6 /unitTests.py | |
parent | 64cbc7245410223e33d81666381821526be48650 (diff) | |
download | pyparsing-git-ed2f5ec744ddc25242f947be8ba798d9fca6a674.tar.gz |
Descriptive names for Forward expressions (#71)
Resolves the infinite recursion potential by setting a temporary name during resolution.
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/unitTests.py b/unitTests.py index 4786255..b7d11bc 100644 --- a/unitTests.py +++ b/unitTests.py @@ -2891,7 +2891,8 @@ class UnicodeExpressionTest(ParseTestCase): class SetNameTest(ParseTestCase): def runTest(self): from pyparsing import (oneOf,infixNotation,Word,nums,opAssoc,delimitedList,countedArray, - nestedExpr,makeHTMLTags,anyOpenTag,anyCloseTag,commonHTMLEntity,replaceHTMLEntity) + nestedExpr,makeHTMLTags,anyOpenTag,anyCloseTag,commonHTMLEntity,replaceHTMLEntity, + Forward,ZeroOrMore) a = oneOf("a b c") b = oneOf("d e f") @@ -2904,6 +2905,8 @@ class SetNameTest(ParseTestCase): [ (('?',':'),3,opAssoc.LEFT), ]) + recursive = Forward() + recursive <<= a + ZeroOrMore(b + recursive) tests = [ a, @@ -2913,6 +2916,7 @@ class SetNameTest(ParseTestCase): arith_expr.expr, arith_expr2, arith_expr2.expr, + recursive, delimitedList(Word(nums).setName("int")), countedArray(Word(nums).setName("int")), nestedExpr(), @@ -2926,10 +2930,11 @@ class SetNameTest(ParseTestCase): a | b | c d | e | f {a | b | c | d | e | f} - Forward: ... + Forward: + | - term + | - term - Forward: ... + Forward: ?: term ?: term + Forward: {a | b | c [{d | e | f Forward: ...}]...} int [, int]... (len) int... nested () expression |