Trying to write a parser

214 views Asked by At

I'm trying to parse a syntax using the Shunting Yard (SY) algorithm. The syntax includes the following commands (they're are many many others though!)

a + b // a and b are numbers
setxy c d //c,d can be numbers
setxy c+d b+a //all numbers

Essentially, setxy is a function but it doesn't expect any function argument separators. This makes it very difficult (impossible?) to do via SY due to the lack of parens and function argument separators.

Any idea if SY can be used to parse a parentheses-less/function argument separator-less function or should I move on to a different parsing algorithm? If so, which one would you recommend?

Thanks! djs22

2

There are 2 answers

3
bushed On BEST ANSWER

Having defined correct grammar you can make http://www.antlr.org/ generate parser for you. Whether it is appropriate solution depends on your homework "requirements".

At least you can generate it and look inside for some hints.

3
Andrew delgadillo On

I don't fully understand what you are trying to do, but perhaps you could use some regex? what are you trying to do write a simple command line program?