Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/singpolyma/rpnr
- Owner: singpolyma
- License: isc
- Created: 2010-03-17T22:08:02.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2010-03-31T22:05:55.000Z (almost 15 years ago)
- Last Synced: 2024-10-15T11:34:33.704Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 102 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: COPYING
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 numbersWhen 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