From 565fbd61dca527c23888e08783d0d91cee458524 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 2 Mar 2006 19:29:32 +0000 Subject: [PATCH] removed NoType and EDefault and added assert --- Abssyntax.hs | 29 +++++++++++-------------- Compile.hs | 2 -- Docsyntax.tex | 36 ++++++++++++++++--------------- Interpret.hs | 16 ++++---------- Lexsyntax.x | 2 +- Parsyntax.y | 39 ++++++++++++++++++--------------- Printsyntax.hs | 31 ++++++++++++--------------- Skelsyntax.hs | 31 ++++++++++++--------------- Typecheck.hs | 58 ++++++++++++++++++++++++++------------------------ syntax.cf | 39 ++++++++++++++++++++------------- 10 files changed, 141 insertions(+), 142 deletions(-) diff --git a/Abssyntax.hs b/Abssyntax.hs index d8ef904..ec85c8d 100644 --- a/Abssyntax.hs +++ b/Abssyntax.hs @@ -4,35 +4,38 @@ module Abssyntax where newtype Ident = Ident String deriving (Eq,Ord,Show) +data Type = + TInt + | TBool + deriving (Eq,Ord,Show) + +data Stms = + Program [Stm] + deriving (Eq,Ord,Show) + data Stm = - SDecl Type Ident Exp - | SExp Exp + SExp Exp | SBlock [Stm] - | SIf Exp Stm Stm | SWhile Exp Stm + | SIf Exp Stm Stm | SPrint Exp | SNoop + | SDecl Type Ident Exp deriving (Eq,Ord,Show) data Exp = EAss Ident Exp | EVar Ident | EInt Integer + | EBool Bool | ENeg Exp | ENot Exp - | EBool Bool | EReadI | EReadB - | ExpT Type Exp - | EDefault | BiOpExp Exp Op Exp | EPost Ident Op deriving (Eq,Ord,Show) -data Stms = - Program [Stm] - deriving (Eq,Ord,Show) - data Op = Lt | ELt @@ -46,9 +49,3 @@ data Op = | Div deriving (Eq,Ord,Show) -data Type = - TInt - | TBool - | NoType - deriving (Eq,Ord,Show) - diff --git a/Compile.hs b/Compile.hs index c3e93f9..69edecd 100644 --- a/Compile.hs +++ b/Compile.hs @@ -9,7 +9,6 @@ compileExp (EBool False) = "0"; compileExp (EInt n) = show n compileExp (EVar (Ident i)) = i compileExp (EAss (Ident i) e) = i++"="++compileExp e -compileExp EDefault = error "EDefault called from an illegal place" compileExp (BiOpExp e o e') = "("++compileExp e++")"++op o++"("++compileExp e'++")" compileExp (ENeg e) = "-("++compileExp e++")" compileExp (ENot e) ="!("++compileExp e++")" @@ -37,5 +36,4 @@ compileStm (SIf b s s') = "if("++compileExp b++")"++compileStm s++" \nelse "++co compileStm (SPrint e) = "printf(\"%d\\n\","++compileExp e++");\n" compileStm (SBlock ss) = "{\n"++concat (map (("\t"++).compileStm) ss)++"\n}\n" compileStm (SWhile e s) = "while("++compileExp e++")"++compileStm s -compileStm (SDecl t (Ident i) EDefault) = "int "++i++"=0;\n" compileStm (SDecl t (Ident i) e) = "int "++i++"="++compileExp e++";\n" diff --git a/Docsyntax.tex b/Docsyntax.tex index 09e4898..e0d2758 100644 --- a/Docsyntax.tex +++ b/Docsyntax.tex @@ -49,8 +49,8 @@ The reserved words used in syntax are the following: \\ The symbols used in syntax are the following: \\ \begin{tabular}{lll} -{\symb{{$=$}}} &{\symb{;}} &{\symb{\{}} \\ -{\symb{\}}} &{\symb{(}} &{\symb{)}} \\ +{\symb{;}} &{\symb{\{}} &{\symb{\}}} \\ +{\symb{{$=$}}} &{\symb{(}} &{\symb{)}} \\ {\symb{{$+$}{$+$}}} &{\symb{{$-$}{$-$}}} &{\symb{{$-$}}} \\ {\symb{!}} &{\symb{{$<$}}} &{\symb{{$<$}{$=$}}} \\ {\symb{{$>$}}} &{\symb{{$>$}{$=$}}} &{\symb{{$=$}{$=$}}} \\ @@ -73,13 +73,24 @@ All other symbols are terminals.\\ \end{tabular}\\ \begin{tabular}{lll} -{\nonterminal{Stm}} & {\arrow} &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ - & {\delimit} &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{;}} \\ - & {\delimit} &{\nonterminal{Exp}} {\terminal{;}} \\ +{\nonterminal{Type}} & {\arrow} &{\terminal{int}} \\ + & {\delimit} &{\terminal{bool}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{Stms}} & {\arrow} &{\nonterminal{ListStm}} \\ +\end{tabular}\\ + +\begin{tabular}{lll} +{\nonterminal{Stm}} & {\arrow} &{\nonterminal{Exp}} {\terminal{;}} \\ & {\delimit} &{\terminal{\{}} {\nonterminal{ListStm}} {\terminal{\}}} \\ - & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} \\ - & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} {\terminal{else}} {\nonterminal{Stm}} \\ + & {\delimit} &{\terminal{int}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ + & {\delimit} &{\terminal{bool}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}} \\ + & {\delimit} &{\terminal{int}} {\nonterminal{Ident}} {\terminal{;}} \\ + & {\delimit} &{\terminal{bool}} {\nonterminal{Ident}} {\terminal{;}} \\ & {\delimit} &{\terminal{while}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} \\ + & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} {\terminal{else}} {\nonterminal{Stm}} \\ + & {\delimit} &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} \\ & {\delimit} &{\terminal{print}} {\nonterminal{Exp}} {\terminal{;}} \\ \end{tabular}\\ @@ -104,9 +115,9 @@ All other symbols are terminals.\\ & {\delimit} &{\nonterminal{Ident}} {\terminal{{$-$}{$-$}}} \\ & {\delimit} &{\nonterminal{Ident}} \\ & {\delimit} &{\nonterminal{Integer}} \\ + & {\delimit} &{\nonterminal{Bool}} \\ & {\delimit} &{\terminal{{$-$}}} {\nonterminal{Exp3}} \\ & {\delimit} &{\terminal{!}} {\nonterminal{Exp3}} \\ - & {\delimit} &{\nonterminal{Bool}} \\ & {\delimit} &{\terminal{readInt}} \\ & {\delimit} &{\terminal{readBool}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} \\ @@ -117,10 +128,6 @@ All other symbols are terminals.\\ & {\delimit} &{\nonterminal{Stm}} {\nonterminal{ListStm}} \\ \end{tabular}\\ -\begin{tabular}{lll} -{\nonterminal{Stms}} & {\arrow} &{\nonterminal{ListStm}} \\ -\end{tabular}\\ - \begin{tabular}{lll} {\nonterminal{Op0}} & {\arrow} &{\terminal{{$<$}}} \\ & {\delimit} &{\terminal{{$<$}{$=$}}} \\ @@ -146,11 +153,6 @@ All other symbols are terminals.\\ & {\delimit} &{\nonterminal{Op0}} \\ \end{tabular}\\ -\begin{tabular}{lll} -{\nonterminal{Type}} & {\arrow} &{\terminal{int}} \\ - & {\delimit} &{\terminal{bool}} \\ -\end{tabular}\\ - \end{document} diff --git a/Interpret.hs b/Interpret.hs index 9e4dcff..5a792b9 100644 --- a/Interpret.hs +++ b/Interpret.hs @@ -23,7 +23,6 @@ eval (EBool b) = return (VBool b) eval (EInt n) = return (VInt n) eval (EVar i) = getVariableValue i eval (EAss i e) = setVariableValue i e -eval EDefault = error "EDefault called from an illegal place" eval (BiOpExp e o e') = do v <- eval e v'<- eval e' @@ -78,11 +77,6 @@ findVariable i (m:ms) = if member i m then lookup i m else findVariable i ms --setVariableValue :: (MonadState Variables m) => Ident -> Exp -> m Value --setVariableValue :: (MonadState Variables m) => Ident -> Exp -> m Value -addVariable :: Ident -> Exp -> StateT Variables IO () -addVariable i e = do - e' <- eval e - (m:ms) <- get - put $ (insert i e' m):ms setVariableValue :: Ident -> Exp -> StateT Variables IO Value setVariableValue i e = do @@ -113,9 +107,7 @@ execute (SBlock ss) = do execute (SWhile e s) = do (VBool b) <- eval e if b then execute s >> execute (SWhile e s) else return () -execute (SDecl t i EDefault) = do - case t of - TInt -> addVariable i (EInt 0) - TBool -> addVariable i (EBool False) - return () -execute (SDecl t i e) = addVariable i e >> return () +execute (SDecl t i e) =do + e' <- eval e + (m:ms) <- get + put $ (insert i e' m):ms diff --git a/Lexsyntax.x b/Lexsyntax.x index 2d4ef67..88f0e2d 100644 --- a/Lexsyntax.x +++ b/Lexsyntax.x @@ -16,7 +16,7 @@ $i = [$l $d _ '] -- identifier character $u = [\0-\255] -- universal: any character @rsyms = -- symbols and non-identifier-like reserved words - \= | \; | \{ | \} | \( | \) | \+ \+ | \- \- | \- | \! | \< | \< \= | \> | \> \= | \= \= | \! \= | \+ | \* | \/ + \; | \{ | \} | \= | \( | \) | \+ \+ | \- \- | \- | \! | \< | \< \= | \> | \> \= | \= \= | \! \= | \+ | \* | \/ :- "//" [.]* ; -- Toss single line comments diff --git a/Parsyntax.y b/Parsyntax.y index 461c967..02e94b0 100644 --- a/Parsyntax.y +++ b/Parsyntax.y @@ -14,10 +14,10 @@ import ErrM %tokentype { Token } %token - '=' { PT _ (TS "=") } ';' { PT _ (TS ";") } '{' { PT _ (TS "{") } '}' { PT _ (TS "}") } + '=' { PT _ (TS "=") } '(' { PT _ (TS "(") } ')' { PT _ (TS ")") } '++' { PT _ (TS "++") } @@ -59,14 +59,25 @@ Bool : 'true' { True } | 'false' { False } +Type :: { Type } +Type : 'int' { TInt } + | 'bool' { TBool } + + +Stms :: { Stms } +Stms : ListStm { Program (reverse $1) } + + Stm :: { Stm } -Stm : Type Ident '=' Exp ';' { SDecl $1 $2 $4 } - | Type Ident ';' { decl_ $1 $2 } - | Exp ';' { SExp $1 } +Stm : Exp ';' { SExp $1 } | '{' ListStm '}' { SBlock (reverse $2) } - | 'if' '(' Exp ')' Stm { if_ $3 $5 } - | 'if' '(' Exp ')' Stm 'else' Stm { SIf $3 $5 $7 } + | 'int' Ident '=' Exp ';' { declIntE_ $2 $4 } + | 'bool' Ident '=' Exp ';' { declBoolE_ $2 $4 } + | 'int' Ident ';' { declInt_ $2 } + | 'bool' Ident ';' { declBool_ $2 } | 'while' '(' Exp ')' Stm { SWhile $3 $5 } + | 'if' '(' Exp ')' Stm 'else' Stm { SIf $3 $5 $7 } + | 'if' '(' Exp ')' Stm { if_ $3 $5 } | 'print' Exp ';' { SPrint $2 } @@ -91,9 +102,9 @@ Exp3 : Ident '++' { postIncr_ $1 } | Ident '--' { postDecr_ $1 } | Ident { EVar $1 } | Integer { EInt $1 } + | Bool { EBool $1 } | '-' Exp3 { ENeg $2 } | '!' Exp3 { ENot $2 } - | Bool { EBool $1 } | 'readInt' { EReadI } | 'readBool' { EReadB } | '(' Exp ')' { $2 } @@ -104,10 +115,6 @@ ListStm : {- empty -} { [] } | ListStm Stm { flip (:) $1 $2 } -Stms :: { Stms } -Stms : ListStm { Program (reverse $1) } - - Op0 :: { Op } Op0 : '<' { Lt } | '<=' { ELt } @@ -133,11 +140,6 @@ Op : Op1 { $1 } | Op0 { $1 } -Type :: { Type } -Type : 'int' { TInt } - | 'bool' { TBool } - - { @@ -152,7 +154,10 @@ happyError ts = Bad $ "syntax error at " ++ tokenPos ts ++ if null ts then [] else (" before " ++ unwords (map prToken (take 4 ts))) myLexer = tokens -decl_ t_ v_ = SDecl t_ v_ EDefault +declIntE_ x_ e_ = SDecl TInt x_ e_ +declBoolE_ x_ e_ = SDecl TBool x_ e_ +declInt_ x_ = SDecl TInt x_ (EInt 0) +declBool_ x_ = SDecl TBool x_ (EBool False) if_ e_ s_ = SIf e_ s_ SNoop compExp_ e1_ o_ e2_ = BiOpExp e1_ o_ e2_ op1_ e1_ o_ e2_ = BiOpExp e1_ o_ e2_ diff --git a/Printsyntax.hs b/Printsyntax.hs index e84a1d3..ff0128e 100644 --- a/Printsyntax.hs +++ b/Printsyntax.hs @@ -87,15 +87,26 @@ instance Print Bool where False -> prPrec i 0 (concatD [doc (showString "false")]) +instance Print Type where + prt i e = case e of + TInt -> prPrec i 0 (concatD [doc (showString "int")]) + TBool -> prPrec i 0 (concatD [doc (showString "bool")]) + + +instance Print Stms where + prt i e = case e of + Program stms -> prPrec i 0 (concatD [prt 0 stms]) + + instance Print Stm where prt i e = case e of - SDecl type' id exp -> prPrec i 0 (concatD [prt 0 type' , prt 0 id , doc (showString "=") , prt 0 exp , doc (showString ";")]) SExp exp -> prPrec i 0 (concatD [prt 0 exp , doc (showString ";")]) SBlock stms -> prPrec i 0 (concatD [doc (showString "{") , prt 0 stms , doc (showString "}")]) - SIf exp stm0 stm -> prPrec i 0 (concatD [doc (showString "if") , doc (showString "(") , prt 0 exp , doc (showString ")") , prt 0 stm0 , doc (showString "else") , prt 0 stm]) SWhile exp stm -> prPrec i 0 (concatD [doc (showString "while") , doc (showString "(") , prt 0 exp , doc (showString ")") , prt 0 stm]) + SIf exp stm0 stm -> prPrec i 0 (concatD [doc (showString "if") , doc (showString "(") , prt 0 exp , doc (showString ")") , prt 0 stm0 , doc (showString "else") , prt 0 stm]) SPrint exp -> prPrec i 0 (concatD [doc (showString "print") , prt 0 exp , doc (showString ";")]) SNoop -> prPrec i 0 (concatD []) + SDecl type' id exp -> prPrec i 0 (concatD [prt 0 type' , prt 0 id , doc (showString "=") , prt 0 exp , doc (showString ";")]) prtList es = case es of [] -> (concatD []) @@ -106,22 +117,15 @@ instance Print Exp where EAss id exp -> prPrec i 0 (concatD [prt 0 id , doc (showString "=") , prt 0 exp]) EVar id -> prPrec i 3 (concatD [prt 0 id]) EInt n -> prPrec i 3 (concatD [prt 0 n]) + EBool bool -> prPrec i 3 (concatD [prt 0 bool]) ENeg exp -> prPrec i 3 (concatD [doc (showString "-") , prt 3 exp]) ENot exp -> prPrec i 3 (concatD [doc (showString "!") , prt 3 exp]) - EBool bool -> prPrec i 3 (concatD [prt 0 bool]) EReadI -> prPrec i 3 (concatD [doc (showString "readInt")]) EReadB -> prPrec i 3 (concatD [doc (showString "readBool")]) - ExpT type' exp -> prPrec i 0 (concatD [prt 0 type' , prt 0 exp]) - EDefault -> prPrec i 0 (concatD []) BiOpExp exp0 op exp -> prPrec i 0 (concatD [prt 0 exp0 , prt 0 op , prt 0 exp]) EPost id op -> prPrec i 0 (concatD [prt 0 id , prt 1 op]) -instance Print Stms where - prt i e = case e of - Program stms -> prPrec i 0 (concatD [prt 0 stms]) - - instance Print Op where prt i e = case e of Lt -> prPrec i 0 (concatD [doc (showString "<")]) @@ -136,11 +140,4 @@ instance Print Op where Div -> prPrec i 2 (concatD [doc (showString "/")]) -instance Print Type where - prt i e = case e of - TInt -> prPrec i 0 (concatD [doc (showString "int")]) - TBool -> prPrec i 0 (concatD [doc (showString "bool")]) - NoType -> prPrec i 0 (concatD []) - - diff --git a/Skelsyntax.hs b/Skelsyntax.hs index 07898ef..bc9bc0c 100644 --- a/Skelsyntax.hs +++ b/Skelsyntax.hs @@ -20,15 +20,26 @@ transBool x = case x of False -> failure x +transType :: Type -> Result +transType x = case x of + TInt -> failure x + TBool -> failure x + + +transStms :: Stms -> Result +transStms x = case x of + Program stms -> failure x + + transStm :: Stm -> Result transStm x = case x of - SDecl type' id exp -> failure x SExp exp -> failure x SBlock stms -> failure x - SIf exp stm0 stm -> failure x SWhile exp stm -> failure x + SIf exp stm0 stm -> failure x SPrint exp -> failure x SNoop -> failure x + SDecl type' id exp -> failure x transExp :: Exp -> Result @@ -36,22 +47,15 @@ transExp x = case x of EAss id exp -> failure x EVar id -> failure x EInt n -> failure x + EBool bool -> failure x ENeg exp -> failure x ENot exp -> failure x - EBool bool -> failure x EReadI -> failure x EReadB -> failure x - ExpT type' exp -> failure x - EDefault -> failure x BiOpExp exp0 op exp -> failure x EPost id op -> failure x -transStms :: Stms -> Result -transStms x = case x of - Program stms -> failure x - - transOp :: Op -> Result transOp x = case x of Lt -> failure x @@ -66,11 +70,4 @@ transOp x = case x of Div -> failure x -transType :: Type -> Result -transType x = case x of - TInt -> failure x - TBool -> failure x - NoType -> failure x - - diff --git a/Typecheck.hs b/Typecheck.hs index 6f65d6e..a78f8f0 100644 --- a/Typecheck.hs +++ b/Typecheck.hs @@ -12,29 +12,31 @@ inList :: Eq a => a -> [a] -> Bool inList _ [] = False inList a (x:xs) = if a == x then True else inList a xs +assert :: Monad m => Bool -> String -> m () +assert True _ = return () +assert False s = fail s + typeCheckExp :: (MonadState Types m) => Exp -> m Type typeCheckExp (BiOpExp e o e') = do t1 <- typeCheckExp e t2 <- typeCheckExp e' - if not(t1 == t2) then fail "The parameters for the binary operator aren't equal" - else if inList o [Eq,NEq] then return TBool - else if not(t1 == TInt) then fail "The parameters need to be of type int" - else if inList o [Plus,Minus,Times,Div] - then return TInt - else return TBool + assert (t1 == t2) "The parameters for the binary operator aren't equal" + if inList o [Eq,NEq] then return TBool + else do + assert (t1 == TInt) "The parameters need to be of type int" + if inList o [Plus,Minus,Times,Div] + then return TInt + else return TBool typeCheckExp (EVar i) = typeCheckVar i typeCheckExp (EAss i e) = do t <- typeCheckVar i t2 <- typeCheckExp e - if t == t2 then return t else fail $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t + assert (t == t2) $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t + return t typeCheckExp (EInt i) = return TInt typeCheckExp (EBool b) = return TBool typeCheckExp EReadI = return TInt typeCheckExp EReadB = return TBool -typeCheckExp (ExpT t e) = do - t2 <- typeCheckExp e - if t == t2 then return t else fail "Something went wrong ExpT is created with the wrong type" -typeCheckExp EDefault = return NoType typeCheckExp (EPost i op) = do TInt <- typeCheckVar i return TInt @@ -54,34 +56,34 @@ findVariable :: (MonadState Types m) => Ident -> Types -> m Type findVariable i [] = fail $ "Variable "++show i++" not found in any scope." findVariable i (m:ms) = if member i m then lookup i m else findVariable i ms -typeCheckStm :: (MonadState Types m) => Stm -> m Type -typeCheckStm SNoop = return NoType +typeCheckStm :: (MonadState Types m) => Stm -> m () +typeCheckStm SNoop = return () typeCheckStm (SExp e) = do typeCheckExp e - return NoType + return () typeCheckStm (SBlock ss) = do modify (empty:) mapM typeCheckStm ss modify tail - return NoType typeCheckStm (SIf e s s') = do TBool <- typeCheckExp e - NoType <- typeCheckStm s - NoType <- typeCheckStm s - return NoType + modify (empty:) + typeCheckStm s + modify (\s -> empty:tail s) + typeCheckStm s' + modify tail typeCheckStm (SWhile e s) = do TBool <- typeCheckExp e - NoType <- typeCheckStm s - return NoType + modify (empty:) + typeCheckStm s + modify tail typeCheckStm (SDecl t i e) = do t2 <- typeCheckExp e - if t == t2 || t2 == NoType then do - (m:ms) <- get - case insertLookupWithKey (\k a1 a2 -> a1) i t m of - (Nothing,m') -> put (m':ms) - _ -> fail $ "Duplicate variable declaration: "++show i - return NoType - else fail $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t + assert (t == t2) $ "Illegal to assign an expression of type "++show t2++" to variable "++show i++" of type "++show t + (m:ms) <- get + case insertLookupWithKey (\k a1 a2 -> a1) i t m of + (Nothing,m') -> put (m':ms) + _ -> fail $ "Duplicate variable declaration: "++show i typeCheckStm (SPrint e) = do typeCheckExp e - return NoType + return () diff --git a/syntax.cf b/syntax.cf index 7b84054..2640824 100644 --- a/syntax.cf +++ b/syntax.cf @@ -1,14 +1,27 @@ -- ordinary rules + +True. Bool ::= "true" ; +False. Bool ::= "false" ; + +TInt. Type ::= "int" ; +TBool. Type ::= "bool" ; + Program. Stms ::= [Stm] ; -SExp. Stm ::= Exp ";" ; -SBlock. Stm ::= "{" [Stm] "}" ; -SDecl. Stm ::= Type Ident "=" Exp ";" ; -decl. Stm ::= Type Ident ";" ; -define decl t v = SDecl t v EDefault ; +SExp. Stm ::= Exp ";" ; +SBlock. Stm ::= "{" [Stm] "}" ; +declIntE. Stm ::= "int" Ident "=" Exp ";" ; +declBoolE. Stm ::= "bool" Ident "=" Exp ";" ; +define declIntE x e = SDecl TInt x e; +define declBoolE x e = SDecl TBool x e; +declInt. Stm ::= "int" Ident ";" ; +declBool. Stm ::= "bool" Ident ";" ; +define declInt x = SDecl TInt x (EInt 0); +define declBool x = SDecl TBool x (EBool False); + SWhile. Stm ::= "while" "(" Exp ")" Stm ; SIf. Stm ::= "if" "(" Exp ")" Stm "else" Stm ; @@ -74,21 +87,17 @@ _. Op ::= Op2; _. Op ::= Op0; -True. Bool ::= "true" ; -False. Bool ::= "false" ; - -TInt. Type ::= "int" ; -TBool. Type ::= "bool" ; - -- pragmas -internal ExpT. Exp ::= Type Exp ; -internal SNoop. Stm ::= ; -internal EDefault. Exp ::= ; +-- internal ExpT. Exp ::= Type Exp ; +-- internal EDefault. Exp ::= ; internal BiOpExp. Exp ::= Exp Op Exp ; -internal NoType. Type ::= ; +-- internal NoType. Type ::= ; internal EPost. Exp ::= Ident Op1 ; +internal SNoop. Stm ::= ; +internal SDecl. Stm ::= Type Ident "=" Exp ";" ; + comment "/*" "*/" ; comment "//" ; -- 2.39.2