Skip to content

Commit 208bb67

Browse files
authored
Merge pull request #492 from LingDong-/master
v0.2.1
2 parents e9453d2 + 397663c commit 208bb67

26 files changed

+2154
-177
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ build/wenyan-linux
44
build/wenyan-macos
55
build/wenyan-win.exe
66
temp
7-
dist
7+
dist
8+
/tools/calendar.html

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ wenyan examples/helloworld.wy
9292

9393
You can now translate JavaScript to wenyan-lang using the [wenyanizer](https://github.com/zxch3n/wenyanizer) by [zxch3n](https://github.com/zxch3n).
9494

95+
### 3rd Party Compilers
96+
97+
- [JVM compiler](https://github.com/MagicLu550/wenyan-lang_jvm) by [MagicLu550](https://github.com/MagicLu550)
98+
9599
### Text Editor Plugins
96100

97101
- [Plugin for VSCode](https://github.com/antfu/wenyan-lang-vscode) by [antfu](https://github.com/antfu)
@@ -261,3 +265,5 @@ If you could help implement a feature with a `√` under `help needed`, please f
261265
|---|---|---|---|
262266
|[hanzi2num conversion error](https://github.com/LingDong-/wenyan-lang/issues/114)| ***** | | |
263267
|[hanzi2num multi-character numbers not included](https://github.com/LingDong-/wenyan-lang/issues/130) | *** | | |
268+
269+

documentation/Runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ You can import remote scripts as you will do for Javascript.
4949

5050
### Outputing Hanzi
5151

52-
By default, it will convert numbers and bools to hanzi. If you want to output raw numbers, you can specify `ouputHanzi="false"` in attr of script tag.
52+
By default, it will convert numbers and bools to hanzi. If you want to output raw numbers, you can specify `outputHanzi="false"` in attr of script tag.
5353

5454
```html
55-
<script type="application/wenyan" ouputHanzi="false">
55+
<script type="application/wenyan" outputHanzi="false">
5656
吾有一數。曰三。書之。
5757
</script>
5858
```

documentation/Standard-Lib.md

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Standard Library Cheatsheet
66

7-
Last updated: Mon, 30 Dec 2019 15:32:37 GMT
7+
Last updated: Sat, 04 Jan 2020 12:49:12 GMT
88

99

1010
## Usage
@@ -13,11 +13,61 @@ Last updated: Mon, 30 Dec 2019 15:32:37 GMT
1313
吾嘗觀「「算經」」之書。方悟「正弦」「餘弦」「圓周率」之義。
1414
```
1515

16+
## [列經](../lib/列經.wy)
17+
18+
| Wenyan | Javascript Equivalent |
19+
|---|---|
20+
1621
## [易經](../lib/易經.wy)
1722

1823
| Wenyan | Javascript Equivalent |
1924
|---|---|
2025

26+
## [曆法](../lib/曆法.wy)
27+
28+
| Wenyan | Javascript Equivalent |
29+
|---|---|
30+
| [`今何紀元時`](../lib/曆法.wy#L9) | `Date.now() / 1000` |
31+
| [`言今之日時`](../lib/曆法.wy#L14) | `new Date().toString(), in Chinese calendar` |
32+
| [`言今之年月日`](../lib/曆法.wy#L19) | `new Date().toDateString(), in Chinese calendar` |
33+
| [`言今之時刻`](../lib/曆法.wy#L24) | `new Date().toTimeString(), in Chinese calendar` |
34+
| [`今年何年號`](../lib/曆法.wy#L29) | `"西元" for modern dates` |
35+
| [`今年何年`](../lib/曆法.wy#L34) | `new Date().getFullYear() for modern dates, in Chinese calendar` |
36+
| [`今年何干支`](../lib/曆法.wy#L40) | `Get index (1 to 60) of this year in the 60-year cycle` |
37+
| [`今年積何年`](../lib/曆法.wy#L46) | `new Date().getFullYear() + 2697, in Chinese calendar` |
38+
| [`今月何月`](../lib/曆法.wy#L53) | `new Date().getMonth() + 1, N + 0.5 for leap months, in Chinese calendar` |
39+
| [`今月積何月`](../lib/曆法.wy#L60) | `Get continuously counting month number of this month` |
40+
| [`今日何日`](../lib/曆法.wy#L67) | `new Date().getDate(), in Chinese calendar` |
41+
| [`今日何干支`](../lib/曆法.wy#L74) | `Get index (1 to 60) of today in the 60-day cycle` |
42+
| [`今日積何日`](../lib/曆法.wy#L80) | `Get continuously counting day number of today` |
43+
| [`今時何時`](../lib/曆法.wy#L87) | `Get index (1 to 12) of current time in the 12 divisions of day` |
44+
| [`今時何小時`](../lib/曆法.wy#L94) | `new Date().getHours()` |
45+
| [`今刻何刻`](../lib/曆法.wy#L101) | `Math.floor(new Date().getMinutes() / 15)` |
46+
| [`今分何分`](../lib/曆法.wy#L108) | `new Date().getMinutes() % 15` |
47+
| [`今秒何秒`](../lib/曆法.wy#L113) | `new Date().getSeconds()` |
48+
| [`言彼之日時`](../lib/曆法.wy#L232) | `new Date(x * 1000).toString(), in Chinese calendar` |
49+
| [`言彼之年月日`](../lib/曆法.wy#L241) | `new Date(x * 1000).toDateString(), in Chinese calendar` |
50+
| [`言彼之時刻`](../lib/曆法.wy#L248) | `new Date(x * 1000).toTimeString(), in Chinese calendar` |
51+
| [`彼年何年號`](../lib/曆法.wy#L255) | `"西元" for modern dates` |
52+
| [`彼年何年`](../lib/曆法.wy#L260) | `new Date(x * 1000).getFullYear() for modern dates, in Chinese calendar` |
53+
| [`彼年何干支`](../lib/曆法.wy#L265) | `Get index (1 to 60) in the 60-year cycle` |
54+
| [`彼年積何年`](../lib/曆法.wy#L271) | `new Date(x * 1000).getFullYear() + 2697, in Chinese calendar` |
55+
| [`彼月何月`](../lib/曆法.wy#L278) | `new Date(x * 1000).getMonth() + 1, N + 0.5 for leap months, in Chinese calendar` |
56+
| [`彼月積何月`](../lib/曆法.wy#L289) | `Get continuously counting month number` |
57+
| [`彼日何日`](../lib/曆法.wy#L294) | `new Date(x * 1000).getDate(), in Chinese calendar` |
58+
| [`彼日何干支`](../lib/曆法.wy#L300) | `Get index (1 to 60) in the 60-day cycle` |
59+
| [`彼日積何日`](../lib/曆法.wy#L306) | `Get continuously counting day number` |
60+
| [`彼時何時`](../lib/曆法.wy#L313) | `Get index (1 to 12) in the 12 divisions of day` |
61+
| [`彼時何小時`](../lib/曆法.wy#L322) | `new Date(x * 1000).getHours()` |
62+
| [`彼刻何刻`](../lib/曆法.wy#L330) | `Math.floor(new Date(x * 1000).getMinutes() / 15)` |
63+
| [`彼分何分`](../lib/曆法.wy#L338) | `new Date(x * 1000).getMinutes() % 15` |
64+
| [`彼秒何秒`](../lib/曆法.wy#L346) | `new Date(x * 1000).getSeconds()` |
65+
66+
## [曆表](../lib/曆表.wy)
67+
68+
| Wenyan | Javascript Equivalent |
69+
|---|---|
70+
2171
## [算經](../lib/算經.wy)
2272

2373
| Wenyan | Javascript Equivalent |
@@ -35,24 +85,26 @@ Last updated: Mon, 30 Dec 2019 15:32:37 GMT
3585
| [`不可算數乎`](../lib/算經.wy#L190) | `Number.isNaN` |
3686
| [`浮點移位`](../lib/算經.wy#L392) | `x * Math.pow(2, y), y is integer` |
3787
| [`析浮點數`](../lib/算經.wy#L428) | `N/A` |
38-
| [`正弦`](../lib/算經.wy#L472) | `Math.sin` |
39-
| [`餘弦`](../lib/算經.wy#L502) | `Math.cos` |
40-
| [`反正弦`](../lib/算經.wy#L510) | `Math.asin` |
41-
| [`反餘弦`](../lib/算經.wy#L537) | `Math.acos` |
42-
| [`正切`](../lib/算經.wy#L544) | `Math.tan` |
43-
| [`反正切`](../lib/算經.wy#L581) | `Math.atan` |
44-
| [`勾股求角`](../lib/算經.wy#L615) | `Math.atan2` |
45-
| [`勾股求弦`](../lib/算經.wy#L633) | `Math.hypot` |
46-
| [`對數`](../lib/算經.wy#L670) | `Math.log` |
47-
| [`指數`](../lib/算經.wy#L713) | `Math.exp` |
48-
| [``](../lib/算經.wy#L749) | `Math.pow` |
49-
| [`平方根`](../lib/算經.wy#L773) | `Math.sqrt` |
50-
| [`絕對`](../lib/算經.wy#L834) | `Math.abs` |
51-
| [`取頂`](../lib/算經.wy#L839) | `Math.ceil` |
52-
| [`取底`](../lib/算經.wy#L844) | `Math.floor` |
53-
| [`取整`](../lib/算經.wy#L859) | `Math.round, but rounded away from zero when the fractional part is exactly 0.5` |
54-
| [`捨餘`](../lib/算經.wy#L873) | `Math.trunc` |
55-
| [`正負`](../lib/算經.wy#L883) | `Math.sign` |
88+
| [`取底除`](../lib/算經.wy#L474) | `{ 商: Math.floor(x / y), 餘: x - y * quo }` |
89+
| [`取整除`](../lib/算經.wy#L491) | `{ 商: Math.round(x / y), 餘: x - y * quo }` |
90+
| [`正弦`](../lib/算經.wy#L565) | `Math.sin` |
91+
| [`餘弦`](../lib/算經.wy#L593) | `Math.cos` |
92+
| [`反正弦`](../lib/算經.wy#L621) | `Math.asin` |
93+
| [`反餘弦`](../lib/算經.wy#L648) | `Math.acos` |
94+
| [`正切`](../lib/算經.wy#L655) | `Math.tan` |
95+
| [`反正切`](../lib/算經.wy#L693) | `Math.atan` |
96+
| [`勾股求角`](../lib/算經.wy#L727) | `Math.atan2` |
97+
| [`勾股求弦`](../lib/算經.wy#L745) | `Math.hypot` |
98+
| [`對數`](../lib/算經.wy#L782) | `Math.log` |
99+
| [`指數`](../lib/算經.wy#L825) | `Math.exp` |
100+
| [``](../lib/算經.wy#L861) | `Math.pow` |
101+
| [`平方根`](../lib/算經.wy#L885) | `Math.sqrt` |
102+
| [`絕對`](../lib/算經.wy#L946) | `Math.abs` |
103+
| [`取頂`](../lib/算經.wy#L951) | `Math.ceil` |
104+
| [`取底`](../lib/算經.wy#L956) | `Math.floor` |
105+
| [`取整`](../lib/算經.wy#L971) | `Math.round, but rounded away from zero when the fractional part is exactly 0.5` |
106+
| [`捨餘`](../lib/算經.wy#L985) | `Math.trunc` |
107+
| [`正負`](../lib/算經.wy#L995) | `Math.sign` |
56108

57109
## [籌經](../lib/籌經.wy)
58110

@@ -65,6 +117,16 @@ Last updated: Mon, 30 Dec 2019 15:32:37 GMT
65117
| Wenyan | Javascript Equivalent |
66118
|---|---|
67119

120+
## [畫譜](../lib/js/畫譜.wy)
121+
122+
| Wenyan | Javascript Equivalent |
123+
|---|---|
124+
125+
## [西曆法](../lib/js/西曆法.wy)
126+
127+
| Wenyan | Javascript Equivalent |
128+
|---|---|
129+
68130

69131

70132

examples/collatz.wy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
欲行是術。必先得一數。
77
曰「乙」。
88
乃行是術曰。
9+
吾有一數。名之曰「埃」。
910
除「乙」以二。所餘幾何。名之曰「積」。
10-
若「積」不等於零者。乘三以「乙」,名之曰「埃」。加一以「埃」,名之曰「埃」
11-
若非 除二於「乙」。名之曰「埃」
11+
若「積」不等於零者。乘三以「乙」。加其於一。昔之「埃」者。今其是矣
12+
若非 除二於「乙」。昔之「埃」者。今其是矣。云云
1213
乃得「埃」。
1314
是謂「助手」之術也。
1415

1516
吾有一列。名之曰「回」。充「回」以「甲」。
1617
恆為是。
17-
若「甲」等於一者乃止。也。
18+
若「甲」等於一者乃止。也。
1819
施「助手」於「甲」。昔之「甲」者。今其是矣。
1920
充「回」以「甲」。
2021
云云。

examples/import.wy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
吾嘗觀「「算經」」之書。方悟「正弦」「餘弦」「圓周率」「取底」「取整」「取頂」「正負」「絕對」之義。
2+
吾嘗觀「「曆法」」之書。方悟「言今之日時」之義。
23
吾嘗觀「「易經」」之書。方悟「占」之義。
34
吾嘗觀「「helloworld」」之書。
45

6+
施「言今之日時」。書之。
7+
58
施「餘弦」於「圓周率」。書之。
69

710
施「占」。書之。
@@ -19,4 +22,4 @@
1922
施「取整」於「圓周率」。書之。
2023
施「取頂」於「圓周率」。書之。
2124
施「絕對」於「圓周率」。書之。
22-
施「正負」於「圓周率」。書之。
25+
施「正負」於「圓周率」。書之。

examples/modinv.wy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
有數一。名之曰「天元」。
77

8-
昔之「右上」者。今「奇數」是矣。
9-
昔之「右下」者。今「定母」是矣。
10-
昔之「左上」者。今「天元」是矣。
11-
昔之「左下」者。今零是矣。
8+
吾有四數。曰「奇數」曰「定母」曰「天元」曰零。
9+
名之曰「右上」曰「右下」曰「左上」曰「左下」。
1210

1311
恆為是。
1412
若「右上」等於一者。乃得「左上」也。

examples/nested_fun.wy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
吾有一列。名之曰「癸」。充「癸」以一以二以三。
55

66
吾有一術。名之曰「丁」。欲行是術。必先得三數。曰「寅」曰「卯」曰「辰」乃行是術曰。
7+
乃得一。
78
是謂「丁」之術也。
89

910
吾有一術。名之曰「戊」。欲行是術。必先得二數。曰「寅」曰「卯」乃行是術曰。
11+
乃得二。
1012
是謂「戊」之術也。
1113

1214
吾有一術。名之曰「己」。欲行是術。必先得一數。曰「寅」乃行是術曰。
15+
乃得三。
1316
是謂「己」之術也。
1417

15-
1618
注曰「「庚 = 戊(甲,乙)」」
1719
夫「甲」。夫「乙」。取二以施「戊」。名之曰「庚」。
1820

examples/sieve.wy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
加一以「戊」。昔之「戊」者。今其是矣云云。
1414

1515
吾有一列。名之曰「諸素」。
16-
有數二。名之曰「戊」。恆為是。若「戊」等於「掩」之長者乃止也。
16+
昔之「戊」者。今二是矣。恆為是。若「戊」等於「掩」之長者乃止也。
1717
夫「掩」之「戊」。名之曰「素耶」。
1818
若「素耶」者充「諸素」以「戊」也。
1919
加一以「戊」。昔之「戊」者。今其是矣云云。

lib/js/畫譜.wy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
今有一術。名之曰「運筆」。欲行是術。必先得一物。曰「紙」。二數。曰「東」曰「南」。乃行是術曰。
4040
有物「紙」。名之曰「canv」。施「canv.getContext」於「「2d」」。名之曰「ctx」。
4141
施「(x=>y=>ctx.lineTo(x,y))」於「東」於「南」。
42-
是謂「備紙」之術也。
42+
是謂「運筆」之術也。
4343

4444
今有一術。名之曰「蘸色」。欲行是術。必先得一物。曰「紙」。一數。曰「色」。乃行是術曰。
4545
有物「紙」。名之曰「canv」。施「canv.getContext」於「「2d」」。名之曰「ctx」。

0 commit comments

Comments
 (0)