support for arithmetic shifts

This commit is contained in:
Zachary Snow 2019-02-17 20:52:01 -05:00
parent d4c6c0d014
commit d34dc7dfeb
2 changed files with 7 additions and 1 deletions

View File

@ -228,6 +228,8 @@ data BinOp
| Le
| Gt
| Ge
| ShiftAL
| ShiftAR
deriving Eq
instance Show BinOp where
@ -250,6 +252,8 @@ instance Show BinOp where
Le -> "<="
Gt -> ">"
Ge -> ">="
ShiftAL -> "<<<"
ShiftAR -> ">>>"
instance Show Expr where
show x = case x of

View File

@ -148,7 +148,7 @@ string { Token Lit_string _ _ }
%left "&" "~&"
%left "==" "!=" "===" "!=="
%left "<" "<=" ">" ">="
%left "<<" ">>"
%left "<<" ">>" "<<<" ">>>"
%left "+" "-"
%left "*" "/" "%"
%left UPlus UMinus "!" "~" RedOps
@ -420,6 +420,8 @@ Expr :: { Expr }
| Expr "*" Expr { BinOp Mul $1 $3 }
| Expr "/" Expr { BinOp Div $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 BWNot $2 }
| "+" Expr %prec UPlus { UniOp UAdd $2 }