now *really* renamed functions and modules

contributes to #3
This commit is contained in:
Trolli Schmittlauch 2017-06-29 22:23:12 +02:00
parent 92ddb2740e
commit 72e5800604
2 changed files with 8 additions and 8 deletions

View file

@ -33,23 +33,23 @@ class JobShop1Visitor(JobShopVisitor):
def visit_trim_ws(self, node:arpeggio.ParseTreeNode, children: arpeggio.SemanticActionResults) -> None:
return None
def parse_jobshop1_string(inputdata: str) -> JobShopProblem:
def parse_string(inputdata: str) -> JobShopProblem:
"""parse string with jobshop1-formatted data (multiple problem instances)
and return list of JobShopProblem s"""
parse_tree = parser.parse(inputdata)
return arpeggio.visit_parse_tree(parse_tree, JobShop1Visitor())
def parse_jobshop1_file(filename: Union[str, bytes]) -> List[JobShopProblem]:
def parse_file(filename: Union[str, bytes]) -> List[JobShopProblem]:
"""Open file with jobshop1-formatted data (multiple problem instances),
parse it and return list of JobShopProblem s"""
with open(filename) as datafile:
inputdata: str = datafile.read()
return parse_jobshop1_string(inputdata)
return parse_string(inputdata)
def main():
print(parse_jobshop1_file("../inputdata/jobshop1.txt"))
print(parse_file("../inputdata/jobshop1.txt"))
parser = ParserPEG(grammar, "job_shop1", skipws=False)

View file

@ -14,7 +14,7 @@ class JobShop2Visitor(JobShopVisitor):
print("returning a", type(problem))
return problem
def parse_jobshop2_string(inputdata: str) -> JobShopProblem:
def parse_string(inputdata: str) -> JobShopProblem:
"""parse string of jobshop2-formatted data (single problem instance, no name & description)
and return JobShopProblem
Raises a ParseError exception on errors"""
@ -24,17 +24,17 @@ def parse_jobshop2_string(inputdata: str) -> JobShopProblem:
raise ParseError("Error while parsing problem input data at line {}, col {}:\n Rules {} did not match.".format(e.line, e.col, e.rules))
return arpeggio.visit_parse_tree(parse_tree, JobShop2Visitor())
def parse_jobshop2_file(filename: Union[str, bytes]) -> JobShopProblem:
def parse_file(filename: Union[str, bytes]) -> JobShopProblem:
"""Open file with jobshop2-formatted data (single problem instance, no name & description),
parse it and return JobShopProblem
Raises a ParseError exception on errors"""
with open(filename) as datafile:
inputdata: str = datafile.read()
return parse_jobshop2_string(inputdata)
return parse_string(inputdata)
def main():
print(parse_jobshop2_file('../inputdata/jobshop2/ta13'))
print(parse_file('../inputdata/jobshop2/ta13'))
parser = ParserPEG(grammar, "job_shop2", skipws=False)