@stackables/bridge 1.6.0 → 1.7.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.
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { parseBridge } from "./bridge-format.js";
1
+ export { parseBridgeChevrotain, parseBridgeChevrotain as parseBridge } from "./parser/index.js";
2
2
  export { bridgeTransform, getBridgeTraces, useBridgeTracing } from "./bridge-transform.js";
3
3
  export type { BridgeOptions, InstructionSource } from "./bridge-transform.js";
4
4
  export { builtinTools, std, createHttpCall } from "./tools/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
package/build/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { parseBridge } from "./bridge-format.js";
1
+ export { parseBridgeChevrotain, parseBridgeChevrotain as parseBridge } from "./parser/index.js";
2
2
  export { bridgeTransform, getBridgeTraces, useBridgeTracing } from "./bridge-transform.js";
3
3
  export { builtinTools, std, createHttpCall } from "./tools/index.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Chevrotain-based parser for the Bridge DSL.
3
+ *
4
+ * Re-exports the public parse function as well as the lexer for direct access.
5
+ */
6
+ export { parseBridgeChevrotain } from "./parser.js";
7
+ export { BridgeLexer, allTokens } from "./lexer.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Chevrotain-based parser for the Bridge DSL.
3
+ *
4
+ * Re-exports the public parse function as well as the lexer for direct access.
5
+ */
6
+ export { parseBridgeChevrotain } from "./parser.js";
7
+ export { BridgeLexer, allTokens } from "./lexer.js";
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Chevrotain Lexer for the Bridge DSL.
3
+ *
4
+ * Tokenizes .bridge source text into a stream consumed by the CstParser.
5
+ * Comments and whitespace are automatically skipped (placed on hidden channels).
6
+ */
7
+ import { Lexer } from "chevrotain";
8
+ export declare const Newline: import("chevrotain").TokenType;
9
+ export declare const WS: import("chevrotain").TokenType;
10
+ export declare const Comment: import("chevrotain").TokenType;
11
+ export declare const Identifier: import("chevrotain").TokenType;
12
+ export declare const VersionKw: import("chevrotain").TokenType;
13
+ export declare const ToolKw: import("chevrotain").TokenType;
14
+ export declare const BridgeKw: import("chevrotain").TokenType;
15
+ export declare const DefineKw: import("chevrotain").TokenType;
16
+ export declare const ConstKw: import("chevrotain").TokenType;
17
+ export declare const WithKw: import("chevrotain").TokenType;
18
+ export declare const AsKw: import("chevrotain").TokenType;
19
+ export declare const FromKw: import("chevrotain").TokenType;
20
+ export declare const InputKw: import("chevrotain").TokenType;
21
+ export declare const OutputKw: import("chevrotain").TokenType;
22
+ export declare const ContextKw: import("chevrotain").TokenType;
23
+ export declare const OnKw: import("chevrotain").TokenType;
24
+ export declare const ErrorKw: import("chevrotain").TokenType;
25
+ export declare const ForceArrow: import("chevrotain").TokenType;
26
+ export declare const Arrow: import("chevrotain").TokenType;
27
+ export declare const NullCoalesce: import("chevrotain").TokenType;
28
+ export declare const ErrorCoalesce: import("chevrotain").TokenType;
29
+ export declare const LCurly: import("chevrotain").TokenType;
30
+ export declare const RCurly: import("chevrotain").TokenType;
31
+ export declare const LSquare: import("chevrotain").TokenType;
32
+ export declare const RSquare: import("chevrotain").TokenType;
33
+ export declare const Equals: import("chevrotain").TokenType;
34
+ export declare const Dot: import("chevrotain").TokenType;
35
+ export declare const Colon: import("chevrotain").TokenType;
36
+ export declare const Comma: import("chevrotain").TokenType;
37
+ export declare const StringLiteral: import("chevrotain").TokenType;
38
+ export declare const NumberLiteral: import("chevrotain").TokenType;
39
+ export declare const TrueLiteral: import("chevrotain").TokenType;
40
+ export declare const FalseLiteral: import("chevrotain").TokenType;
41
+ export declare const NullLiteral: import("chevrotain").TokenType;
42
+ export declare const PathToken: import("chevrotain").TokenType;
43
+ export declare const allTokens: import("chevrotain").TokenType[];
44
+ export declare const BridgeLexer: Lexer;
45
+ //# sourceMappingURL=lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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AK,gCAA+D,CAAC;AAIlF,eAAO,MAAM,aAAa,gCAGxB,CAAC;AAEH,eAAO,MAAM,aAAa,gCAGxB,CAAC;AAEH,eAAO,MAAM,WAAW,gCAAmF,CAAC;AAC5G,eAAO,MAAM,YAAY,gCAAkF,CAAC;AAC5G,eAAO,MAAM,WAAW,gCAAmF,CAAC;AAE5G,eAAO,MAAM,SAAS,gCAGpB,CAAC;AAIH,eAAO,MAAM,SAAS,kCAqCrB,CAAC;AAEF,eAAO,MAAM,WAAW,OAGtB,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Chevrotain Lexer for the Bridge DSL.
3
+ *
4
+ * Tokenizes .bridge source text into a stream consumed by the CstParser.
5
+ * Comments and whitespace are automatically skipped (placed on hidden channels).
6
+ */
7
+ import { createToken, Lexer } from "chevrotain";
8
+ // ── Whitespace & comments ──────────────────────────────────────────────────
9
+ export const Newline = createToken({
10
+ name: "Newline",
11
+ pattern: /\r?\n/,
12
+ group: Lexer.SKIPPED,
13
+ });
14
+ export const WS = createToken({
15
+ name: "WS",
16
+ pattern: /[ \t]+/,
17
+ group: Lexer.SKIPPED,
18
+ });
19
+ export const Comment = createToken({
20
+ name: "Comment",
21
+ pattern: /#[^\r\n]*/,
22
+ group: Lexer.SKIPPED,
23
+ });
24
+ // ── Identifiers (defined first — keywords reference via longer_alt) ────────
25
+ export const Identifier = createToken({
26
+ name: "Identifier",
27
+ pattern: /[a-zA-Z_][\w-]*/,
28
+ });
29
+ // ── Keywords ───────────────────────────────────────────────────────────────
30
+ export const VersionKw = createToken({ name: "VersionKw", pattern: /version/i, longer_alt: Identifier });
31
+ export const ToolKw = createToken({ name: "ToolKw", pattern: /tool/i, longer_alt: Identifier });
32
+ export const BridgeKw = createToken({ name: "BridgeKw", pattern: /bridge/i, longer_alt: Identifier });
33
+ export const DefineKw = createToken({ name: "DefineKw", pattern: /define/i, longer_alt: Identifier });
34
+ export const ConstKw = createToken({ name: "ConstKw", pattern: /const/i, longer_alt: Identifier });
35
+ export const WithKw = createToken({ name: "WithKw", pattern: /with/i, longer_alt: Identifier });
36
+ export const AsKw = createToken({ name: "AsKw", pattern: /as/i, longer_alt: Identifier });
37
+ export const FromKw = createToken({ name: "FromKw", pattern: /from/i, longer_alt: Identifier });
38
+ export const InputKw = createToken({ name: "InputKw", pattern: /input/i, longer_alt: Identifier });
39
+ export const OutputKw = createToken({ name: "OutputKw", pattern: /output/i, longer_alt: Identifier });
40
+ export const ContextKw = createToken({ name: "ContextKw", pattern: /context/i, longer_alt: Identifier });
41
+ export const OnKw = createToken({ name: "OnKw", pattern: /on/i, longer_alt: Identifier });
42
+ export const ErrorKw = createToken({ name: "ErrorKw", pattern: /error/i, longer_alt: Identifier });
43
+ // ── Operators & punctuation ────────────────────────────────────────────────
44
+ export const ForceArrow = createToken({ name: "ForceArrow", pattern: /<-!/ });
45
+ export const Arrow = createToken({ name: "Arrow", pattern: /<-/ });
46
+ export const NullCoalesce = createToken({ name: "NullCoalesce", pattern: /\|\|/ });
47
+ export const ErrorCoalesce = createToken({ name: "ErrorCoalesce", pattern: /\?\?/ });
48
+ export const LCurly = createToken({ name: "LCurly", pattern: /\{/ });
49
+ export const RCurly = createToken({ name: "RCurly", pattern: /\}/ });
50
+ export const LSquare = createToken({ name: "LSquare", pattern: /\[/ });
51
+ export const RSquare = createToken({ name: "RSquare", pattern: /\]/ });
52
+ export const Equals = createToken({ name: "Equals", pattern: /=/ });
53
+ export const Dot = createToken({ name: "Dot", pattern: /\./ });
54
+ export const Colon = createToken({ name: "Colon", pattern: /:/ });
55
+ export const Comma = createToken({ name: "Comma", pattern: /,/ });
56
+ // ── Literals ───────────────────────────────────────────────────────────────
57
+ export const StringLiteral = createToken({
58
+ name: "StringLiteral",
59
+ pattern: /"(?:[^"\\]|\\.)*"/,
60
+ });
61
+ export const NumberLiteral = createToken({
62
+ name: "NumberLiteral",
63
+ pattern: /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/,
64
+ });
65
+ export const TrueLiteral = createToken({ name: "TrueLiteral", pattern: /true/, longer_alt: Identifier });
66
+ export const FalseLiteral = createToken({ name: "FalseLiteral", pattern: /false/, longer_alt: Identifier });
67
+ export const NullLiteral = createToken({ name: "NullLiteral", pattern: /null/, longer_alt: Identifier });
68
+ export const PathToken = createToken({
69
+ name: "PathToken",
70
+ pattern: /\/[\w./-]*/,
71
+ });
72
+ // ── Token ordering ─────────────────────────────────────────────────────────
73
+ export const allTokens = [
74
+ WS,
75
+ Comment,
76
+ Newline,
77
+ ForceArrow,
78
+ Arrow,
79
+ NullCoalesce,
80
+ ErrorCoalesce,
81
+ LCurly,
82
+ RCurly,
83
+ LSquare,
84
+ RSquare,
85
+ Equals,
86
+ Dot,
87
+ Colon,
88
+ Comma,
89
+ StringLiteral,
90
+ // Keywords before Identifier (longer_alt prevents prefix stealing)
91
+ VersionKw,
92
+ ToolKw,
93
+ BridgeKw,
94
+ DefineKw,
95
+ ConstKw,
96
+ WithKw,
97
+ AsKw,
98
+ FromKw,
99
+ InputKw,
100
+ OutputKw,
101
+ ContextKw,
102
+ OnKw,
103
+ ErrorKw,
104
+ TrueLiteral,
105
+ FalseLiteral,
106
+ NullLiteral,
107
+ PathToken,
108
+ NumberLiteral,
109
+ Identifier,
110
+ ];
111
+ export const BridgeLexer = new Lexer(allTokens, {
112
+ ensureOptimizations: true,
113
+ positionTracking: "full",
114
+ });
@@ -0,0 +1,3 @@
1
+ import type { Instruction } from "../types.js";
2
+ export declare function parseBridgeChevrotain(text: string): Instruction[];
3
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser/parser.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAKV,WAAW,EAMZ,MAAM,aAAa,CAAC;AA0oBrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAEjE"}