13 Oct 2002 16:39:43 -0400

Related articles |
---|

commutative operations in bison for parallel operation surgeonde@yahoo.de (Hannes liesen) (2002-10-13) |

Re: commutative operations in bison for parallel operation anton@mips.complang.tuwien.ac.at (Anton Ertl) (2002-10-20) |

From: | "Hannes liesen" <surgeonde@yahoo.de> |

Newsgroups: | comp.compilers |

Date: | 13 Oct 2002 16:39:43 -0400 |

Organization: | T-Online |

Keywords: | optimize, yacc, question, comment |

Posted-Date: | 13 Oct 2002 16:39:43 EDT |

The mfcalc in the bison manual shows a simple example for a calculator.

This decribes the associatvity of the operators as we have learned at

school year 3, so that we can slit up nested operations in single operations

%left '+' '-'

%left '*' '/'

%right NEG

%right '^'

...

This describes what to do with a single operation as we learned at

school year 1 (ok, except pow)

expr:

expr '+' expr {$<expr>$ = $<expr>1 + $<expr>3; }

| expr '-' expr {$$ = $1 - $3; }

| expr '*' expr {$$ = $1 * $3; }

| expr '/' expr {$$ = $1 / $3; }

| '-' expr %prec NEG {$$ = -$2; }

| expr '^' expr {$$ = pow($1,$3); }

| '(' expr ')' {$$ = $2;}

If I feed the parser with 1+2+3+4+5

the parser stack shows me (rpn-like)

1 2 + 3 + 4 + 5 +

so each operation waits for the completion of the previous operation.

We cannot parallelize this. I can remember from priamry scholl, that

addition is commutative. How can I tell the bison parser generator

about it, that he arranges the stack like this.

1 2 + 3 4 + +

I could calc

1 2 +

and

3 4 +

in parallel then. Actually I don't do the actions as described above,

I put the tokens and values on my own stck and than I calculate each

single triple. Do I really have to re-arrange the stack myself? The

way bison feeds the stack basing on the parser definition, is not

appropriate for parallel operation.

[Yes, you have to arrange the stack yourself. Bison doesn't have any

idea of the semantics of what it's parsing. -John]

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.