diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-13 19:57:27 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-13 19:57:27 -0700 |
commit | 36834bb8f64de5e6e4d16553172ef7c75fc5fc4c (patch) | |
tree | c5f0baf754ecfbac342d3657716f709c363c0413 /grammar.peggy | |
download | lambda-calculus-interpreter-36834bb8f64de5e6e4d16553172ef7c75fc5fc4c.tar.gz lambda-calculus-interpreter-36834bb8f64de5e6e4d16553172ef7c75fc5fc4c.zip |
interpreter
Diffstat (limited to 'grammar.peggy')
-rw-r--r-- | grammar.peggy | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/grammar.peggy b/grammar.peggy new file mode 100644 index 0000000..c2dd580 --- /dev/null +++ b/grammar.peggy @@ -0,0 +1,14 @@ +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")* |