mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-09-11 19:47:31 +03:00
.. | ||
.gitignore | ||
Eval.hs | ||
happyParser.cabal | ||
Lexer.x | ||
Main.hs | ||
Makefile | ||
Parser.y | ||
README.md | ||
stack.yaml | ||
Syntax.hs |
Happy
A simple example use of the Happy/Alex toolchain to generate parsers.
To compile and run:
$ cabal run
Usage:
Happy> 42
Tokens: [TokenNum 42]
Syntax: Right (Lit (LInt 42))
42
Happy> (\x -> x) 1
Tokens: [TokenLParen,TokenLambda,TokenSym "x",TokenArrow,TokenSym "x",TokenRParen,TokenNum 1]
Syntax: Right (App (Lam "x" (Var "x")) (Lit (LInt 1)))
1
License
Released under MIT license.