-
-
Save pdubroy/984ad6e3ecf181b1c15c to your computer and use it in GitHub Desktop.
Ohm declarative binding syntax
This file contains 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
// `ident <- env` means parse an identifier only if it exists in env. | |
Expr<env> | |
= LetExpr<env> | |
| WhereExpr<env> | |
| ident <- env | |
LetExpr<env> | |
= "letseq" LetSeqBindingsAndBody<env> | |
| "letrec" LetRecBindingsAndBody<env> | |
| "letpar" LetParBindingsAndBody<env> | |
// `ident -> env'` means parse an identifier, and add it to a new environment | |
// named `env'` which delegates to `env`. | |
LetSeqBindingsAndBody<env> | |
= ident -> env' "=" expr<env> "," LetSeqBindingsAndBody<env'> | |
| ident -> env' "=" expr<env> "in" Expr<env'> | |
LetRecBindingsAndBody<env> | |
= ident -> env' "=" expr<env'> "," LetRecBindingsAndBody<env'> | |
| ident -> env' "=" expr<env'> "in" Expr<env'> | |
LetParBindingsAndBody<env> | |
= ident -> env' "=" expr<env> "," LetParBindingsAndBody<env> // Uh oh, env' is never passed on... | |
| ident -> env' "=" expr<env> "in" Expr<env'> | |
WhereExpr<env> | |
= Expr<env'> "where" WhereSeqBindings<env> // This also doesn't work, as Expr needs the env produced by the deepest invocation of WhereSeqBindings | |
WhereSeqBindings = ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment