From b89de0e6cb3b95d17bd9b7ee3b17a9325bded45b Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 22 Jun 2017 23:49:44 +0200 Subject: [PATCH] rules now successfully parsed, but too deep recursion --- src/JobShopParser/jobshop1_parser.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/JobShopParser/jobshop1_parser.py b/src/JobShopParser/jobshop1_parser.py index a064077..90e44d7 100644 --- a/src/JobShopParser/jobshop1_parser.py +++ b/src/JobShopParser/jobshop1_parser.py @@ -1,10 +1,10 @@ -from parsomonious.grammar import Grammar +from parsimonious.grammar import Grammar grammar = Grammar( - """ + r""" start = skip_preface - skip_preface = instance_list / ~"."s skip_preface - eol = \n / \r\n + skip_preface = instance_list / (~"."s skip_preface) + eol = "\n" / "\r\n" _ = " " 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 @@ -17,3 +17,6 @@ grammar = Grammar( job_data = ~"[ \r\n0-9]*"s """) +with open("./inputdata/jobshop1.txt") as datafile: + inputdata : str = datafile.read() + print(grammar.parse(inputdata))