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




_______________________________________________
help-bison@gnu.org 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


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to