diff options
author | June McEnroe <june@causal.agency> | 2020-12-30 19:38:10 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-30 19:38:10 -0500 |
commit | 239bad36c1d5468de0752e8d59264358939a0713 (patch) | |
tree | fc66228e70eaf305c3f646b2521c4236efb8b3fd /bin | |
parent | Support unary + in order (diff) | |
download | src-239bad36c1d5468de0752e8d59264358939a0713.tar.gz src-239bad36c1d5468de0752e8d59264358939a0713.zip |
Add unary & to bit
Also unary + and fix precedence of unary -.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bit.y | 4 | ||||
-rw-r--r-- | bin/man1/bit.1 | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/bin/bit.y b/bin/bit.y index 61b6f465..2b2ee27c 100644 --- a/bin/bit.y +++ b/bin/bit.y @@ -63,7 +63,9 @@ expr: | expr 'G' { $$ = $1 << 30; } | expr 'T' { $$ = $1 << 40; } | '~' expr { $$ = ~$2; } - | '-' expr { $$ = -$2; } + | '&' expr %prec '~' { $$ = MASK($2); } + | '+' expr %prec '~' { $$ = +$2; } + | '-' expr %prec '~' { $$ = -$2; } | expr '*' expr { $$ = $1 * $3; } | expr '/' expr { $$ = $1 / $3; } | expr '%' expr { $$ = $1 % $3; } diff --git a/bin/man1/bit.1 b/bin/man1/bit.1 index 06fd182f..b91a10e1 100644 --- a/bin/man1/bit.1 +++ b/bin/man1/bit.1 @@ -27,6 +27,11 @@ The .Sy -> operator is used for arithmetic shift. .It +The unary +.Sy & +operator is equivalent to +.Sy (1 << x) - 1 . +.It The postfix operators .Sy K , .Sy M , |