Skip to content

Commit

Permalink
Eliminate true and false from pgcl grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Legotier committed Jun 3, 2022
1 parent 0a598c2 commit 12167a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions probably/pgcl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@
| "∞" -> infinity
| "\\infty" -> infinity
var: CNAME
var: /(?!true|false)([_a-zA-Z]\\w*)/
%ignore /#.*$/m
%ignore /\\/\\/.*$/m
%ignore WS
%ignore ";"
%import common.CNAME
%import common.INT
%import common.FLOAT
%import common.WS
Expand Down Expand Up @@ -184,7 +183,7 @@ def _child_str(t: Tree, index: int) -> str:

def _parse_var(t: Tree) -> Var:
assert t.data == 'var'
assert t.children[0].type == 'CNAME' # type: ignore
#assert t.children[0].type == 'CNAME' # type: ignore (doesn't work anymore)
if t.children[0] in _illegal_variable_names:
raise SyntaxError(f"Illegal variable name: {t.children[0]}")
return str(_child_str(t, 0))
Expand Down
7 changes: 7 additions & 0 deletions tests/test_typechecking.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ def test_for_instr_errors():
res = check_program(program)
assert isinstance(res, CheckFail)
assert "In distribution parameter expressions, no variables are allowed. - Forgot parameter declaration?" in res.message

program = parse_pgcl("""
nat x
!Plot[x, true]
""")
res = check_program(program)
assert isinstance(res, CheckFail)

1 comment on commit 12167a5

@Legotier

This comment was marked as outdated.

Please sign in to comment.