From 27fef8b782291fb68b643d67bdc2cc0757290591 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 15 May 2019 23:19:00 -0400 Subject: Support simple assignment in order --- bin/man1/order.1 | 2 +- bin/order.y | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/man1/order.1 b/bin/man1/order.1 index 5a01ab4b..2eb730f1 100644 --- a/bin/man1/order.1 +++ b/bin/man1/order.1 @@ -31,4 +31,4 @@ $ order 'a & b << 1' does not support the .Sy (type) operator -or the assignment operators. +or the compound assignment operators. diff --git a/bin/order.y b/bin/order.y index 4327c00a..8700ded4 100644 --- a/bin/order.y +++ b/bin/order.y @@ -44,9 +44,10 @@ static int yylex(void); %} -%token Var Arr Inc Dec Sizeof Shl Shr Le Ge Eq Ne And Or +%token Var %left ',' +%right '=' %right '?' ':' %left Or %left And @@ -102,6 +103,7 @@ expr: | expr And expr { $$ = fmt("(%s && %s)", $1, $3); } | expr Or expr { $$ = fmt("(%s || %s)", $1, $3); } | expr '?' expr ':' expr { $$ = fmt("(%s ? %s : %s)", $1, $3, $5); } + | expr '=' expr { $$ = fmt("(%s = %s)", $1, $3); } | expr ',' expr { $$ = fmt("(%s, %s)", $1, $3); } ; -- cgit 1.4.1