Skip to content

Commit e99c777

Browse files
committed
wip
1 parent fe17914 commit e99c777

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scrapscript.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ def xp(n: float) -> Prec:
305305
"::": lp(2000),
306306
"@": rp(1001),
307307
"": rp(1000),
308-
"guard": rp(5.5),
309308
">>": lp(14),
310309
"<<": lp(14),
311310
"^": rp(13),
@@ -329,6 +328,7 @@ def xp(n: float) -> Prec:
329328
"||": rp(7),
330329
"|>": rp(6),
331330
"<|": lp(6),
331+
"guard": rp(5.5),
332332
"->": lp(5),
333333
"|": rp(4.5),
334334
":": lp(4.5),
@@ -345,7 +345,9 @@ def xp(n: float) -> Prec:
345345
HIGHEST_PREC: float = max(max(p.pl, p.pr) for p in PS.values())
346346

347347

348-
OPER_CHARS = set("".join(PS.keys())) - set("guard")
348+
# TODO(max): Consider making "guard" an operator with only punctuation (but
349+
# leave syntax-level "guard" keyword)
350+
OPER_CHARS = set(c for c in "".join(PS.keys()) if not c.isalpha())
349351
assert " " not in OPER_CHARS
350352

351353

@@ -2365,6 +2367,12 @@ def test_parse_multiple_guards(self) -> None:
23652367
),
23662368
)
23672369

2370+
def test_parse_guard_pipe(self) -> None:
2371+
self.assertEqual(
2372+
parse(tokenize("| x guard x |> f -> x")),
2373+
MatchFunction([MatchCase(Var("x"), Apply(Var("f"), Var("x")), Var("x"))]),
2374+
)
2375+
23682376

23692377
class MatchTests(unittest.TestCase):
23702378
def test_match_with_equal_ints_returns_empty_dict(self) -> None:

0 commit comments

Comments
 (0)