Skip to content

Commit 4e45d06

Browse files
committed
wip
1 parent 76eb58f commit 4e45d06

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

@@ -2364,6 +2366,12 @@ def test_parse_multiple_guards(self) -> None:
23642366
),
23652367
)
23662368

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

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

0 commit comments

Comments
 (0)