@graffiticode/parser 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,9 @@
4
4
  "Bash(NODE_OPTIONS=--experimental-vm-modules npx jest:*)",
5
5
  "Bash(npx eslint:*)",
6
6
  "Bash(npm test:*)",
7
- "Bash(npm publish:*)"
7
+ "Bash(npm publish:*)",
8
+ "Bash(grep:*)",
9
+ "Bash(npm install:*)"
8
10
  ]
9
11
  }
10
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graffiticode/parser",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { parser } from "./parser.js";
2
+ export { unparse } from "./unparse.js";
@@ -2,6 +2,7 @@ import { jest } from "@jest/globals";
2
2
  import { buildParser, parser } from "./parser.js";
3
3
  import { mockPromiseValue, mockPromiseError } from "./testing/index.js";
4
4
  import { lexicon as basisLexicon } from "@graffiticode/basis";
5
+ import { unparse } from "./unparse.js";
5
6
 
6
7
  describe("lang/parser", () => {
7
8
  const log = jest.fn();
@@ -547,6 +548,36 @@ describe("parser integration tests", () => {
547
548
  expect(strNode.elts[0]).toBe("Price: ${amount}");
548
549
  });
549
550
 
551
+ it("should parse and unparse a tag node", async () => {
552
+ // Arrange - use an empty lexicon so "foo" is not recognized as a function
553
+ const emptyLexicon = {};
554
+
555
+ // Act - parse "foo.." where "foo" is not in the lexicon, producing a TAG node
556
+ const result = await parser.parse(0, "foo..", emptyLexicon);
557
+
558
+ // Assert - find the TAG node
559
+ expect(result).toHaveProperty("root");
560
+
561
+ let tagNode = null;
562
+ for (const key in result) {
563
+ if (key !== "root") {
564
+ const node = result[key];
565
+ if (node.tag === "TAG" && node.elts[0] === "foo") {
566
+ tagNode = node;
567
+ break;
568
+ }
569
+ }
570
+ }
571
+
572
+ expect(tagNode).not.toBeNull();
573
+ expect(tagNode.tag).toBe("TAG");
574
+ expect(tagNode.elts).toEqual(["foo"]);
575
+
576
+ // Unparse should reproduce the original source
577
+ const source = unparse(result, emptyLexicon);
578
+ expect(source).toBe("foo..");
579
+ });
580
+
550
581
  it("should parse strings with mixed escape sequences", async () => {
551
582
  // Arrange & Act
552
583
  const result = await parser.parse(0, '"Line 1\\nTab\\t\\"Quote\\""..', basisLexicon);