grammar now able to match jobshop1 even with preface
This commit is contained in:
parent
632e908f95
commit
c62e012c97
File diff suppressed because it is too large
Load diff
|
@ -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]*"
|
||||||
|
@ -13,7 +14,7 @@ grammar = """
|
||||||
problem_data = trim_ws num_jobs ' ' num_machines eol job_data+
|
problem_data = trim_ws num_jobs ' ' num_machines eol job_data+
|
||||||
trim_ws = r'[ \t]*'
|
trim_ws = r'[ \t]*'
|
||||||
eol = "\n" / "\r\n"
|
eol = "\n" / "\r\n"
|
||||||
nonneg_num = r'\d+'
|
nonneg_num = r'\d+'
|
||||||
num_jobs = nonneg_num
|
num_jobs = nonneg_num
|
||||||
num_machines = nonneg_num
|
num_machines = nonneg_num
|
||||||
machine = nonneg_num
|
machine = nonneg_num
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue