]> ruin.nu Git - proglang.git/blobdiff - Parsyntax.y
YEAH
[proglang.git] / Parsyntax.y
index f75fff6d2eebaa3458074b030d5c7b70b0de7f1d..461c967b366f8bf473c2b90877643b884aac1490 100644 (file)
@@ -23,6 +23,7 @@ import ErrM
  '++' { PT _ (TS "++") }
  '--' { PT _ (TS "--") }
  '-' { PT _ (TS "-") }
+ '!' { PT _ (TS "!") }
  '<' { PT _ (TS "<") }
  '<=' { PT _ (TS "<=") }
  '>' { PT _ (TS ">") }
@@ -71,7 +72,7 @@ Stm : Type Ident '=' Exp ';' { SDecl $1 $2 $4 }
 
 Exp :: { Exp }
 Exp : Ident '=' Exp { EAss $1 $3 } 
-  | Exp1 BOp Exp1 { BExp $1 $2 $3 }
+  | Exp1 Op0 Exp1 { compExp_ $1 $2 $3 }
   | Exp1 { $1 }
 
 
@@ -91,6 +92,7 @@ Exp3 : Ident '++' { postIncr_ $1 }
   | Ident { EVar $1 }
   | Integer { EInt $1 }
   | '-' Exp3 { ENeg $2 }
+  | '!' Exp3 { ENot $2 }
   | Bool { EBool $1 }
   | 'readInt' { EReadI }
   | 'readBool' { EReadB }
@@ -106,8 +108,8 @@ Stms :: { Stms }
 Stms : ListStm { Program (reverse $1) } 
 
 
-BOp :: { BOp }
-BOp : '<' { Lt } 
+Op0 :: { Op }
+Op0 : '<' { Lt } 
   | '<=' { ELt }
   | '>' { Gt }
   | '>=' { EGt }
@@ -128,6 +130,7 @@ Op2 : '*' { Times }
 Op :: { Op }
 Op : Op1 { $1 } 
   | Op2 { $1 }
+  | Op0 { $1 }
 
 
 Type :: { Type }
@@ -151,8 +154,9 @@ happyError ts =
 myLexer = tokens
 decl_ t_ v_ = SDecl t_ v_ EDefault
 if_ e_ s_ = SIf e_ s_ SNoop
-op1_ e1_ o_ e2_ = OpExp e1_ o_ e2_
-op2_ e1_ o_ e2_ = OpExp e1_ o_ e2_
+compExp_ e1_ o_ e2_ = BiOpExp e1_ o_ e2_
+op1_ e1_ o_ e2_ = BiOpExp e1_ o_ e2_
+op2_ e1_ o_ e2_ = BiOpExp e1_ o_ e2_
 postIncr_ i_ = EPost i_ Plus
 postDecr_ i_ = EPost i_ Minus
 }