help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to parse linear equations


From: Philip Herron
Subject: Re: how to parse linear equations
Date: Sat, 16 Jan 2010 16:14:42 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 16/01/2010 15:02, Hans Aberg wrote:
On 16 Jan 2010, at 15:52, Michael Chen wrote:

Exactly, I would like to first process the linear expression, which
are coefficients and a constant; how can I do it over my ast tree
recursively?

         +
   *               *
2    +          3      -
   x   y             z     x

Just make a data structure that can hold a polynomial - linear in your case, with operators + - *. Then just build it as in the calculator case, only that it operates on this polynomial data.

  Hans




_______________________________________________
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
Hey,

Ah nice way of doing this would be use the normal calculator example:

expression: expression '+' expression
                  | expression '-' expression
                   ....

But you can use Gaussian Elimination for a set of linear equations to do the hard work (to simplify or even solve) for you by creating a matrix, although you want to of course be able to handle single linear equations it might give you some ideas in how to structure and process the expression.

--Phil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]