support for binary xnor

This commit is contained in:
Zachary Snow 2019-03-30 01:33:49 -04:00
parent 2314f97a96
commit c4f5718f51
2 changed files with 5 additions and 1 deletions

View File

@ -41,6 +41,7 @@ data BinOp
| LogOr
| BitAnd
| BitXor
| BitXnor
| BitOr
| Mul
| Div
@ -69,6 +70,7 @@ instance Show BinOp where
show LogOr = "||"
show BitAnd = "&"
show BitXor = "^"
show BitXnor = "~^"
show BitOr = "|"
show Mul = "*"
show Div = "/"

View File

@ -221,7 +221,7 @@ directive { Token Spe_Directive _ _ }
%left "||"
%left "&&"
%left "|" "~|"
%left "^" "^~"
%left "^" "^~" "~^"
%left "&" "~&"
%left "==" "!=" "===" "!==" "==?" "!=?"
%left "<" "<=" ">" ">="
@ -781,6 +781,8 @@ Expr :: { Expr }
| Expr "|" Expr { BinOp BitOr $1 $3 }
| Expr "^" Expr { BinOp BitXor $1 $3 }
| Expr "&" Expr { BinOp BitAnd $1 $3 }
| Expr "~^" Expr { BinOp BitXnor $1 $3 }
| Expr "^~" Expr { BinOp BitXnor $1 $3 }
| Expr "+" Expr { BinOp Add $1 $3 }
| Expr "-" Expr { BinOp Sub $1 $3 }
| Expr "*" Expr { BinOp Mul $1 $3 }