Skip to content

Commit 21dfc5d

Browse files
committedApr 12, 2020
Fix bugs,Add new methods
1 parent 851991e commit 21dfc5d

37 files changed

+459
-124
lines changed
 

Diff for: ‎.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

Diff for: ‎.idea/.gitignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎.idea/misc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>YuScript</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

Diff for: ‎.settings/org.eclipse.jdt.core.prefs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8

Diff for: ‎YuScript.iml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager">
4+
<output url="file://$MODULE_DIR$/bin" />
5+
<exclude-output />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
</content>
9+
<orderEntry type="inheritedJdk" />
10+
<orderEntry type="sourceFolder" forTests="false" />
11+
</component>
12+
</module>

Diff for: ‎src/com/rose/yuscript/Main.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript;
55

@@ -18,7 +18,7 @@ public static void main(String[] args) throws Throwable {
1818
br.close();
1919
String str = sb.toString();
2020
YuInterpreter i = new YuInterpreter(0);
21-
i.eval("syso(123 + \"+\" + 789)");
21+
i.eval(str);
2222
}
2323

2424
}

Diff for: ‎src/com/rose/yuscript/YuContext.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript;
55

@@ -114,6 +114,7 @@ public YuContext(int session) {
114114
* Create a new context from the given context
115115
* @param context The source context.Can not be null
116116
*/
117+
@SuppressWarnings("CopyConstructorMissesField")
117118
public YuContext(YuContext context) {
118119
this(context.getSession());
119120
localVariables.putAll(context.localVariables);

Diff for: ‎src/com/rose/yuscript/YuInterpreter.java

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript;
55

66
import java.lang.reflect.Array;
7-
import java.util.Iterator;
87
import java.util.List;
98

109
import com.rose.yuscript.functions.Function;
@@ -65,7 +64,7 @@ public void eval(YuTree tree) throws Throwable {
6564
eval(tree,new YuContext(getSession()));
6665
}
6766

68-
public void eval(YuTree tree,YuContext context) throws Throwable {
67+
public void eval(YuTree tree,YuContext context) {
6968
if(tree == null || context == null) {
7069
throw new IllegalArgumentException("argument(s) can not be null");
7170
}
@@ -107,13 +106,11 @@ public Void visitCodeBlock(YuCodeBlock codeBlock, YuContext value) {
107106
}
108107
value.addCodeBlock(block);
109108
child.accept(this, value);
110-
if(block != null) {
111-
boolean used = value.isCodeBlockUsed();
112-
if(block != YuContext.NO_CODE_BLOCK && used) {
113-
i++;
114-
}
115-
value.popCodeBlock();
109+
boolean used = value.isCodeBlockUsed();
110+
if(block != YuContext.NO_CODE_BLOCK && used) {
111+
i++;
116112
}
113+
value.popCodeBlock();
117114
if(value.isStopFlagSet()) {
118115
break;
119116
}
@@ -142,7 +139,7 @@ private static Long castToLong(Object obj) {
142139
try {
143140
return Long.parseLong(strF);
144141
}catch (NumberFormatException e) {
145-
return null;
142+
return 0L;
146143
}
147144
}
148145

@@ -163,12 +160,10 @@ public Void visitForTree(YuForTree tree, YuContext value) {
163160
}
164161
tree.getCodeBlock().accept(this, value);
165162
}
166-
}else if(right != null && Iterable.class.isInstance(right)) {
163+
}else if(right instanceof Iterable) {
167164
Iterable<?> r = (Iterable<?>)right;
168-
Iterator<?> i = r.iterator();
169-
while(i.hasNext()) {
170-
Object val = i.next();
171-
if(tree.getDest().getType() == YuValue.TYPE_VAR) {
165+
for (Object val : r) {
166+
if (tree.getDest().getType() == YuValue.TYPE_VAR) {
172167
value.setVariable(tree.getDest().getVariableName(), val);
173168
}
174169
tree.getCodeBlock().accept(this, value);

Diff for: ‎src/com/rose/yuscript/YuTokens.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript;
55

Diff for: ‎src/com/rose/yuscript/annotation/ScriptMethod.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.annotation;
55

@@ -11,9 +11,9 @@
1111

1212
@Retention(RetentionPolicy.RUNTIME)
1313
@Target(METHOD)
14-
/**
15-
* @author Rose
16-
*
14+
/*
15+
@author Rose
16+
1717
*/
1818
public @interface ScriptMethod {
1919

Diff for: ‎src/com/rose/yuscript/functions/Function.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.functions;
55

Diff for: ‎src/com/rose/yuscript/functions/FunctionManager.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.functions;
55

@@ -64,11 +64,7 @@ public void removeFunction(Function function) {
6464
}
6565

6666
public void addFunction(Function function) {
67-
List<Function> list = functionMap.get(function.getName());
68-
if(list == null) {
69-
list = new ArrayList<>();
70-
functionMap.put(function.getName(), list);
71-
}
67+
List<Function> list = functionMap.computeIfAbsent(function.getName(), k -> new ArrayList<>());
7268
if(list.contains(function)) {
7369
throw new IllegalArgumentException("Function has been added");
7470
}

Diff for: ‎src/com/rose/yuscript/functions/JavaFunction.java

+29-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.functions;
@@ -20,7 +20,7 @@ public class JavaFunction implements Function {
2020
private int argCount;
2121
private String name;
2222
private boolean firstRtv;
23-
23+
2424
public JavaFunction(Method method) {
2525
this.method = method;
2626
params = method.getParameterTypes();
@@ -44,12 +44,12 @@ public JavaFunction(Method method) {
4444
firstRtv = method.getAnnotation(ScriptMethod.class).returnValueAtBegin();
4545
this.name = method.getName();
4646
}
47-
47+
4848
public JavaFunction(Method method,String name) {
4949
this(method);
5050
this.name = name;
5151
}
52-
52+
5353
@Override
5454
public String getName() {
5555
return this.name;
@@ -59,7 +59,7 @@ public String getName() {
5959
public int getArgumentCount() {
6060
return argCount;
6161
}
62-
62+
6363
private static Object get(YuExpression expr,Class<?> clazz,YuContext context) {
6464
if(clazz == YuExpression.class) {
6565
return expr;
@@ -78,6 +78,7 @@ public void invoke(List<YuExpression> arguments, YuContext context, YuInterprete
7878
YuExpression rt;
7979
Object value;
8080
if(firstRtv) {
81+
int pointerArgument = 1;
8182
for(int i = 0;i < params.length;i++) {
8283
if(params[i].isArray()) {
8384
if(params[i] == Object[].class) {
@@ -94,11 +95,21 @@ public void invoke(List<YuExpression> arguments, YuContext context, YuInterprete
9495
args[i] = array;
9596
}
9697
}else {
97-
args[i] = get(i + 1 >= arguments.size() ? null : arguments.get(i + 1), params[i], context);
98+
YuExpression expr = arguments.get(pointerArgument);
99+
if(params[i] == YuExpression.class) {
100+
args[i] = expr;
101+
pointerArgument++;
102+
}else if(params[i] == Object.class) {
103+
args[i] = expr.getValue(context);
104+
pointerArgument++;
105+
}else if(params[i] == YuContext.class) {
106+
args[i] = context;
107+
}
98108
}
99109
}
100110
rt = arguments.get(0);
101111
}else {
112+
int pointerArgument = 0;
102113
for(int i = 0;i < params.length;i++) {
103114
if(params[i].isArray()) {
104115
if(params[i] == Object[].class) {
@@ -115,7 +126,16 @@ public void invoke(List<YuExpression> arguments, YuContext context, YuInterprete
115126
args[i] = array;
116127
}
117128
}else {
118-
args[i] = get(i >= arguments.size() ? null : arguments.get(i), params[i], context);
129+
YuExpression expr = arguments.get(pointerArgument);
130+
if(params[i] == YuExpression.class) {
131+
args[i] = expr;
132+
pointerArgument++;
133+
}else if(params[i] == Object.class) {
134+
args[i] = expr.getValue(context);
135+
pointerArgument++;
136+
}else if(params[i] == YuContext.class) {
137+
args[i] = context;
138+
}
119139
}
120140
}
121141
rt = arguments.get(arguments.size() - 1);
@@ -141,7 +161,7 @@ public void invoke(List<YuExpression> arguments, YuContext context, YuInterprete
141161
}
142162
args[i] = array;
143163
}else {
144-
args[i] = arguments.toArray(new YuExpression[arguments.size()]);
164+
args[i] = arguments.toArray(new YuExpression[0]);
145165
}
146166
}else {
147167
args[i] = get(i >= arguments.size() ? null : arguments.get(i), params[i], context);
@@ -150,5 +170,5 @@ public void invoke(List<YuExpression> arguments, YuContext context, YuInterprete
150170
method.invoke(null, args);
151171
}
152172
}
153-
173+
154174
}

Diff for: ‎src/com/rose/yuscript/functions/YuMethod.java

+282-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
/**
1+
/*
22
* This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.functions;
55

6+
import java.lang.reflect.Array;
7+
import java.math.BigDecimal;
8+
import java.math.RoundingMode;
69
import java.text.SimpleDateFormat;
710

811
import com.rose.yuscript.YuContext;
912
import com.rose.yuscript.annotation.ScriptMethod;
1013
import com.rose.yuscript.tree.YuCodeBlock;
14+
import com.rose.yuscript.tree.YuExpression;
1115
import com.rose.yuscript.tree.YuSyntaxError;
16+
import com.rose.yuscript.tree.YuValue;
17+
1218
import static com.rose.yuscript.YuInterpreter.*;
1319

1420
/**
1521
* @author Rose
1622
*
1723
*/
24+
@SuppressWarnings("unused")
1825
public class YuMethod {
1926

2027
private final static SimpleDateFormat FORMAT = new SimpleDateFormat("HH:mm:ss.SSS");
@@ -40,11 +47,7 @@ public static void t(YuContext context) {
4047
}
4148
final YuContext newContext = new YuContext(context);
4249
final YuCodeBlock block = context.getCodeBlock();
43-
new Thread() {
44-
public void run() {
45-
context.getDeclaringInterpreter().visitCodeBlock(block, newContext);
46-
}
47-
}.start();
50+
new Thread(() -> context.getDeclaringInterpreter().visitCodeBlock(block, newContext)).start();
4851
}
4952

5053
@ScriptMethod
@@ -62,5 +65,277 @@ public static int slg(Object obj) {
6265
public static int rslg(Object obj) {
6366
return stringForm(obj).length();
6467
}
65-
68+
69+
@ScriptMethod
70+
public static void tw(Object[] objs) {
71+
syso(objs);
72+
}
73+
74+
@ScriptMethod
75+
public static Long s(YuContext context,YuExpression expr) {
76+
return calculate(context,expr);
77+
}
78+
79+
@ScriptMethod
80+
public static Double s2(YuContext context,YuExpression expr) {
81+
BigDecimal bg = BigDecimal.valueOf(calculate2(context, expr));
82+
return bg.setScale(2, RoundingMode.HALF_UP).doubleValue();
83+
}
84+
85+
@ScriptMethod
86+
public static Double sn(YuContext context,YuExpression expr) {
87+
return calculate2(context, expr);
88+
}
89+
90+
@SuppressWarnings("incomplete-switch")
91+
public static Long calculate(YuContext context,YuValue expr) {
92+
if(expr instanceof YuExpression) {
93+
YuExpression e = (YuExpression) expr;
94+
long ans = 0;
95+
long composing = calculate(context, e.getChildren().get(0));
96+
boolean plusOrMinus = true;
97+
for(int i = 0;i < e.getOperators().size();i++) {
98+
long val = calculate(context, e.getChildren().get(i + 1));
99+
switch(e.getOperators().get(i)) {
100+
case PLUS:
101+
if(plusOrMinus) {
102+
ans += composing;
103+
}else {
104+
ans -= composing;
105+
}
106+
composing = val;
107+
plusOrMinus = true;
108+
break;
109+
case MINUS:
110+
if(plusOrMinus) {
111+
ans += composing;
112+
}else {
113+
ans -= composing;
114+
}
115+
composing = val;
116+
plusOrMinus = false;
117+
break;
118+
case MULTIPLY:
119+
composing *= val;
120+
break;
121+
case DIVIDE:
122+
composing /= val;
123+
break;
124+
}
125+
}
126+
if(plusOrMinus) {
127+
ans += composing;
128+
}else {
129+
ans -= composing;
130+
}
131+
return ans;
132+
}else {
133+
Object value = null;
134+
switch(expr.getType()) {
135+
case YuValue.TYPE_BOOL:
136+
value = expr.isInvert() == (!expr.getBool());
137+
if((Boolean)value) {
138+
value = 1;
139+
}else {
140+
value = 0;
141+
}
142+
break;
143+
case YuValue.TYPE_NULL:
144+
value = 0;
145+
break;
146+
case YuValue.TYPE_NUM:
147+
value = expr.getNumber();
148+
break;
149+
case YuValue.TYPE_STR:
150+
value = expr.getString();
151+
break;
152+
case YuValue.TYPE_VAR:
153+
value = expr.getValue(context);
154+
}
155+
if(value == null) {
156+
return 0L;
157+
}else if(value instanceof Number){
158+
return ((Number)value).longValue();
159+
}else {
160+
return (long)Double.parseDouble(value instanceof String ? (String)value : value.toString());
161+
}
162+
}
163+
}
164+
@SuppressWarnings("incomplete-switch")
165+
public static Double calculate2(YuContext context, YuValue expr) {
166+
if(expr instanceof YuExpression) {
167+
YuExpression e = (YuExpression) expr;
168+
double ans = 0D;
169+
double composing = calculate2(context, e.getChildren().get(0));
170+
boolean plusOrMinus = true;
171+
for(int i = 0;i < e.getOperators().size();i++) {
172+
double val = calculate2(context, e.getChildren().get(i + 1));
173+
switch(e.getOperators().get(i)) {
174+
case PLUS:
175+
if(plusOrMinus) {
176+
ans += composing;
177+
}else {
178+
ans -= composing;
179+
}
180+
composing = val;
181+
plusOrMinus = true;
182+
break;
183+
case MINUS:
184+
if(plusOrMinus) {
185+
ans += composing;
186+
}else {
187+
ans -= composing;
188+
}
189+
composing = val;
190+
plusOrMinus = false;
191+
break;
192+
case MULTIPLY:
193+
composing *= val;
194+
break;
195+
case DIVIDE:
196+
composing /= val;
197+
break;
198+
}
199+
}
200+
if(plusOrMinus) {
201+
ans += composing;
202+
}else {
203+
ans -= composing;
204+
}
205+
return ans;
206+
}else {
207+
Object value = null;
208+
switch(expr.getType()) {
209+
case YuValue.TYPE_BOOL:
210+
value = expr.isInvert() == (!expr.getBool());
211+
if((Boolean)value) {
212+
value = 1;
213+
}else {
214+
value = 0;
215+
}
216+
break;
217+
case YuValue.TYPE_NULL:
218+
value = 0;
219+
break;
220+
case YuValue.TYPE_NUM:
221+
value = expr.getNumber();
222+
break;
223+
case YuValue.TYPE_STR:
224+
value = expr.getString();
225+
break;
226+
case YuValue.TYPE_VAR:
227+
value = expr.getValue(context);
228+
}
229+
if(value == null) {
230+
return 0D;
231+
}else if(value instanceof Number){
232+
return ((Number)value).doubleValue();
233+
}else {
234+
return Double.parseDouble(value instanceof String ? (String)value : value.toString());
235+
}
236+
}
237+
}
238+
239+
@ScriptMethod
240+
public static String ssg(Object str,Object p1,Object p2) {
241+
return getString(str).substring(getInt(p1), getInt(p2));
242+
}
243+
244+
@ScriptMethod
245+
public static String sj(Object str,Object p1,Object p2) {
246+
String a = getString(p1);
247+
String b = getString(p2);
248+
String c = getString(str);
249+
return c.substring(c.indexOf(a) + a.length() , c.indexOf(b));
250+
}
251+
252+
@ScriptMethod
253+
public static String sr(Object str,Object p1,Object p2) {
254+
String a = getString(p1);
255+
String b = getString(p2);
256+
String c = getString(str);
257+
return c.replace(a, b);
258+
}
259+
260+
@ScriptMethod
261+
public static String sr(Object str,Object p1,Object p2,Object action) {
262+
if(getBool(action)) {
263+
String a = getString(p1);
264+
String b = getString(p2);
265+
String c = getString(str);
266+
return c.replaceAll(a, b);
267+
}else {
268+
return sr(str, p1, p2);
269+
}
270+
}
271+
272+
@ScriptMethod
273+
public static String[] sl(Object a,Object b) {
274+
return getString(a).split(getString(b));
275+
}
276+
277+
@ScriptMethod
278+
public static int sgszl(Object array) {
279+
try {
280+
return Array.getLength(array);
281+
}catch (Exception e) {
282+
return -1;
283+
}
284+
}
285+
286+
@ScriptMethod
287+
public static Object sgsz(Object array,Object pos) {
288+
try {
289+
return Array.get(array,getInt(pos));
290+
}catch (Exception e) {
291+
return null;
292+
}
293+
}
294+
295+
@ScriptMethod
296+
public static void sssz(Object array,Object pos,Object val) {
297+
if(array.getClass().isArray()) {
298+
Array.set(array, getInt(val), val);
299+
}else {
300+
throw new IllegalArgumentException();
301+
}
302+
}
303+
304+
private static boolean getBool(Object p) {
305+
if(p == null) {
306+
return false;
307+
}else if(p instanceof Boolean) {
308+
return (Boolean) p;
309+
}else if(p instanceof CharSequence){
310+
try {
311+
return Boolean.parseBoolean(p.toString());
312+
}catch (Exception e) {
313+
return true;
314+
}
315+
}else {
316+
return true;
317+
}
318+
}
319+
320+
private static String getString(Object p) {
321+
if(p == null) {
322+
return "null";
323+
}else if(p instanceof String) {
324+
return (String)p;
325+
}else {
326+
return String.valueOf(p);
327+
}
328+
}
329+
330+
private static int getInt(Object p) {
331+
if(p == null) {
332+
return 0;
333+
}else if(p instanceof Number) {
334+
return ((Number)p).intValue();
335+
}else {
336+
return Integer.parseInt(p instanceof String ? (String)p : p.toString());
337+
}
338+
}
339+
340+
66341
}

Diff for: ‎src/com/rose/yuscript/tree/YuAssignment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuBreak.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuCodeBlock.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuCondition.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuConditionalExpression.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -64,7 +64,7 @@ public boolean getValue(YuContext context) {
6464
switch(operator) {
6565
case ANDAND:
6666
if(condition) {
67-
condition = condition && getChildren().get(i + 1).getValue(context);
67+
condition = getChildren().get(i + 1).getValue(context);
6868
}else {
6969
break loop;
7070
}
@@ -73,7 +73,7 @@ public boolean getValue(YuContext context) {
7373
if(condition) {
7474
break loop;
7575
}else {
76-
condition = condition || getChildren().get(i + 1).getValue(context);
76+
condition = getChildren().get(i + 1).getValue(context);
7777
}
7878
}
7979
}

Diff for: ‎src/com/rose/yuscript/tree/YuEndcode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuExpression.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuForTree.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuFunctionCall.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -22,7 +22,7 @@ public <T, R> R accept(YuTreeVisitor<R, T> visitor, T value) {
2222
}
2323

2424
public YuFunctionCall() {
25-
arguments = new ArrayList<YuExpression>();
25+
arguments = new ArrayList<>();
2626
}
2727

2828
public void addArgument(YuExpression expression) {

Diff for: ‎src/com/rose/yuscript/tree/YuIfTree.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuNode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuScope.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuSyntaxError.java

+7-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -9,45 +9,28 @@
99
*/
1010
public class YuSyntaxError extends Error {
1111

12-
/**
13-
*
14-
*/
12+
1513
private static final long serialVersionUID = -2093795813319607171L;
1614

17-
/**
18-
*
19-
*/
15+
2016
public YuSyntaxError() {
2117
}
2218

23-
/**
24-
* @param message
25-
*/
19+
2620
public YuSyntaxError(String message) {
2721
super(message);
2822
}
2923

30-
/**
31-
* @param cause
32-
*/
24+
3325
public YuSyntaxError(Throwable cause) {
3426
super(cause);
3527
}
3628

37-
/**
38-
* @param message
39-
* @param cause
40-
*/
29+
4130
public YuSyntaxError(String message, Throwable cause) {
4231
super(message, cause);
4332
}
4433

45-
/**
46-
* @param message
47-
* @param cause
48-
* @param enableSuppression
49-
* @param writableStackTrace
50-
*/
5134
public YuSyntaxError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
5235
super(message, cause, enableSuppression, writableStackTrace);
5336
}

Diff for: ‎src/com/rose/yuscript/tree/YuTokenizer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -327,6 +327,7 @@ protected void scanTrans() {
327327
length++;
328328
}
329329
} else {
330+
bad();
330331
}
331332
}
332333

Diff for: ‎src/com/rose/yuscript/tree/YuTree.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -246,11 +246,9 @@ private YuFunctionCall parseFunctionCall() throws YuSyntaxError {
246246
YuExpression expr = parseExpression();
247247
call.addArgument(expr);
248248
tokenizer.nextToken();
249-
if(tokenizer.getToken() == COMMA) {
250-
251-
}else if(tokenizer.getToken() == RPAREN) {
249+
if(tokenizer.getToken() == RPAREN) {
252250
break;
253-
}else {
251+
}else if(tokenizer.getToken() != COMMA){
254252
throw new YuSyntaxError();
255253
}
256254
}

Diff for: ‎src/com/rose/yuscript/tree/YuTreeVisitor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/tree/YuValue.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

@@ -126,8 +126,6 @@ public void setNull() {
126126

127127
/**
128128
* Get value
129-
* @param context
130-
* @return
131129
*/
132130
public Object getValue(YuContext context) {
133131
switch(getType()) {

Diff for: ‎src/com/rose/yuscript/tree/YuWhileTree.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.tree;
55

Diff for: ‎src/com/rose/yuscript/util/MyCharacter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.util;
55

Diff for: ‎src/com/rose/yuscript/util/TrieTree.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* This Java File is Created By Rose
1+
/*
2+
This Java File is Created By Rose
33
*/
44
package com.rose.yuscript.util;
55

0 commit comments

Comments
 (0)
Please sign in to comment.