erikrose / parsimonious

The fastest pure-Python PEG parser I can muster
MIT License
1.8k stars 126 forks source link

Question upon parsing #178

Open manfredlotz opened 3 years ago

manfredlotz commented 3 years ago

This is Fedora 33, Python 3.9.1 and parsimonious-0.8.1.

Looking at the sample

from parsimonious.grammar import Grammar grammar = Grammar(
    """
    bold_text  = bold_open text bold_close
    text       = ~"[A-Z 0-9]*"i
    bold_open  = "(("
    bold_close = "))"
""")

print(grammar.parse('((bold stuff))'))

I am wondering how I would specify the grammar if I would allow single ( and ) in text so that for example

print(grammar.parse('((bold (or something) stuff))'))

could be parsed.

Thanks a lot.