improve module
This commit is contained in:
parent
901472e8b5
commit
c3953449ff
|
@ -1,6 +1,8 @@
|
|||
from typing import List, Tuple, Sequence, Optional, Union
|
||||
import arpeggio
|
||||
|
||||
__all__ = ["jobshop1_parser", "jobshop2_parser"]
|
||||
|
||||
grammar = """
|
||||
# starting point for jobshop1 input file
|
||||
job_shop1 = skip_preface
|
||||
|
@ -78,7 +80,7 @@ class JobShopVisitor(arpeggio.PTNodeVisitor):
|
|||
if len(job_numbers) % 2 ==1:
|
||||
raise ParseError("Odd number of numbers in job data")
|
||||
# returns list of (duration, machine) tuples
|
||||
return list(zip(job_numbers[1::2], job_numbers[0::2]))
|
||||
return list(zip(job_numbers[1::2], job_numbers[0::2])) # [::2] returns only every second element of the list
|
||||
|
||||
def visit_problem_data(self, node: arpeggio.ParseTreeNode, children: arpeggio.SemanticActionResults) -> JobShopProblem:
|
||||
if self.debug:
|
||||
|
|
Loading…
Reference in a new issue