DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(bison.info.gz) Mfcalc Rules

Info Catalog (bison.info.gz) Mfcalc Decl (bison.info.gz) Multi-function Calc (bison.info.gz) Mfcalc Symtab
 
 Grammar Rules for `mfcalc'
 --------------------------
 
    Here are the grammar rules for the multi-function calculator.  Most
 of them are copied directly from `calc'; three rules, those which
 mention `VAR' or `FNCT', are new.
 
      input:   /* empty */
              | input line
      ;
      
      line:
                '\n'
              | exp '\n'   { printf ("\t%.10g\n", $1); }
              | error '\n' { yyerrok;                  }
      ;
      
      exp:      NUM                { $$ = $1;                         }
              | VAR                { $$ = $1->value.var;              }
              | VAR '=' exp        { $$ = $3; $1->value.var = $3;     }
              | FNCT '(' exp ')'   { $$ = (*($1->value.fnctptr))($3); }
              | exp '+' exp        { $$ = $1 + $3;                    }
              | exp '-' exp        { $$ = $1 - $3;                    }
              | exp '*' exp        { $$ = $1 * $3;                    }
              | exp '/' exp        { $$ = $1 / $3;                    }
              | '-' exp  %prec NEG { $$ = -$2;                        }
              | exp '^' exp        { $$ = pow ($1, $3);               }
              | '(' exp ')'        { $$ = $2;                         }
      ;
      /* End of grammar */
      %%
 
Info Catalog (bison.info.gz) Mfcalc Decl (bison.info.gz) Multi-function Calc (bison.info.gz) Mfcalc Symtab
automatically generated byinfo2html