Lex and yacc program for infix to prefix

broken image

In particular, ANTLR will let you write a grammar which will parse infix expressions and spit out prefix notation with virtually no programming at all. For example, your idea can be implemented very easily using a parser toolkit like ANTLR (Another Toolkit for Language Recognition).

broken image

Matt, you're exploring the ideas that underlie parsing of formal languages, finite state machines, compilers, etc. Thus, replacing parentheses and commas with spaces gives x + 2 3 + 4 5 as the decomposed result.ĭo you think my methodology is plausible and valid?

broken image

(04-29-2014 12:47 AM)Matt Agajanian Wrote: The way I see it is if I interpret each one or two number operation as func(arg1, arg2.) or func(arg), then, after writing this form of the expression out, I replace the parenthese and commas with spaces for readability and syntax, the end result is a prefix expression.įor example: (2+3)x(4+5) becomes x(+(2,3),+(4,5)).

broken image