Code Monkey home page Code Monkey logo

wenyan-rs's Introduction

Wenyan-rs

A bytecode interpreter for Wenyan-lang.

Usage

wyw [file]

Examples

吾有一術 名之曰「階乘」 欲行是術 必先得一數 曰「甲」 乃行是術曰
 若「甲」等於一者。
  乃得「甲」
 若非
  減「甲」以一名之曰「乙」
  施「階乘」於「乙」名之曰「丙」
  乘「丙」以「甲」。名之曰「丁」
  乃得「丁」
 云云
是謂「階乘」之術也

施「階乘」於五書之

Output:

120

This project are still work in progress, many features are not implemented yet. You can see more supported examples in inputs folder.

Differences

The Online IDE has many friendly enhances, some of my rules may be more strict for ease of implementation.

Variable need to be wrapped with single quote.

吾有一數曰五名之曰「甲」 // ✅
吾有一數曰五名之曰甲 // ❌

昔之「甲」者今其是矣 // ✅
昔之甲者今其是矣 // ❌

Disable partially define variables.

吾有二數曰五曰六  // ✅
吾有二數曰五曰六名之曰「甲」名之曰「乙」 // ✅
吾有二數曰五曰六名之曰「甲」 // ❌ 

Has implicit block scope.

吾有一數曰十名之曰「甲」
若陽者
  吾有一數曰一名之曰「甲」
  加「甲」以五書之
云云
加「甲」以五書之

Output vs Online IDE:

-6
-6
+6
+15

Boolean algebra statement always gets boolean.

吾有一數曰五名之曰「甲」
吾有一數曰六名之曰「乙」
夫「甲」「乙」中有陽乎
書之

吾有一數曰五名之曰「甲」
吾有一數曰六名之曰「乙」
夫「甲」「乙」中無陰乎
書之

Output vs Online IDE:

-5
-6
+true
+true

Treats single data as expression and will be pushed into stack.

吾有一數曰五名之曰「甲」
「甲」書之
「「黃河流水鳴濺濺」」書之

Output vs Online IDE

+5
+黃河流水鳴濺濺

Treats '也' as kind of whitespace, you can use it to make code more readable, but can't use it as close of block.

Function will be added into stack, and "書之" will drain values produced by current function.

吾有一數曰五名之曰「甲」
吾有一術名之曰「你好」是術曰
夫「「世界,你好」」書之
是謂 「你好」 之術也

施「你好」

After 夫「「世界,你好」」書之, The stack will be:

[2] <fn 你好>
[1] Value::Number(5)
[0] <global context> 

When function 你好 returns, the stack will be:

[1] Value::Number(5)
[0] <global context> 

Take advantage of our own virtual machine, It has ability to report more kind of runtime errors.

吾有二言曰『你』曰『好』名之曰「甲」名之曰「乙」 
減「甲」以「乙」書之

Output:

[line 2] errors: two string can only be added

Install

If you are Mac user, download binary file from the release page, and follow this blog to add it to your path. If you are noticed about "can’t be opened because Apple cannot check it for malicious software.", you can follow this blog to allow it.

The better install way will be added when this project is more stable.

Future Work

There are still many features not implemented! Part of them are listed in this issue.

Credits

License

MIT.

wenyan-rs's People

Contributors

mysteryven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

wenyan-rs's Issues

TODO List

I need to look for a job recently. These things will probably start in the next month.

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.