Skip to content

Commit

Permalink
adding --version option and better error printing when MAX$ is missin…
Browse files Browse the repository at this point in the history
…g from limits.py
  • Loading branch information
Harniver committed Dec 9, 2023
1 parent a92f3a6 commit 718afa8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# make-templates 0.2.003
# make-templates 0.2.004

This is a simple python-based tool generating solution templates (containing code for reading input and writing output), for tasks in either the yaml format for CMS or in the Terry format.

Expand Down
8 changes: 8 additions & 0 deletions make_templates/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def replace_start(lines : List[str], targets : List[str], lang : str, name : str
return lines[:i] + v + lines[j:]

def main(args):
if args.version:
print("make-templates " + find_version())
exit(0)
# load task.yaml
if not path.isfile('task.yaml'):
print("[ERROR] File task.yaml not found")
Expand Down Expand Up @@ -195,6 +198,11 @@ def script():
description="make-templates " + find_version(),
epilog="This script should be run in the root directory of a task.",
)
parser.add_argument(
"-v", "--version",
action="store_true",
help="prints the version number and exits",
)
parser.add_argument(
"targets",
nargs="*",
Expand Down
3 changes: 3 additions & 0 deletions make_templates/targets/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def build_consts(consts:set, bounds:dict):
return ""
s = ""
for c in consts:
if c not in bounds:
print(f"[ERROR] {c} missing in limits.py but {c[-1]} is used to define array lengths")
exit(1)
s += "#define %s %s\n" % (c, bounds[c])
return s + "\n"

Expand Down
3 changes: 3 additions & 0 deletions make_templates/targets/pas.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def build_consts(consts:set, bounds:dict):
return ""
s = ""
for c in consts:
if c not in bounds:
print(f"[ERROR] {c} missing in limits.py but {c[-1]} is used to define array lengths")
exit(1)
s += "%s = %s;\n" % (c, bounds[c])
return "const\n" + indent(s) + "\n"

Expand Down

0 comments on commit 718afa8

Please sign in to comment.