From dc1bb39579d2bdfedc7f5a99315b9f0dc95d15f0 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 30 Dec 2020 18:31:36 -0500 Subject: Add postfix $ operator to bit --- bin/bit.y | 2 ++ bin/man1/bit.1 | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bit.y b/bin/bit.y index 0a9bc7ce..61b6f465 100644 --- a/bin/bit.y +++ b/bin/bit.y @@ -35,6 +35,7 @@ static uint64_t vars[128]; %} +%left '$' %right '=' %left '|' %left '^' @@ -75,6 +76,7 @@ expr: | expr '^' expr { $$ = $1 ^ $3; } | expr '|' expr { $$ = $1 | $3; } | Var '=' expr { $$ = vars[$1] = $3; } + | expr '$' { $$ = $1; } ; %% diff --git a/bin/man1/bit.1 b/bin/man1/bit.1 index b61bc704..06fd182f 100644 --- a/bin/man1/bit.1 +++ b/bin/man1/bit.1 @@ -1,4 +1,4 @@ -.Dd June 7, 2019 +.Dd December 30, 2020 .Dt BIT 1 .Os . @@ -34,6 +34,11 @@ The postfix operators .Sy T are used as constant multipliers. .It +The postfix operator +.Sy $ +is of lowest precedence and is equivalent to +wrapping the preceding expression in parentheses. +.It Single-letter (lower case) variables can be assigned. The variable -- cgit 1.4.1