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 = """
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
problem_instance = trim_ws "instance" ' ' instance_name trim_ws eol trim_ws eol sep_line description eol problem_data
description = r"[^\n]*"
@ -13,7 +14,7 @@ grammar = """
problem_data = trim_ws num_jobs ' ' num_machines eol job_data+
trim_ws = r'[ \t]*'
eol = "\n" / "\r\n"
nonneg_num = r'\d+'
nonneg_num = r'\d+'
num_jobs = nonneg_num
num_machines = nonneg_num
machine = nonneg_num

View file

@ -4,6 +4,6 @@ from common import grammar
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()
parse_tree = parser.parse(inputdata)