jobshop2_parser now works, too

This commit is contained in:
Trolli Schmittlauch 2017-06-27 23:39:32 +02:00
parent 59cf66506f
commit 252e7d6ee0
2 changed files with 15 additions and 3 deletions

View file

@ -5,7 +5,14 @@ from typing import List, Tuple, Sequence, Optional, Union
from . import grammar, JobShopVisitor, JobShopProblem
class JobShop2Visitor(JobShopVisitor):
pass
def visit_job_shop2(self, node: arpeggio.ParseTreeNode, children: arpeggio.SemanticActionResults) -> JobShopProblem:
if self.debug:
print("job_shop2:\nchildren:", children)
problem = children[0]
if self.debug:
print("returning a", type(problem))
return problem
def parse_jobshop2_file(filename: Union[str, bytes]) -> JobShopProblem:
"""Open file with jobshop2-formatted data (single problem instance, no name & description),
@ -17,7 +24,7 @@ def parse_jobshop2_file(filename: Union[str, bytes]) -> JobShopProblem:
return arpeggio.visit_parse_tree(parse_tree, JobShop2Visitor())
def main():
print(type(parse_jobshop2_file('../inputdata/jobshop2/ta13').problem_data))
print(type(parse_jobshop2_file('../inputdata/jobshop2/ta13')))
parser = ParserPEG(grammar, "job_shop2", skipws=False)