GithubHelp home page GithubHelp logo

lideming / sharprpn Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 35 KB

An RPN programming language

License: MIT License

C# 98.94% Dockerfile 1.06%
csharp interpreter parser rpn rpn-expression rpn-calculator

sharprpn's Introduction

SharpRPN

SharpRPN is a stack machine with an RPN programming language, inspired by RPL on HP calculators.

SharpRPN image

Use as a calculator:

Input: 1
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  1 │ 1     │ Int32  
                     
Input: 2
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  2 │ 1     │ Int32  
  1 │ 2     │ Int32  
                     
Input: +
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  1 │ 3     │ Int32  
                     
Input: 3 4 + *
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  1 │ 21    │ Int32  
                     
Input: 1 2 3 * 4 + +
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  2 │ 21    │ Int32  
  1 │ 11    │ Int32  

Drop an item from stack or clear all items:

  # │ Value │ Type   
 ───┼───────┼─────── 
  2 │ 21    │ Int32  
  1 │ 11    │ Int32  
                     
Input: drop
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  1 │ 21    │ Int32  
                     
Input: clear
Stack empty

Set value to variable:

Input: 1 'foo' sto
Stack empty
Input: foo
                     
  # │ Value │ Type   
 ───┼───────┼─────── 
  1 │ 1     │ Int32  

Codeblocks:

Input: { 'hello world!' 1 2 + }
                                            
  # │ Value                    │ Type       
 ───┼──────────────────────────┼─────────── 
  1 │ { 'hello world!' 1 2 + } │ CodeBlock  
                                            
Input: eval
                             
  # │ Value        │ Type    
 ───┼──────────────┼──────── 
  2 │ hello world! │ String  
  1 │ 3            │ Int32   

Input and condition:

Input: { 'Correct\n' print } { 'Wrong\n' print } "What's the answer? " print input '42' == evalifelse
What's the answer? 42                   
Correct

Try it now

Build and run from source

(.NET Core 3.1 SDK required)

git clone https://github.com/lideming/SharpRPN.git
cd SharpRPN
dotnet run

Run prebuilt binaries

(.NET Core 3.1 Runtime required)

Download the latest build from Github Actions.

Run in Docker Docker Image Size (tag)

docker run -it yuuza/sharprpn

sharprpn's People

Contributors

lideming avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.