Skip to content

Instantly share code, notes, and snippets.

@gdeest
Created March 22, 2012 17:43
Show Gist options
  • Save gdeest/2160752 to your computer and use it in GitHub Desktop.
Save gdeest/2160752 to your computer and use it in GitHub Desktop.
Lambda-Term parser
varTerm = do
char <- noneOf ['.', '\\', '(', ')']
return $ Var char
appTerm = do
app <- char '(' *> lambdaTerm <* char ')'
arg <- lambdaTerm
return $ App app arg
absTerm = do
var <- char '\\' *> anyChar <* char '.'
fun <- lambdaTerm
return $ Abs var fun
lambdaTerm = do
term <- try varTerm <|> appTerm <|> absTerm
return term
expression = do
term <- lambdaTerm <* char '\n'
return term
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment