Commit d34dc7df by Zachary Snow

support for arithmetic shifts

parent d4c6c0d0
...@@ -228,6 +228,8 @@ data BinOp ...@@ -228,6 +228,8 @@ data BinOp
| Le | Le
| Gt | Gt
| Ge | Ge
| ShiftAL
| ShiftAR
deriving Eq deriving Eq
instance Show BinOp where instance Show BinOp where
...@@ -250,6 +252,8 @@ instance Show BinOp where ...@@ -250,6 +252,8 @@ instance Show BinOp where
Le -> "<=" Le -> "<="
Gt -> ">" Gt -> ">"
Ge -> ">=" Ge -> ">="
ShiftAL -> "<<<"
ShiftAR -> ">>>"
instance Show Expr where instance Show Expr where
show x = case x of show x = case x of
......
...@@ -148,7 +148,7 @@ string { Token Lit_string _ _ } ...@@ -148,7 +148,7 @@ string { Token Lit_string _ _ }
%left "&" "~&" %left "&" "~&"
%left "==" "!=" "===" "!==" %left "==" "!=" "===" "!=="
%left "<" "<=" ">" ">=" %left "<" "<=" ">" ">="
%left "<<" ">>" %left "<<" ">>" "<<<" ">>>"
%left "+" "-" %left "+" "-"
%left "*" "/" "%" %left "*" "/" "%"
%left UPlus UMinus "!" "~" RedOps %left UPlus UMinus "!" "~" RedOps
...@@ -420,6 +420,8 @@ Expr :: { Expr } ...@@ -420,6 +420,8 @@ Expr :: { Expr }
| Expr "*" Expr { BinOp Mul $1 $3 } | Expr "*" Expr { BinOp Mul $1 $3 }
| Expr "/" Expr { BinOp Div $1 $3 } | Expr "/" Expr { BinOp Div $1 $3 }
| Expr "%" Expr { BinOp Mod $1 $3 } | Expr "%" Expr { BinOp Mod $1 $3 }
| Expr "<<<" Expr { BinOp ShiftAL $1 $3 }
| Expr ">>>" Expr { BinOp ShiftAR $1 $3 }
| "!" Expr { UniOp Not $2 } | "!" Expr { UniOp Not $2 }
| "~" Expr { UniOp BWNot $2 } | "~" Expr { UniOp BWNot $2 }
| "+" Expr %prec UPlus { UniOp UAdd $2 } | "+" Expr %prec UPlus { UniOp UAdd $2 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment