Add AST to Parser
This commit is contained in:
parent
b51be83eff
commit
bf4592540a
2 changed files with 21 additions and 1 deletions
20
app/Parser.hs
Normal file
20
app/Parser.hs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
module Parser where
|
||||||
|
|
||||||
|
import qualified Lexer
|
||||||
|
|
||||||
|
type AST = Expr
|
||||||
|
|
||||||
|
data Expr = Add Term Expr
|
||||||
|
| Sub Term Expr
|
||||||
|
| ETerm Term
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
data Term = Mult Factor Term
|
||||||
|
| Div Factor Term
|
||||||
|
| TFactor Factor
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
data Factor = Integer Int
|
||||||
|
| Parantheses Expr
|
||||||
|
| NegFactor Factor
|
||||||
|
deriving Show
|
||||||
|
|
@ -52,7 +52,7 @@ executable simple-arithmetic-compiler
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
|
|
||||||
-- Modules included in this executable, other than Main.
|
-- Modules included in this executable, other than Main.
|
||||||
other-modules: Lexer
|
other-modules: Lexer, Parser
|
||||||
|
|
||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue