Last active
September 24, 2018 06:08
-
-
Save jimblandy/94268b0f298160515ce2902a7d4ec09a to your computer and use it in GitHub Desktop.
Working LALRPOP grammar for the lambda calculus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use ::Expr; | |
| use ::app_chain; | |
| grammar; | |
| pub Expr = { | |
| <Fun>, | |
| <App>, | |
| <Prim>, | |
| }; | |
| Fun: Box<Expr> = { | |
| "/" <Id> "." <Expr> => Box::new(Expr::Fun(<>)), | |
| }; | |
| App: Box<Expr> = { | |
| <Prim+> <Prim> => app_chain(<>), | |
| <Prim+> <Fun> => app_chain(<>), | |
| }; | |
| Prim = { | |
| <Var>, | |
| "(" <Expr> ")", | |
| } | |
| Var: Box<Expr> = <Id> => Box::new(Expr::Var(<>)); | |
| Id: String = <r"[a-zA-Z_][a-zA-Z0-9_]*"> => <>.to_owned(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment