HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/pkgs/pyparsing-3.1.2-py312haa95532_0/info/test/examples/nested.py
#
#  nested.py
#  Copyright, 2007 - Paul McGuire
#
#  Simple example of using nestedExpr to define expressions using
#  paired delimiters for grouping lists and sublists
#

from pyparsing import *

data = """
{
     { item1 "item with } in it" }
     {
      {item2a item2b }
      {item3}
     }

}
"""

# use {}'s for nested lists
nestedItems = nestedExpr("{", "}")
print((nestedItems + stringEnd).parseString(data).asList())

# use default delimiters of ()'s
mathExpr = nestedExpr()
print(mathExpr.parseString("((( ax + by)*C) *(Z | (E^F) & D))"))