Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grammar to recognize postfix formulas

I'm trying to create a postfix to infix converter, and I'm unable to create the grammar for postfix formulas. I've been also looking for it for a while without success..

What grammar could I use to recognize valid postfix expressions?

The tokens I need are: number, +, * and ^ (pow).

like image 638
Oscar Mederos Avatar asked Sep 19 '25 08:09

Oscar Mederos


1 Answers

I would suggest

E ::= number | E E + | E E * | E E ^
like image 106
flolo Avatar answered Sep 21 '25 10:09

flolo