From 57b1a2757eab6532eb7c3ea72f1eacf04eca914d Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 13 Nov 1987 15:11:37 +0000 Subject: [PATCH] some cosmetic changes+fix in calculator --- doc/LLgen/LLgen.n | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/LLgen/LLgen.n b/doc/LLgen/LLgen.n index c1550d8a4..d4aca0abd 100644 --- a/doc/LLgen/LLgen.n +++ b/doc/LLgen/LLgen.n @@ -896,36 +896,35 @@ stat { int ident, val; } : ; expr(int level, *val;) { int expr; } : - %if (level <= MAXPRIO) - /* The grammar is ambiguous here. If level > MAXPRIO, - * this invocation will only scan one factor - */ - expr(MAXPRIO+1,val) - [ %while (prio(tok.t_tokno) >= level) + factor(val) + [ %while (prio(tok.t_tokno) >= level) /* Swallow operators as long as their priority is * larger than or equal to the level of this invocation */ - '+' expr(prio('+')+1,&expr) + '+' expr(prio('+')+1,&expr) { *val += expr; } /* This states that '+' groups left to right. If it * should group right to left, the rule should read: * '+' expr(prio('+'),&expr) */ - | '-' expr(prio('-'),&expr) + | '-' expr(prio('-')+1,&expr) { *val -= expr; } - | '*' expr(prio('*'),&expr) + | '*' expr(prio('*')+1,&expr) { *val *= expr; } - | '/' expr(prio('/'),&expr) + | '/' expr(prio('/')+1,&expr) { *val /= expr; } - | '%' expr(prio('%'),&expr) + | '%' expr(prio('%')+1,&expr) { *val %= expr; } - | '&' expr(prio('&'),&expr) + | '&' expr(prio('&')+1,&expr) { *val &= expr; } - | '|' expr(prio('|'),&expr) + | '|' expr(prio('|')+1,&expr) { *val |= expr; } - ]* + ]* /* Notice the "*" here. It is important. */ + ; + +factor(int *val;): | '(' expr(1,val) ')' | '-' expr(MAXPRIO+1,val) { *val = -*val; } -- 2.34.1