rules now successfully parsed, but too deep recursion

This commit is contained in:
Trolli Schmittlauch 2017-06-22 23:49:44 +02:00
parent 608af7d2ff
commit b89de0e6cb

View file

@ -1,10 +1,10 @@
from parsomonious.grammar import Grammar from parsimonious.grammar import Grammar
grammar = Grammar( grammar = Grammar(
""" r"""
start = skip_preface start = skip_preface
skip_preface = instance_list / ~"."s skip_preface skip_preface = instance_list / (~"."s skip_preface)
eol = \n / \r\n eol = "\n" / "\r\n"
_ = " " _ = " "
instance_list = problem_instance (sep_line problem_instance eol)* eof instance_list = problem_instance (sep_line problem_instance eol)* eof
problem_instance = strip_whitespace "instance" _ instance_name eol eol sep_line description eol job_data problem_instance = strip_whitespace "instance" _ instance_name eol eol sep_line description eol job_data
@ -17,3 +17,6 @@ grammar = Grammar(
job_data = ~"[ \r\n0-9]*"s job_data = ~"[ \r\n0-9]*"s
""") """)
with open("./inputdata/jobshop1.txt") as datafile:
inputdata : str = datafile.read()
print(grammar.parse(inputdata))