]> ruin.nu Git - proglang.git/blobdiff - Parsyntax.y
streamlined the binary operators
[proglang.git] / Parsyntax.y
index f75fff6d2eebaa3458074b030d5c7b70b0de7f1d..dbd776705fe7fbb566e77bf45bda1e20787638ef 100644 (file)
@@ -71,7 +71,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 }
 
 
@@ -106,8 +106,8 @@ Stms :: { Stms }
 Stms : ListStm { Program (reverse $1) } 
 
 
-BOp :: { BOp }
-BOp : '<' { Lt } 
+Op0 :: { Op }
+Op0 : '<' { Lt } 
   | '<=' { ELt }
   | '>' { Gt }
   | '>=' { EGt }
@@ -128,6 +128,7 @@ Op2 : '*' { Times }
 Op :: { Op }
 Op : Op1 { $1 } 
   | Op2 { $1 }
+  | Op0 { $1 }
 
 
 Type :: { Type }
@@ -151,8 +152,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
 }