diff --git a/src/main/java/org/jcnc/snow/compiler/parser/utils/ASTJsonSerializer.java b/src/main/java/org/jcnc/snow/compiler/parser/utils/ASTJsonSerializer.java index 278a42c..51ba838 100644 --- a/src/main/java/org/jcnc/snow/compiler/parser/utils/ASTJsonSerializer.java +++ b/src/main/java/org/jcnc/snow/compiler/parser/utils/ASTJsonSerializer.java @@ -121,7 +121,7 @@ public class ASTJsonSerializer { Map map = newNodeMap("Declaration"); map.put("name", d.getName()); map.put("varType", d.getType()); - map.put("initializer", d.getInitializer().map(ASTJsonSerializer::exprToMap).orElse(null)); + map.put("init", d.getInitializer().map(ASTJsonSerializer::exprToMap).orElse(null)); yield map; } // 赋值语句节点 @@ -132,7 +132,7 @@ public class ASTJsonSerializer { // 条件语句节点 case IfNode i -> { Map map = newNodeMap("If"); - map.put("condition", exprToMap(i.condition())); + map.put("cond", exprToMap(i.condition())); List thenList = new ArrayList<>(i.thenBranch().size()); for (Node stmt : i.thenBranch()) thenList.add(nodeToMap(stmt)); map.put("then", thenList); @@ -146,9 +146,9 @@ public class ASTJsonSerializer { // 循环语句节点 case LoopNode l -> { Map map = newNodeMap("Loop"); - map.put("initializer", l.initializer() != null ? nodeToMap(l.initializer()) : null); - map.put("condition", l.condition() != null ? exprToMap(l.condition()) : null); - map.put("update", l.update() != null ? nodeToMap(l.update()) : null); + map.put("init", l.init() != null ? nodeToMap(l.init()) : null); + map.put("cond", l.cond() != null ? exprToMap(l.cond()) : null); + map.put("step", l.step() != null ? nodeToMap(l.step()) : null); List body = new ArrayList<>(l.body().size()); for (Node stmt : l.body()) body.add(nodeToMap(stmt)); map.put("body", body);