Re: newbie question on Bison/Yacc

Martin von Loewis <loewis@informatik.hu-berlin.de>
4 Jan 2001 01:00:18 -0500

          From comp.compilers

Related articles
newbie question on Bison/Yacc golova@my-deja.com (2000-12-31)
Re: newbie question on Bison/Yacc loewis@informatik.hu-berlin.de (Martin von Loewis) (2001-01-04)
| List of all articles for this month |
From: Martin von Loewis <loewis@informatik.hu-berlin.de>
Newsgroups: comp.compilers
Date: 4 Jan 2001 01:00:18 -0500
Organization: Humboldt University Berlin, Department of Computer Science
References: 00-12-124
Keywords: yacc
Posted-Date: 04 Jan 2001 01:00:18 EST

golova@my-deja.com writes:


> I am totally new to yacc/bison and wondering if you could help me with
> the following question: I need to parse an algebraic expression and
> calculate its value at a bunch of different points; what are the ways
> (the fastest way?) to reset the "independent vars" and recalculate the
> expression again?


I recommend to build a "symbol table", which maps variable names to
their assigned values. How efficient that is is not really a matter of
bison; you need a fast way to find an identifier in the symbol table
(e.g. by hashing), and you probably need a fast way to clear part of
the variable names when there scope is left (e.g. by chaining multiple
symbol tables, and then discarding the innermost one).


Regards,
Martin


Post a followup to this message

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