diff --git a/src/JobShopParser/common.py b/src/JobShopParser/common.py index 3cb01a3..778beda 100644 --- a/src/JobShopParser/common.py +++ b/src/JobShopParser/common.py @@ -1,23 +1,29 @@ grammar = """ + # starting point for jobshop1 input file job_shop1 = skip_preface - # eat away lines of preface, until first problem_instance is encountered + # eat away lines of preface, until first problem_instance is encountered; then the list of instances start 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]*" instance_name = r"\w+" sep_line = trim_ws plus_line trim_ws eol + # lines out of multiple + signs plus_line = r"\+\+\++" + # EOF is a builtin rule matching end of file eof_sep = trim_ws plus_line " EOF " plus_line trim_ws eol* EOF - + # entry point for jobshop2 input files job_shop2 = problem_data EOF problem_data = trim_ws num_jobs ' ' num_machines eol job_data+ + # used for skipping arbitrary number of non-breaking whitespace trim_ws = r'[ \t]*' + # git may change line-endings on windows, so we have to match on both eol = "\n" / "\r\n" nonneg_num = r'\d+' num_jobs = nonneg_num num_machines = nonneg_num machine = nonneg_num duration = nonneg_num + # task data for 1 job job_data = ' '* machine ' '+ duration (' '+ machine ' '+ duration)* trim_ws eol """