grammar now able to match jobshop1 even with preface

This commit is contained in:
Trolli Schmittlauch 2017-06-25 20:25:34 +02:00
parent 632e908f95
commit c62e012c97
3 changed files with 4 additions and 2248 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
grammar = """ grammar = """
job_shop1 = skip_preface job_shop1 = skip_preface
skip_preface = instance_list / (r"." skip_preface) # eat away lines of preface, until first problem_instance is encountered
skip_preface = (!problem_instance r"[^\n]+" skip_preface) / (eol skip_preface) / instance_list
instance_list = problem_instance (sep_line trim_ws eol problem_instance eol?)* eof_sep instance_list = problem_instance (sep_line trim_ws eol problem_instance eol?)* eof_sep
problem_instance = trim_ws "instance" ' ' instance_name trim_ws eol trim_ws eol sep_line description eol problem_data problem_instance = trim_ws "instance" ' ' instance_name trim_ws eol trim_ws eol sep_line description eol problem_data
description = r"[^\n]*" description = r"[^\n]*"

View file

@ -4,6 +4,6 @@ from common import grammar
parser = ParserPEG(grammar, "job_shop1", skipws=False,debug=True) parser = ParserPEG(grammar, "job_shop1", skipws=False,debug=True)
with open("./inputdata/jobshop1_noprefix.txt") as datafile: with open("./inputdata/jobshop1.txt") as datafile:
inputdata : str = datafile.read() inputdata : str = datafile.read()
parse_tree = parser.parse(inputdata) parse_tree = parser.parse(inputdata)