Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Jparsec is now ported to Ruby, with a way lighter syntax than Java.

The following is the ruby version of calculator:

As simple as that!

The above example utilizes the pre-built Expressions class to help building expression parser. Another example is for a simpler s-expression parser (in lisp syntax, "- (+ 1 (* 2 2)) (1)" sort of thing). We will build this parser without help of Expressions as it is much simpler than infix syntax:

The code is pretty self-explanatory. The only thing to note is that we had to manually skip whitespaces using the "ignore" function.

rparsec can be downloaded at

API document is available online

Created by benyu benyu
On Sun Oct 08 14:53:56 CDT 2006
Using TimTam

  • No labels