From de4fbddfffe9c3cf39114608e3d3e5268c3cc2e4 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 30 Dec 2020 19:38:10 -0500 Subject: Add unary & to bit Also unary + and fix precedence of unary -. --- bin/bit.y | 4 +++- bin/man1/bit.1 | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/bit.y b/bin/bit.y index 583a0280..33347ff5 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 , -- cgit 1.4.1 ref='/src/log/home/.config/git/ignore?follow=1'>log tree commit diff
path: root/home/.config/git/ignore (unfollow)
Commit message (Expand)Author
2020-06-08Prefix mandoc with exec in about-filterJune McEnroe
2020-06-07Remove mktemp options from mkbuiltins, mktokensJune McEnroe
2020-06-07Cast z_stream fields to size_tJune McEnroe
2020-06-07Call static_assert by _Static_assertJune McEnroe
2020-06-07Add OpenBSD to install.shJune McEnroe
2020-06-03Add The Song of AchillesJune McEnroe
2020-06-01Allow redirecting input in everJune McEnroe
2020-05-31Add %c conversion to c scriptJune McEnroe
2020-05-31Add c script to READMEJune McEnroe
2020-05-31Add c scriptJune McEnroe
2020-05-31Update mdoc source URLsJune McEnroe
2020-05-26Remove unfinished PSF fontsJune McEnroe