Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: 10
- run: npm ci
- run: npm install
- run: npm test
- run: npm run build

Expand All @@ -26,6 +26,6 @@ jobs:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm publish
- run: npm run publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ jobs:
- name: Lint
run: npm run lint

- name: Build
run: |
npm run make_cmdline
npm run make_ide

- name: Test
run: npm test
run: |
npm run build
npm test

51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,27 @@ More sophisticated examples, such as the Sieve of Eratosthenes, Quicksort, Mande

### The Compiler

Clone the repo, (OR simply download `./build/wenyan.js` and set its executable bit using the terminal command `chmod +x wenyan.js`). Then run `./build/wenyan.js` to compile your wenyan souce code to target language. Calling the compiler without arguments prints the help message, reproduced below:
Install the compiler by

```
Usage: wenyan [options] [input files]

Options:
--eval -e <string> : Give a string instead of a file (default: `')
--exec -x <boolean> : Execute output (default: `false')
--inspect -i <boolean> : Interactive REPL (default: `false')
--lang -l <string> : Language: js/py (default: `js')
--log <string> : Log file (default: `/dev/null')
--output -o <string> : Output file (default: `/dev/stdout')
--roman -r <boolean> : Romanize identifiers (default: `true')
```bash
npm install -g @wenyanlang/cli
```

Try building the included examples first, e.g.:
Try run the included examples, e.g.:

```
```bash
wenyan examples/helloworld.wy -o helloworld.js
```

### [The online IDE](http://wenyan-lang.lingdong.works/ide.html)
### [The Online IDE](http://wenyan-lang.lingdong.works/ide.html)

![](screenshots/screenshot02.png)

### Text Editor Plugins

- [Plugin for VSCode](https://github.com/antfu/wenyan-lang-vscode) by [antfu](https://github.com/antfu)
- [Plugin for Vim](https://github.com/voldikss/vim-wenyan) by [voldikss](https://github.com/voldikss)
- [Plugin for Sublime Text](https://github.com/absop/SublimeWenyan) by [absop](https://github.com/absop)

## Syntax Cheatsheet

Expand Down Expand Up @@ -152,6 +148,7 @@ Arrays are 1-indexed.


### Functions

| wenyan | JavaScript |
|---|---|
|`吾有一術。名之曰「吸星大法」。是術曰。⋯⋯是謂「吸星大法」之術也。`|`function f(){...}`|
Expand All @@ -161,22 +158,30 @@ Arrays are 1-indexed.
|`吾有一數。曰五。書之。`|`console.log(5);`|

### Import

| wenyan | JavaScript |
|---|---|
|`吾嘗觀「「算經」」之書。方悟「正弦」「餘弦」之義。` | `{sin,cos}=require("math");` |
|`吾嘗觀「「算經」」之書。方悟「正弦」「餘弦」之義。` | `var {sin,cos} = require("math");` |

## Renderer
### Comments

`src/render.js` can render a wenyan program into an image that resembles pages from historical printed books. It can also parse the resultant SVG file back to the original program. Below is the rendering of the Universal Turing Machine written in wenyan:
| wenyan | JavaScript |
|---|---|
|`批曰。「「文氣淋灕。字句切實」」。` | `/*文氣淋灕。字句切實*/` |

![](screenshots/screenshot03.png)

## Renderer

## Contributed Tools
```
wenyan examples/turing.wy --render 圖靈機 --output .
```

- [Plugin for VSCode](https://github.com/antfu/wenyan-lang-vscode) by [antfu](https://github.com/antfu)
- [Plugin for Vim](https://github.com/voldikss/vim-wenyan) by [voldikss](https://github.com/voldikss)
- [Plugin for Sublime Text](https://github.com/absop/SublimeWenyan) by [absop](https://github.com/absop)
Render a wenyan script into an image that resembles pages from historical printed books.
It can also parse the resultant SVG file back to the original program. For more details, please refer to the help by `wenyan -h`.

Below is the rendering of the Universal Turing Machine written in wenyan:

![](screenshots/screenshot03.png)

## Feature Requests

Expand Down
2 changes: 0 additions & 2 deletions build/wenyan.js

This file was deleted.

26 changes: 24 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"name": "wenyan-lang",
"version": "0.0.1",
"author": "LingDong<lingdong0618@hotmail.com>",
"name": "wenyanlang",
"description": "文言 A programming language for the ancient Chinese",
"version": "0.0.1-beta.19",
"author": "LingDong <lingdong0618@hotmail.com>",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/LingDong-/wenyan-lang.git"
},
"license": "MIT",
"bin": {
"wenyan": "./dist/cli.js"
},
"main": "./dist/core.js",
"files": [
"dist"
"keywords": [
"wenyan",
"wenyan-lang",
"compiler",
"ancient-chinese",
"classical-chinese"
],
"homepage": "https://github.com/LingDong-/wenyan-lang",
"scripts": {
"build": "npm run clear && webpack --mode production && chmod -x ./dist/cli.js",
"build": "npm run clear && webpack --mode production",
"dev": "npm run clear && webpack --mode development --watch",
"clear": "rimraf ./dist",
"publish": "node ./tools/publish.js",
"release": "bump --commit --tag && git push --follow-tags",
"make_cmdline": "node ./tools/make_cmdline.js && pkg ./build/wenyan.js --out-path ./build",
"make_ide": "node ./tools/make_ide.js",
"make_site": "node ./tools/make_site.js",
"test": "mocha --require mocha-snapshots",
Expand Down Expand Up @@ -54,6 +57,7 @@
"mocha-snapshots": "^4.2.0",
"pkg": "^4.4.2",
"prettier": "^1.19.1",
"raw-loader": "^4.0.0",
"rimraf": "^3.0.0",
"version-bump-prompt": "^5.0.6",
"webpack": "^4.41.4",
Expand Down
Loading