refactor: 重构模板代码
This commit is contained in:
parent
87560db20d
commit
d11822f4ba
@ -71,7 +71,7 @@ public class ASTPrinter {
|
|||||||
NodeContext _
|
NodeContext _
|
||||||
) -> {
|
) -> {
|
||||||
System.out.println(pad + "function " + name
|
System.out.println(pad + "function " + name
|
||||||
+ "(params=" + parameters + ", return=" + returnType + ")");
|
+ "(params=" + parameters + ", returns=" + returnType + ")");
|
||||||
for (StatementNode stmt : body) {
|
for (StatementNode stmt : body) {
|
||||||
print(stmt, indent + 1);
|
print(stmt, indent + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,8 @@ public final class SnowExample {
|
|||||||
return """
|
return """
|
||||||
module: Math
|
module: Math
|
||||||
function: main
|
function: main
|
||||||
parameter:
|
params:
|
||||||
return_type: int
|
returns: int
|
||||||
body:
|
body:
|
||||||
Math.factorial(6)
|
Math.factorial(6)
|
||||||
return 0
|
return 0
|
||||||
@ -33,9 +33,9 @@ public final class SnowExample {
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function: factorial
|
function: factorial
|
||||||
parameter:
|
params:
|
||||||
declare n: int
|
declare n: int
|
||||||
return_type: int
|
returns: int
|
||||||
body:
|
body:
|
||||||
declare num1: int = 1
|
declare num1: int = 1
|
||||||
loop:
|
loop:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user