Skip to content

Commit

Permalink
fix obj literal bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lingdong Huang committed Dec 19, 2019
1 parent e229e48 commit 58bee3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions examples/obj.wy
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
吾有一物。名之曰「精衛」。其物如是。
物之「」者。言曰「「女娃」」。
物之「足數」者。數曰二。
物之「喙數」者。數曰一。
物之「「名」」者。言曰「「女娃」」。
物之「「足數」」者。數曰二。
物之「「喙數」」者。數曰一。
是謂「精衛」之物也。

吾有一術。名之曰「造物之術」。欲行是術。必先得一言。曰「甲」。乃行是術曰。
吾有一物。名之曰「乙」。其物如是。
物之「」者。言曰「甲」。
物之「」者。數曰四。
物之「「丙」」者。言曰「甲」。
物之「「丁」」者。數曰四。
是謂「乙」之物也。
乃得「乙」。
是謂「造物之術」之物也。

施「造物之術」。名之曰「戊」。
施「造物之術」於「「某甲」」。名之曰「戊」。
昔之「戊」之「「丁」」者。今五是矣。
施「JSON.stringify」於「戊」。書之。
昔之「戊」之「「丁」」者。今不復存矣。
Expand Down
4 changes: 2 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function tokens2asc(
}
asc.push(x);
} else if (gettok(i, 0) == "decl" && gettok(i, 1) == "prop") {
typeassert(i + 1, ["iden"], "identifier");
typeassert(i + 1, ["lit"], "property key");
typeassert(i + 3, ["type"], "property type");
typeassert(i + 4, ["assgn"], "property value");
var x = {
Expand Down Expand Up @@ -672,7 +672,7 @@ function asc2js(asc) {
} else if (a.op == "objbody") {
js += `${prevobj}={`;
} else if (a.op == "prop") {
js += `"${a.name}":${a.value[1]},`;
js += `${a.name}:${a.value[1]},`;
} else if (a.op == "end") {
js += "}";
curlvl--;
Expand Down

0 comments on commit 58bee3c

Please sign in to comment.