lukeparser / pybison

Use Bison directly from Python
https://pypi.org/project/pybison
GNU General Public License v2.0
26 stars 6 forks source link

Multiple run() invocations. #1

Closed sbrodehl closed 7 years ago

sbrodehl commented 7 years ago

This PR improves the usage of pybison by making it possible to invoke the run() method of a given parser multiple times.

Here is a short example:

from parser.attributes import AttributeParser
# create a parser object once
parser = BisonParser()

# use run() method with different inputs
with open("foo.md", "r") as foo:
    obj = parser.run(read=foo.read)
    print(json.dumps(obj, sort_keys=True, indent=4))

# let's use another file
with open("bar.md", "r") as bar:
    obj = parser.run(read=bar.read)
    print(json.dumps(obj, sort_keys=True, indent=4))