项目作者: lideming

项目描述 :
An RPN programming language
高级语言: C#
项目地址: git://github.com/lideming/SharpRPN.git
创建时间: 2021-04-08T09:16:33Z
项目社区:https://github.com/lideming/SharpRPN

开源协议:MIT License

下载


SharpRPN

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

SharpRPN image

Use as a calculator:

  1. Input: 1
  2. # │ Value │ Type
  3. ───┼───────┼───────
  4. 1 1 Int32
  5. Input: 2
  6. # │ Value │ Type
  7. ───┼───────┼───────
  8. 2 1 Int32
  9. 1 2 Int32
  10. Input: +
  11. # │ Value │ Type
  12. ───┼───────┼───────
  13. 1 3 Int32
  14. Input: 3 4 + *
  15. # │ Value │ Type
  16. ───┼───────┼───────
  17. 1 21 Int32
  18. Input: 1 2 3 * 4 + +
  19. # │ Value │ Type
  20. ───┼───────┼───────
  21. 2 21 Int32
  22. 1 11 Int32

Drop an item from stack or clear all items:

  1. # │ Value │ Type
  2. ───┼───────┼───────
  3. 2 21 Int32
  4. 1 11 Int32
  5. Input: drop
  6. # │ Value │ Type
  7. ───┼───────┼───────
  8. 1 21 Int32
  9. Input: clear
  10. Stack empty

Set value to variable:

  1. Input: 1 'foo' sto
  2. Stack empty
  3. Input: foo
  4. # │ Value │ Type
  5. ───┼───────┼───────
  6. 1 1 Int32

Codeblocks:

  1. Input: { 'hello world!' 1 2 + }
  2. # │ Value │ Type
  3. ───┼──────────────────────────┼───────────
  4. 1 { 'hello world!' 1 2 + } CodeBlock
  5. Input: eval
  6. # │ Value │ Type
  7. ───┼──────────────┼────────
  8. 2 hello world! String
  9. 1 3 Int32

Input and condition:

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

Try it now

Build and run from source

(.NET Core 3.1 SDK required)

  1. git clone https://github.com/lideming/SharpRPN.git
  2. cd SharpRPN
  3. 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)

  1. docker run -it yuuza/sharprpn