-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogico.hs
37 lines (31 loc) · 865 Bytes
/
Logico.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Logico where
import Text.Parsec
import Text.Parsec.Expr
import qualified Text.Parsec.Token as T
import Text.Parsec.Language
import DataTypes
import Lex
import Relacional
import Tabelas
exprL = do {parenteses logic
<|> Rel
<$> exprR}
logic = buildExpressionParser tabelaL exprL
<?> "expressao logica"
expr = buildExpressionParser tabela fator
<?> "expressao"
exprR = do {
e <- expr;
r <- opr;
r e <$> expr;}
fator = do parenteses expr
<|> constant
<|> Lit <$> literal
<|> try (do
i <- identifier;
e <- parenteses (list expr)
return (Chamada i e)
)
<|> IdVar <$> identifier
<?> "expressao simples"
constant = do {c <- numero; case c of Left n -> return (Const (CInt n)); Right n -> return (Const (CDouble n))}