add xor operator

This commit is contained in:
NotAFile 2022-01-17 17:36:24 +01:00
parent 71774b2a2c
commit 4d03535741
1 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,7 @@ pub struct Assign<'a> {
pub enum Operation<'a> { pub enum Operation<'a> {
And { a: Expression<'a>, b: Expression<'a> }, And { a: Expression<'a>, b: Expression<'a> },
Or { a: Expression<'a>, b: Expression<'a> }, Or { a: Expression<'a>, b: Expression<'a> },
Xor { a: Expression<'a>, b: Expression<'a> },
Not(Expression<'a>), Not(Expression<'a>),
} }
@ -113,6 +114,13 @@ fn operation(input: Span) -> IResult<Span, Operation> {
b, b,
}, },
), ),
map(
separated_pair(ws0(expression_nonrecurse), char('^'), ws0(expression)),
|(a, b)| Operation::Xor {
a,
b,
},
),
map( map(
preceded(char('~'), expression), preceded(char('~'), expression),
|expr| Operation::Not(expr), |expr| Operation::Not(expr),