pydsl 0.5.0 is ready! It fixes some issues in the parser implementations and changes the way alphabet works, although the main changeset was already available in the version 0.4.1. Here is an updated session using pydsl:


from pydsl.File.BNF import load_bnf_file
from pydsl.File.Python import load_python_file
from pydsl.Translator import translator_factory

truefalse = load_bnf_file('pydsl/contrib/grammar/TrueFalse.bnf')
grammardefinition = load_bnf_file('pydsl/contrib/grammar/LogicalExpression.bnf', {'TrueFalse':truefalse})
grammardefinition.alphabet # Returns the alphabet used by this grammar
grammardefinition.minsize
grammardefinition.maxsize

from pydsl.Check import check
check(grammardefinition,['(']) # returns True or False

from pydsl.Parser import parse
parse(grammardefinition,[')']) # returns a ParseTree

from pydsl.Extract import extract
extract(grammardefinition,'abc()abc') # returns ('False',3,11)


solver = translator_factory(load_python_file('pydsl/contrib/transformer/echo.py'))
mystring = "True||False"
result = solver(mystring)
print(result)