Added force_create param to table load/create.
@@ -26,15 +26,24 @@ LALR = 1
def create_load_table(grammar, itemset_type=LR_1, start_production=1,
- prefer_shifts=False, prefer_shifts_over_empty=True):
+ prefer_shifts=False, prefer_shifts_over_empty=True,
+ force_create=False):
"""
Construct table by loading from file if present and newer than the grammar.
If table file is older than the grammar or non-existent calculate the table
and save to file.
+
+ Arguments:
+ see create_table
+
+ force_create(bool): If set to True table will be created even if table file
+ exists.
+
"""
create_table_file = True
table_file_name = None
+ if not force_create:
if grammar.file_path:
file_basename, _ = os.path.splitext(grammar.file_path)
table_file_name = "{}.pgt".format(file_basename)
@@ -48,7 +57,7 @@ def create_load_table(grammar, itemset_type=LR_1, start_production=1,
create_table_file = True
break
- if create_table_file:
+ if create_table_file or force_create:
table = create_table(grammar, itemset_type, start_production,
prefer_shifts, prefer_shifts_over_empty)
if table_file_name:
