Re: Fastening the run-time interpretation of mathematical expressions

"idknow@gmail.com" <idknow@gmail.com>
15 Nov 2006 15:23:19 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: Fastening the run-time interpretation of mathematical expressions mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-11-13)
Re: Fastening the run-time interpretation of mathematical expressions akk@privat.de (Andreas Kochenburger) (2006-11-13)
Re: Fastening the run-time interpretation of mathematical expressions martin@gkc.org.uk (Martin Ward) (2006-11-13)
Re: Fastening the run-time interpretation of mathematical expressions tommy.thorn@gmail.com (Tommy Thorn) (2006-11-13)
Re: Fastening the run-time interpretation of mathematical expressions 148f3wg02@sneakemail.com (Karsten Nyblad) (2006-11-15)
Re: Fastening the run-time interpretation of mathematical expressions martin@gkc.org.uk (Martin Ward) (2006-11-15)
Re: Fastening the run-time interpretation of mathematical expressions idknow@gmail.com (idknow@gmail.com) (2006-11-15)
Re: Fastening the run-time interpretation of mathematical expressions gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-11-16)
Re: Fastening the run-time interpretation of mathematical expressions darius@raincode.com (Darius Blasband) (2006-11-20)
| List of all articles for this month |

From: "idknow@gmail.com" <idknow@gmail.com>
Newsgroups: comp.compilers
Date: 15 Nov 2006 15:23:19 -0500
Organization: Compilers Central
References: 06-11-052
Keywords: parse

PAolo wrote:
> I am writing a piece of software that accept in input the definition
> of a mathematical function and a list of points in which evaluate the
> function and puts the result in output.
[snip]
> ... The gramar is:
>
> %token <val> NUM /*float representation*/
> %token <name> ID /*name starting with [a-zA-Z_] */
> %left '-' '+'
> %left '*' '/'
> %left NEG /* negation--unary minus */
> %right '^' /* exponentiation */
>
> exp: NUM {printf(" %g",$1);}
> | ID {printf(" #%s",$1);}
> | ID '(' exp ')' {printf(" @%s",$1);}
> | exp '+' exp {printf(" +");}
> | exp '-' exp {printf(" -");}
> | exp '*' exp {printf(" *");}
> | exp '/' exp {printf(" /");}
> | '-' exp %prec NEG {printf(" neg");}
> | exp '^' exp {printf(" ^");}
> | '(' exp ')'
> ;
>
> -John]


Exp: Unaryop Mul.
Unaryop: '-'|'!'
Mul: Mulop Add.
Mulop: '*'|'/'|'%'|'^'
Add: Addop Primary.
Addop: '+'|'-'
Primary: '(' Exp ')' | ID.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.