Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/singpolyma/rpnr

Reverse Polish Notation for Ruby
https://github.com/singpolyma/rpnr

Last synced: about 1 month ago
JSON representation

Reverse Polish Notation for Ruby

Awesome Lists containing this project

README

        

= Reverse Polish Notation for Ruby =

== Buiding ==

You will need make, lex, and a C compiler.

Run make

== Running ==

The rpnr utility takes RPNR on standard in and outputs valid Ruby on stanadard out.

rpnr < code.rpnr > code.rb

== RPNR Syntax ==

* Tokens are seperated by whitespace
* '(' and ')' are whitespace
* Tokens that are all non-alphanumeric or start with a ':' are messages
* Tokens in double quotes are strings.
* Tokens in single quotes are symbols.
* Tokens in /.*/ are regular expressions.
* Tokens that are numbers are numbers

When a non-message is encountered, it is pushed onto the stack.

When a message is encountered:
* The top two items are popped
* The next-to-top item is passed the message with the argument being the top

=== Edge cases ===

'a,b' (a b +) :lambda #=> lambda{|a,b| a.send(:'+', b)}

a 1 = #=> a = 1