lambda-calculus-interpreter/grammar.peggy

15 lines
436 B
Plaintext
Raw Normal View History

2024-02-13 21:57:27 -05:00
LambdaTerm = Application / Abstraction / Variable
Application = LPAREN _ left:LambdaTerm _ right:LambdaTerm RPAREN { return { application: { left, right } }; }
Abstraction = LPAREN _ LAMBDA _ param:Variable _ DOT _ body:LambdaTerm RPAREN { return { abstraction: { param, body } }; }
Variable = param:[a-zA-Z0-9]+ { return param.join(""); }
LPAREN = "("
RPAREN = ")"
DOT = "."
LAMBDA = "λ" / "\\"
_ = ("\n" / " " / "\t" / "\r\n")*