X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Parsyntax.y;h=dbd776705fe7fbb566e77bf45bda1e20787638ef;hb=d2416679eff983d31ea9b2de4bdd0124c50bd20d;hp=f75fff6d2eebaa3458074b030d5c7b70b0de7f1d;hpb=93b042040034d199c925248a2dd1c321773ab6d0;p=proglang.git diff --git a/Parsyntax.y b/Parsyntax.y index f75fff6..dbd7767 100644 --- a/Parsyntax.y +++ b/Parsyntax.y @@ -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 }