• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A fast implementation of the Nix expression language


Commit MetaInfo

Révision376831c93fc2872a6134b52fd5bec158805e195f (tree)
l'heure2024-06-10 07:57:27
AuteurCorbin <cds@corb...>
CommiterCorbin

Message de Log

parser: Add weird let-expression and rec-expression.

Change Summary

Modification

--- a/parser.py
+++ b/parser.py
@@ -295,6 +295,14 @@ class WithBox(BaseBox):
295295 self.expr = expr
296296 def pretty(self): return "with %s; %s" % (self.scope.pretty(), self.expr.pretty())
297297
298+class WeirdLetBox(BaseBox):
299+ def __init__(self, binds): self.binds = binds
300+ def pretty(self): return "let " + self.binds.pretty()
301+
302+class RecBox(BaseBox):
303+ def __init__(self, binds): self.binds = binds
304+ def pretty(self): return "rec " + self.binds.pretty()
305+
298306 class LambdaBox(BaseBox):
299307 def __init__(self, binding, params, body):
300308 self.binding = binding
@@ -444,6 +452,12 @@ def stringQLEnd(p): return IncompleteQL([(p[0], trimBox(p[1], 1, -1))])
444452 @pg.production("expr_simple : URI")
445453 def exprURI(p): return StrBox(p[0].getstr())
446454
455+@pg.production("expr_simple : LET OPEN_BRACE binds CLOSE_BRACE")
456+def exprWeirdLet(p): return WeirdLetBox(p[2])
457+
458+@pg.production("expr_simple : REC OPEN_BRACE binds CLOSE_BRACE")
459+def exprRec(p): return RecBox(p[2])
460+
447461 enclosedRule("expr_simple : OPEN_BRACE binds CLOSE_BRACE", 1)
448462 enclosedRule("expr_simple : OPEN_PAREN expr CLOSE_PAREN", 1)
449463 enclosedRule("expr_simple : OPEN_BRACK expr_list CLOSE_BRACK", 1)