Skip to content

Commit 53553db

Browse files
author
magiclu550
committed
fix a bug about wenyan2number
1 parent 12f350e commit 53553db

File tree

4 files changed

+119
-79
lines changed

4 files changed

+119
-79
lines changed

src/main/java/cn/wenyan/compiler/WenYanShell.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void run(String wenyan){
4141
public synchronized Object run(boolean out,String... wenyanString){
4242
compiler.getServerLogger().info("---------------运行之--------------------");
4343
String code = compiler.getGroovyCode(true,out, wenyanString);
44+
//System.out.println(code);
4445
return run.evaluate(code);
4546

4647
}

src/main/java/cn/wenyan/compiler/utils/NumberTree.groovy

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cn.wenyan.compiler.utils
22

3-
import groovy.transform.CompileStatic;
3+
import groovy.transform.CompileStatic
4+
5+
import java.util.stream.Collectors;
46

57
@CompileStatic
68
class NumberTree {
@@ -21,6 +23,7 @@ class NumberTree {
2123
if(wenyan.size() == 1)return
2224
if(index == -1)return
2325
String left = wenyan.substring(0,index)
26+
left = left.empty?"":left
2427
String right = wenyan.substring(index+1)
2528
String max = wenyan.charAt(index)
2629
node.left = new Node()
@@ -57,10 +60,10 @@ class NumberTree {
5760
for(int i = 0;i<nodes.size();i+=2){
5861
result += GroovyUtils.getNumber(nodes[i].value) * GroovyUtils.getNumber(i+1<nodes.size()?nodes[i+1].value:"")
5962
}
63+
println(result)
6064
(result + floatValue)*prefix
6165
}
6266

63-
6467
}
6568
@CompileStatic
6669
class Node{
@@ -82,4 +85,8 @@ class Node{
8285
String toString() {
8386
return value
8487
}
88+
89+
boolean isEmpty(){
90+
return value.empty
91+
}
8592
}

start/compiler.groovy

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,6 @@
1+
import cn.wenyan.compiler.WenYanShell
12
import cn.wenyan.compiler.WenYanTools
23

3-
WenYanTools.default.runtime.shell.run(false,"吾有一術。名之曰「圖靈機」。欲行是術。必先得一列。曰「諸律」。二言。曰「始態」。曰「終態」。\n" +
4-
"乃行是術曰。\n" +
5-
"\t吾有一列。名之曰「帶」。充「帶」以「「白」」。\n" +
6-
"\t有數一。名之曰「針」。\n" +
7-
"\n" +
8-
"\t吾有二數。曰一。曰一。名之曰「左疆」。曰「右疆」。\n" +
9-
"\t吾有一言。曰「始態」。名之曰「態」。\n" +
10-
"\n" +
11-
"\t吾有一術。名之曰「圖靈機畫法」。是術曰。\n" +
12-
"\t\t吾有一言。名之曰「畫帶」。\n" +
13-
"\t\t有數「左疆」。名之曰「筆」。恆為是。若「筆」大於「右疆」者乃止也。\n" +
14-
"\t\t\t夫「帶」之「筆」。名之曰「符」。\n" +
15-
"\t\t\t若「針」等於「筆」者。\n" +
16-
"\t\t\t\t加「符」於「「〔」」。加其以「「〕」」昔之「符」者。今其是矣\n" +
17-
"\t\t\t若非。\n" +
18-
"\t\t\t\t加「符」於「「、」」。加其以「「、」」昔之「符」者。今其是矣\n" +
19-
"\t\t\t云云。\n" +
20-
"\t\t\t加「畫帶」以「符」。昔之「畫帶」者。今其是矣。\n" +
21-
"\n" +
22-
"\t\t加一以「筆」。昔之「筆」者。今其是矣云云。\n" +
23-
"\t\t吾有四言。曰「態」。曰「「《」」。曰「畫帶」。曰「「》」」書之。\n" +
24-
"\t是謂「圖靈機畫法」之術也。\n" +
25-
"\n" +
26-
"\t施「圖靈機畫法」。噫。\n" +
27-
"\n" +
28-
"\t恆為是。\n" +
29-
"\t\t凡「諸律」中之「律」\n" +
30-
"\t\t\t夫「律」之一。名之曰「甲態」。\n" +
31-
"\t\t\t夫「律」之二。名之曰「讀符」。\n" +
32-
"\t\t\t夫「律」之三。名之曰「乙態」。\n" +
33-
"\t\t\t夫「律」之四。名之曰「畫符」。\n" +
34-
"\t\t\t夫「律」之五。名之曰「移」。\n" +
35-
"\n" +
36-
"\t\t\t若「態」等於「甲態」者。若「帶」之「針」等於「讀符」者。\n" +
37-
"\t\t\t\t昔之「帶」之「針」者。今「畫符」是矣。\n" +
38-
"\t\t\t\t昔之「態」者。今「乙態」是矣。\n" +
39-
"\t\t\t\t若「移」等於「「左」」者。減一於「針」。昔之「針」者。今其是矣。云云。\n" +
40-
"\t\t\t\t若「移」等於「「右」」者。加一於「針」。昔之「針」者。今其是矣。云云。\n" +
41-
"\t\t\t\t乃止。\n" +
42-
"\t\t\t云云云云\n" +
43-
"\t\t云云。\n" +
44-
"\n" +
45-
"\t\t若「針」小於「左疆」者。\n" +
46-
"\t\t\t昔之「帶」之「針」者。今「「白」」是矣。\n" +
47-
"\t\t\t昔之「左疆」者。今「針」是矣。\n" +
48-
"\t\t云云\n" +
49-
"\t\t若「針」大於「右疆」者。\n" +
50-
"\t\t\t昔之「帶」之「針」者。今「「白」」是矣。\n" +
51-
"\t\t\t昔之「右疆」者。今「針」是矣。\n" +
52-
"\t\t云云\n" +
53-
"\n" +
54-
"\t\t施「圖靈機畫法」。噫。\n" +
55-
"\t\t若「態」等於「終態」者乃止也。\n" +
56-
"\t云云。\n" +
57-
"是謂「圖靈機」之術也。\n" +
58-
"\n" +
59-
"\n" +
60-
"吾有一術。名之曰「製律」。欲行是術。必先得一列。曰「諸律」。\n" +
61-
"\t五言。曰「甲態」。曰「讀符」。曰「乙態」。曰「畫符」。曰「移」。乃行是術曰。\n" +
62-
"\t吾有一列。名之曰「律」。\n" +
63-
"\t充「律」以「甲態」。以「讀符」。以「乙態」。以「畫符」。以「移」。\n" +
64-
"\t充「諸律」以「律」。\n" +
65-
"是謂「製律」之術也。\n" +
66-
"\n" +
67-
"吾有一言。曰「「營營河狸。止于樊。」」。書之。\n" +
68-
"\n" +
69-
"吾有一列。名之曰「諸律」。\n" +
70-
"吾有一言。曰「「墨」」。名之曰「陽符」。\n" +
71-
"吾有一言。曰「「白」」。名之曰「陰符」。\n" +
72-
"施「製律」於「諸律」於「「甲」」於「陰符」於「「乙」」於「陽符」於「「右」」\n" +
73-
"施「製律」於「諸律」於「「甲」」於「陽符」於「「丙」」於「陽符」於「「左」」\n" +
74-
"施「製律」於「諸律」於「「乙」」於「陰符」於「「甲」」於「陽符」於「「左」」\n" +
75-
"施「製律」於「諸律」於「「乙」」於「陽符」於「「乙」」於「陽符」於「「右」」\n" +
76-
"施「製律」於「諸律」於「「丙」」於「陰符」於「「乙」」於「陽符」於「「左」」\n" +
77-
"施「製律」於「諸律」於「「丙」」於「陽符」於「「樊」」於「陽符」於「「中」」\n" +
78-
"\n" +
79-
"施「圖靈機」於「諸律」於「「甲」」於「「樊」」。")
4+
WenYanTools.default.runtime.shell.run(false,
5+
"吾有一數,曰十二,名之曰「加」")
6+

start/test.groovy

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
def 曼德博( 寬, 高){
2+
/*曼德博集。亦稱曼德布洛特复数集合。复平面上组成分形之点之集合也。*/
3+
def 皴法 = """丁龘蠹臺龜畫龍淼蔑高五三二"""
4+
5+
/*皴法者。圖畫之法也*/
6+
def ans_1 = 0-1
7+
def= ans_1
8+
9+
def ans_2 = 0+1
10+
def= ans_2
11+
12+
def ans_3 = 0-2
13+
def= ans_3
14+
15+
def ans_4 = 0+2
16+
def= ans_4
17+
18+
def ans_5 =-
19+
def ans_6 = ans_5/
20+
def 橫步 = ans_6
21+
22+
def ans_7 =-
23+
def ans_8 = ans_7/
24+
def 縱步 = ans_8
25+
26+
def= 0
27+
28+
while(true){
29+
if(戊==高){
30+
break
31+
}
32+
def ans_9 = 縱步*
33+
def ans_10 = ans_9+
34+
def= ans_10
35+
36+
def= ''
37+
38+
def= 0
39+
40+
while(true){
41+
if(戌==寬){
42+
break
43+
}
44+
def ans_11 = 橫步*
45+
def ans_12 = ans_11+
46+
def= ans_12
47+
48+
def 虛虛 =
49+
50+
def 實實 =
51+
52+
/*凡每一像素。皆算令其收斂之最大疊代數*/
53+
def= 0
54+
55+
while(true){
56+
if(己==2){ //
57+
break
58+
}
59+
def ans_13 = 實實*實實
60+
def ans_14 = 虛虛*虛虛
61+
def= ans_13
62+
def= ans_14
63+
64+
def ans_15 =+
65+
def= ans_15
66+
67+
if(丙>4){
68+
break
69+
}
70+
def ans_16 = 虛虛*實實
71+
def ans_17 = ans_16*2
72+
def ans_18 = ans_17+
73+
虛虛 = ans_18
74+
75+
def ans_19 =-
76+
def ans_20 = ans_19+
77+
實實 = ans_20
78+
79+
def ans_21 = 1+
80+
= ans_21
81+
82+
}
83+
/*既得疊代數。乃以皴法圖之*/
84+
def ans_22 = 3-
85+
def= ans_22
86+
87+
def ans_23 = getArray(皴法)[getIndex(巳)]
88+
def= ans_23
89+
90+
def ans_24 =+
91+
= ans_24
92+
93+
def ans_25 = 1+
94+
= ans_25
95+
96+
}
97+
def ans_26 = ''++''
98+
println(ans_26 .toString())
99+
def ans_27 = 1+
100+
= ans_27
101+
102+
}
103+
}
104+
/*畫曼德博集合之法。至是盡矣。乃一試之*/
105+
def ans_28 = 曼德博(59,24)

0 commit comments

Comments
 (0)