Skip to content

Commit 506f79a

Browse files
committed
2 parents 32f3511 + fb45e94 commit 506f79a

File tree

7 files changed

+61
-7
lines changed

7 files changed

+61
-7
lines changed

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Issue
3+
about: General Issue
4+
title: ""
5+
---
6+
7+
<!--
8+
Note: If you feel like complimenting my work, thank you, but there is no need to open an issue, simply give me a star or tell your friend about it. If you feel like criticizing me, please use these two dedicated threads to do so.
9+
https://github.com/LingDong-/wenyan-lang/issues/174
10+
https://github.com/LingDong-/wenyan-lang/issues/177
11+
12+
Thank you.
13+
14+
15+
For Chinese user: 如果你想赞美这个项目,谢谢你,但是请不需要建立新的 issue, Star 或告诉你的朋友即可。 如果你想批评这个项目,请到以下两个 issue 留言。
16+
https://github.com/LingDong-/wenyan-lang/issues/174
17+
https://github.com/LingDong-/wenyan-lang/issues/177
18+
19+
谢谢。
20+
-->
21+
22+
23+
## Describe your issue/suggestions
24+
25+
26+
27+
## Before you open the issue, Please be sure ALL the items in the following list are checked
28+
29+
- [ ] If this is a feature request, my request is NOT listed [Here](https://github.com/LingDong-/wenyan-lang#feature-requests)
30+
- [ ] If this is a bug report, my bug is not listed [Here](https://github.com/LingDong-/wenyan-lang#known-bugs)

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ English | [简体中文](./README.zh-Hans.md) | [繁体中文](./README.zh-Hant.
1212

1313
##
1414

15-
> 夫[唐](https://en.wikipedia.org/wiki/Emperor_Yao)、[虞](https://en.wikipedia.org/wiki/Emperor_Shun)之世,[結繩而足治](https://ctext.org/book-of-changes/xi-ci-xia/zh),屈指而足算。是時豈料百代之後,計算機械之巧,精於[公輸](https://en.wikipedia.org/wiki/Lu_Ban)之[木鳶](https://en.wikipedia.org/wiki/Lu_Ban#Inventions),善於[武侯](https://en.wikipedia.org/wiki/Zhuge_Liang)之[流馬](https://en.wikipedia.org/wiki/Wooden_ox);程式語言之多,繁若[《天官》](https://ctext.org/shiji/tian-guan-shu/zh)之星宿,奇勝[《山經》](https://en.wikipedia.org/wiki/Classic_of_Mountains_and_Seas)之走獸。[鼠](https://golang.org/)、[蟹](https://www.rust-lang.org/)、[鑽](http://ruby-lang.org/)、[魚](https://fishshell.com/),或以速稱。[蛇](https://www.python.org/)、[象](https://www.php.net/)、[駱](https://www.perl.org/)、[犀](http://shop.oreilly.com/product/9780596805531.do),各爭文采。方知[鬼之所以夜哭,天之所以雨粟](https://ctext.org/huainanzi/ben-jing-xun/zh)。然以文言編程者 ,似所未有。此誠非文脈之所以傳,文心之所以保。[嗟予小子](https://zh.wikisource.org/zh-hant/%E6%A6%AE%E6%9C%A8_(%E9%99%B6%E6%B7%B5%E6%98%8E)),遂有斯志。然則數寸之烏絲猶覆於頭,[萬卷之素書未破於手](https://zh.wikisource.org/zh-hant/%E5%A5%89%E8%B4%88%E9%9F%8B%E5%B7%A6%E4%B8%9E%E4%B8%88%E4%BA%8C%E5%8D%81%E4%BA%8C%E9%9F%BB);一身長羈於遠邦,兩耳久矌于[雅言](https://zh.wikipedia.org/wiki/%E9%9B%85%E9%9F%B3)。然夫文章者吾之所宿好,程式者偶承時人之謬譽。故[希孟](https://en.wikipedia.org/wiki/Wang_Ximeng)不慚年少,[莊生](https://en.wikipedia.org/wiki/Zhuang_Zhou)不望[無涯](https://ctext.org/zhuangzi/nourishing-the-lord-of-life/zh)。乃作斯言。誠未能嘔瀝[長吉](https://en.wikipedia.org/wiki/Li_He)之[心血](https://zh.wikisource.org/zh-hant/%E6%9D%8E%E8%B3%80%E5%B0%8F%E5%82%B3),亦庶幾免於[義山](https://en.wikipedia.org/wiki/Li_Shangyin)之[流沫](https://zh.wikisource.org/zh-hant/%E9%9F%93%E7%A2%91)。既成之後,復學[干將鑄劍](https://zh.wikisource.org/wiki/%E9%91%84%E5%8A%8D)而自飼,[越王嚐糞](https://ctext.org/wu-yue-chun-qiu/yue-wang-gou-jian-wu-nian/zh)而當先。自謂偶追[《十書》](https://en.wikipedia.org/wiki/Ten_Computational_Canons)之筆意,但恨少[八家](https://en.wikipedia.org/wiki/Eight_Masters_of_the_Tang_and_Song)之淋漓。此[子山](https://en.wikipedia.org/wiki/Yu_Xin)所謂[士衡抚掌而甘心,平子見陋而固宜](https://zh.wikisource.org/zh-hant/%E5%93%80%E6%B1%9F%E5%8D%97%E8%B3%A6)。然則雖實[覆甕](https://zh.wikisource.org/zh-hant/%E6%99%89%E6%9B%B8/%E5%8D%B7092#%E5%B7%A6%E6%80%9D)之質,尚存斧正之望;雖乏[呂相](https://en.wikipedia.org/wiki/L%C3%BC_Buwei)之金,[易字](https://zh.wikisource.org/zh/%E5%8F%B2%E8%A8%98/%E5%8D%B7085)之渴蓋同。此亦開源之大義,吾輩之所以勉勵也。一笑。
15+
> 夫[唐](https://en.wikipedia.org/wiki/Emperor_Yao)、[虞](https://en.wikipedia.org/wiki/Emperor_Shun)之世,[結繩而足治](https://ctext.org/book-of-changes/xi-ci-xia/zh),屈指而足算。是時豈料百代之後,計算機械之巧,精於[公輸](https://en.wikipedia.org/wiki/Lu_Ban)之[木鳶](https://en.wikipedia.org/wiki/Lu_Ban#Inventions),善於[武侯](https://en.wikipedia.org/wiki/Zhuge_Liang)之[流馬](https://en.wikipedia.org/wiki/Wooden_ox);程式語言之多,繁若[《天官》](https://ctext.org/shiji/tian-guan-shu/zh)之星宿,奇勝[《山經》](https://en.wikipedia.org/wiki/Classic_of_Mountains_and_Seas)之走獸。[鼠](https://golang.org/)、[蟹](https://www.rust-lang.org/)、[鑽](http://ruby-lang.org/)、[魚](https://fishshell.com/),或以速稱。[蛇](https://www.python.org/)、[象](https://www.php.net/)、[駱](https://www.perl.org/)、[犀](http://shop.oreilly.com/product/9780596805531.do),各爭文采。方知[鬼之所以夜哭,天之所以雨粟](https://ctext.org/huainanzi/ben-jing-xun/zh)。然以文言編程者 ,似所未有。此誠非文脈之所以傳,文心之所以保。[嗟予小子](https://zh.wikisource.org/zh-hant/%E6%A6%AE%E6%9C%A8_(%E9%99%B6%E6%B7%B5%E6%98%8E)),遂有斯志。然則數寸之烏絲猶覆於頭,[萬卷之素書未破於手](https://zh.wikisource.org/zh-hant/%E5%A5%89%E8%B4%88%E9%9F%8B%E5%B7%A6%E4%B8%9E%E4%B8%88%E4%BA%8C%E5%8D%81%E4%BA%8C%E9%9F%BB);一身長羈於遠邦,兩耳久曠于[雅言](https://zh.wikipedia.org/wiki/%E9%9B%85%E9%9F%B3)。然夫文章者吾之所宿好,程式者偶承時人之謬譽。故[希孟](https://en.wikipedia.org/wiki/Wang_Ximeng)不慚年少,[莊生](https://en.wikipedia.org/wiki/Zhuang_Zhou)不望[無涯](https://ctext.org/zhuangzi/nourishing-the-lord-of-life/zh)。乃作斯言。誠未能嘔瀝[長吉](https://en.wikipedia.org/wiki/Li_He)之[心血](https://zh.wikisource.org/zh-hant/%E6%9D%8E%E8%B3%80%E5%B0%8F%E5%82%B3),亦庶幾免於[義山](https://en.wikipedia.org/wiki/Li_Shangyin)之[流沫](https://zh.wikisource.org/zh-hant/%E9%9F%93%E7%A2%91)。既成之後,復學[干將鑄劍](https://zh.wikisource.org/wiki/%E9%91%84%E5%8A%8D)而自飼,[越王嚐糞](https://ctext.org/wu-yue-chun-qiu/yue-wang-gou-jian-wu-nian/zh)而當先。自謂偶追[《十書》](https://en.wikipedia.org/wiki/Ten_Computational_Canons)之筆意,但恨少[八家](https://en.wikipedia.org/wiki/Eight_Masters_of_the_Tang_and_Song)之淋漓。此[子山](https://en.wikipedia.org/wiki/Yu_Xin)所謂[士衡抚掌而甘心,平子見陋而固宜](https://zh.wikisource.org/zh-hant/%E5%93%80%E6%B1%9F%E5%8D%97%E8%B3%A6)。然則雖實[覆甕](https://zh.wikisource.org/zh-hant/%E6%99%89%E6%9B%B8/%E5%8D%B7092#%E5%B7%A6%E6%80%9D)之質,尚存斧正之望;雖乏[呂相](https://en.wikipedia.org/wiki/L%C3%BC_Buwei)之金,[易字](https://zh.wikisource.org/zh/%E5%8F%B2%E8%A8%98/%E5%8D%B7085)之渴蓋同。此亦開源之大義,吾輩之所以勉勵也。一笑。
1616

1717

1818
## Helloworld
@@ -71,9 +71,13 @@ npm install -g @wenyanlang/cli
7171
Try run the included examples, e.g.:
7272

7373
```bash
74-
wenyan examples/helloworld.wy -o helloworld.js
74+
wenyan examples/helloworld.wy
75+
# will outputs: 問天地好在。
7576
```
7677

78+
> From v0.1.0, the `wenyan` command will direct execute the script by default. If you are migrating from previous versions, please use `wenyan -h` to output the help and check [this PR](https://github.com/LingDong-/wenyan-lang) for the detailed changes.
79+
80+
7781
### [The Online IDE](http://wenyan-lang.lingdong.works/ide.html)
7882

7983
![](screenshots/screenshot02.png)

examples/quine.wy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
注曰Reference: 注曰https://qiita.com/amoO_O/items/5d0c4edfc99f64bea6fb
2-
吾有一術。名之曰「自己複製」。欲行是術。必先得零數。是術曰。吾有一術。名之曰「置換」。欲行是術。必先得三數。曰「文字列」。曰「置換対象」。曰「置換先」是術曰。吾有一言。曰「「」」。名之曰「返品」。吾有一數。曰二。名之曰「未来」。吾有一爻。曰陽。名之曰「実行条件」。凡「文字列」中之「文字」。若「実行条件」者。若「文字」等於「「星」」中無陰乎「文字列」之「未来」等於「置換対象」者。昔之「文字」者。今「置換先」是。昔之「実行条件」者。今陰是。也。加「返品」以「文字」。昔之「返品」者。今其是矣。若非。昔之「実行条件」者。今陽是。也。加「未来」以一。昔之「未来」者。今其是矣。云云。乃得「返品」。是謂「置換」之術也。吾有一言。曰String.fromCharCode名之曰「函数」。施「函数」於一萬二千三百。昔之「始」者。今其是矣。施「函数」於一萬二千三百零一。昔之「終」者。今其是矣。吾有二言。曰「「吾有一術。名之曰星甲自己複製星乙。欲行是術。必先得零數。是術曰。吾有一術。名之曰星甲置換星乙。欲行是術。必先得三數。曰星甲文字列星乙。曰星甲置換対象星乙。曰星甲置換先星乙是術曰。吾有一言。曰星甲星甲星乙星乙。名之曰星甲返品星乙。吾有一數。曰二。名之曰星甲未来星乙。吾有一爻。曰陽。名之曰星甲実行条件星乙。凡星甲文字列星乙中之星甲文字星乙。若星甲実行条件星乙者。若星甲文字星乙等於星甲星甲星星乙星乙中無陰乎星甲文字列星乙之星甲未来星乙等於星甲置換対象星乙者。昔之星甲文字星乙者。今星甲置換先星乙是。昔之星甲実行条件星乙者。今陰是。也。加星甲返品星乙以星甲文字星乙。昔之星甲返品星乙者。今其是矣。若非。昔之星甲実行条件星乙者。今陽是。也。加星甲未来星乙以一。昔之星甲未来星乙者。今其是矣。云云。乃得星甲返品星乙。是謂星甲置換星乙之術也。吾有一言。曰String.fromCharCode名之曰星甲函数星乙。施星甲函数星乙於一萬二千三百。昔之星甲始星乙者。今其是矣。施星甲函数星乙於一萬二千三百零一。昔之星甲終星乙者。今其是矣。吾有二言。曰星甲星甲星丙星乙星乙。星甲星甲星乙星乙。名之曰星甲原文星乙曰星甲結果星乙。施星甲置換星乙於星甲原文星乙。於星甲星甲甲星乙星乙。於星甲始星乙。昔之星甲結果星乙者。今其是矣。施星甲置換星乙於星甲結果星乙。於星甲星甲乙星乙星乙。於星甲終星乙。昔之星甲結果星乙者。今其是矣。施星甲置換星乙於星甲結果星乙。於星甲星甲丙星乙星乙。於星甲原文星乙。昔之星甲結果星乙者。今其是矣。吾有一言。曰星甲結果星乙。書之。是謂星甲自己複製星乙之術也。施星甲自己複製星乙。」」。「「」」。名之曰「原文」曰「結果」。施「置換」於「原文」。於「「甲」」。於「始」。昔之「結果」者。今其是矣。施「置換」於「結果」。於「「乙」」。於「終」。昔之「結果」者。今其是矣。施「置換」於「結果」。於「「丙」」。於「原文」。昔之「結果」者。今其是矣。吾有一言。曰「結果」。書之。是謂「自己複製」之術也。施「自己複製」。
2+
吾有一術。名之曰「自己複製」。欲行是術。必先得零數。是術曰。吾有一術。名之曰「置換」。欲行是術。必先得三數。曰「文字列」。曰「置換対象」。曰「置換先」是術曰。吾有一言。曰「「」」。名之曰「返品」。吾有一數。曰二。名之曰「未来」。吾有一爻。曰陽。名之曰「実行条件」。凡「文字列」中之「文字」。若「実行条件」者。若「文字」等於「「星」」中無陰乎「文字列」之「未来」等於「置換対象」者。昔之「文字」者。今「置換先」是。昔之「実行条件」者。今陰是。也。加「返品」以「文字」。昔之「返品」者。今其是矣。若非。昔之「実行条件」者。今陽是。也。加「未来」以一。昔之「未来」者。今其是矣。云云。乃得「返品」。是謂「置換」之術也。吾有一言。曰String.fromCharCode名之曰「函数」。施「函数」於一萬二千三百。昔之「始」者。今其是矣。施「函数」於一萬二千三百零一。昔之「終」者。今其是矣。吾有二言。曰「「吾有一術。名之曰星甲自己複製星乙。欲行是術。必先得零數。是術曰。吾有一術。名之曰星甲置換星乙。欲行是術。必先得三數。曰星甲文字列星乙。曰星甲置換対象星乙。曰星甲置換先星乙是術曰。吾有一言。曰星甲星甲星乙星乙。名之曰星甲返品星乙。吾有一數。曰二。名之曰星甲未来星乙。吾有一爻。曰陽。名之曰星甲実行条件星乙。凡星甲文字列星乙中之星甲文字星乙。若星甲実行条件星乙者。若星甲文字星乙等於星甲星甲星星乙星乙中無陰乎星甲文字列星乙之星甲未来星乙等於星甲置換対象星乙者。昔之星甲文字星乙者。今星甲置換先星乙是。昔之星甲実行条件星乙者。今陰是。也。加星甲返品星乙以星甲文字星乙。昔之星甲返品星乙者。今其是矣。若非。昔之星甲実行条件星乙者。今陽是。也。加星甲未来星乙以一。昔之星甲未来星乙者。今其是矣。云云。乃得星甲返品星乙。是謂星甲置換星乙之術也。吾有一言。曰String.fromCharCode名之曰星甲函数星乙。施星甲函数星乙於一萬二千三百。昔之星甲始星乙者。今其是矣。施星甲函数星乙於一萬二千三百零一。昔之星甲終星乙者。今其是矣。吾有二言。曰星甲星甲星丙星乙星乙。曰星甲星甲星乙星乙。名之曰星甲原文星乙曰星甲結果星乙。施星甲置換星乙於星甲原文星乙。於星甲星甲甲星乙星乙。於星甲始星乙。昔之星甲結果星乙者。今其是矣。施星甲置換星乙於星甲結果星乙。於星甲星甲乙星乙星乙。於星甲終星乙。昔之星甲結果星乙者。今其是矣。施星甲置換星乙於星甲結果星乙。於星甲星甲丙星乙星乙。於星甲原文星乙。昔之星甲結果星乙者。今其是矣。吾有一言。曰星甲結果星乙。書之。是謂星甲自己複製星乙之術也。施星甲自己複製星乙。」」。曰「「」」。名之曰「原文」曰「結果」。施「置換」於「原文」。於「「甲」」。於「始」。昔之「結果」者。今其是矣。施「置換」於「結果」。於「「乙」」。於「終」。昔之「結果」者。今其是矣。施「置換」於「結果」。於「「丙」」。於「原文」。昔之「結果」者。今其是矣。吾有一言。曰「結果」。書之。是謂「自己複製」之術也。施「自己複製」。

lib/統計.wy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
今有一術。名之曰「求和」。欲行是術。必先得一列。曰「列」。乃行是術曰。
2+
吾有一數。曰零。名之曰「和」。凡「列」中之「數」。加「和」以「數」。
3+
名之曰「和」。云云。乃得「和」。是謂「求和」之術也。
4+
5+
今有一術。名之曰「算術平均」。欲行是術。必先得一列。曰「列」。乃行是術曰。
6+
施「求和」於「列」。名之曰「和」。夫「列」之長。名之曰「長」。除「和」以「長」。
7+
名之曰「算術平均數」。乃得「算術平均數」。是謂「算術平均」之術也。
8+
9+
今有一術。名之曰「方差」。欲行是術。必先得一列。曰「列」。乃行是術曰。
10+
施「算術平均」於「列」。名之曰「算術平均數」。夫「列」之長。名之曰「長」。
11+
吾有一數。曰零。名之曰「平方和」。凡「列」中之「數」。減「數」以「算術平均數」。
12+
名之曰「偏差」。乘「偏差」以「偏差」。名之曰「偏差之平方」。
13+
加「偏差之平方」以「平方和」。名之曰「平方和」。云云。除「平方和」以「長」。
14+
名之曰「方差之數」。乃得「方差之數」。是謂「方差」之術也。

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wenyanlang",
33
"description": "文言 A programming language for the ancient Chinese",
4-
"version": "0.0.2",
4+
"version": "0.1.0",
55
"author": "LingDong <[email protected]>",
66
"private": true,
77
"repository": {

src/cli.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ program
3434
"Output compiled code or executing result to file"
3535
)
3636
.option("-r, --render", "Outputs renderings")
37-
.option("--roman", "Romanize identifiers")
37+
.option(
38+
"--roman [method]",
39+
'Romanize identifiers. The method can be "pinyin", "baxter" or "unicode"'
40+
)
3841
.option("--log <file>", "Save log to file")
3942
.option("--title <title>", "Override title in rendering")
4043
.helpOption("-h, --help", "Display help");
@@ -91,11 +94,14 @@ function preprocess() {
9194
else if (program.render) program.output = `${base}.svg`;
9295
else program.output = `${base}.log`;
9396
}
97+
98+
if (program.roman == true) {
99+
program.roman = "pinyin";
100+
}
94101
}
95102

96103
function getCompiled() {
97104
const source = getSource();
98-
console.log(source);
99105
return compile(program.lang, source, {
100106
romanizeIdentifiers: program.roman,
101107
logCallback: logHandler(program.log, "a"),

0 commit comments

Comments
 (0)