parseman 0.4.0 → 0.6.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.
Files changed (65) hide show
  1. package/README.md +48 -17
  2. package/dist/combinators/choice.d.ts.map +1 -1
  3. package/dist/combinators/completions.d.ts +1 -1
  4. package/dist/combinators/completions.d.ts.map +1 -1
  5. package/dist/combinators/grammar.d.ts.map +1 -1
  6. package/dist/combinators/keywords.d.ts +22 -0
  7. package/dist/combinators/keywords.d.ts.map +1 -1
  8. package/dist/combinators/literal.d.ts.map +1 -1
  9. package/dist/combinators/map.d.ts +8 -2
  10. package/dist/combinators/map.d.ts.map +1 -1
  11. package/dist/combinators/node.d.ts +10 -11
  12. package/dist/combinators/node.d.ts.map +1 -1
  13. package/dist/combinators/not.d.ts +3 -3
  14. package/dist/combinators/not.d.ts.map +1 -1
  15. package/dist/combinators/recover.d.ts +2 -2
  16. package/dist/combinators/recover.d.ts.map +1 -1
  17. package/dist/combinators/regex.d.ts.map +1 -1
  18. package/dist/combinators/repeat.d.ts +4 -4
  19. package/dist/combinators/repeat.d.ts.map +1 -1
  20. package/dist/combinators/scanTo.d.ts.map +1 -1
  21. package/dist/combinators/sequence.d.ts.map +1 -1
  22. package/dist/combinators/trivia-skip.d.ts +16 -10
  23. package/dist/combinators/trivia-skip.d.ts.map +1 -1
  24. package/dist/combinators/withCtx.d.ts +2 -2
  25. package/dist/combinators/withCtx.d.ts.map +1 -1
  26. package/dist/compiler/codegen.d.ts +4 -2
  27. package/dist/compiler/codegen.d.ts.map +1 -1
  28. package/dist/compiler/inline-build.d.ts +11 -0
  29. package/dist/compiler/inline-build.d.ts.map +1 -0
  30. package/dist/compiler/inline-callback.d.ts +12 -0
  31. package/dist/compiler/inline-callback.d.ts.map +1 -0
  32. package/dist/compiler/trivia-fast-path.d.ts +24 -0
  33. package/dist/compiler/trivia-fast-path.d.ts.map +1 -0
  34. package/dist/cst/capture-buffer.d.ts +46 -0
  35. package/dist/cst/capture-buffer.d.ts.map +1 -0
  36. package/dist/cst/trivia-entries.d.ts +20 -0
  37. package/dist/cst/trivia-entries.d.ts.map +1 -0
  38. package/dist/cst/trivia-index.d.ts +11 -11
  39. package/dist/cst/trivia-index.d.ts.map +1 -1
  40. package/dist/cst/trivia-kinds.d.ts +47 -0
  41. package/dist/cst/trivia-kinds.d.ts.map +1 -0
  42. package/dist/cst/types.d.ts +9 -13
  43. package/dist/cst/types.d.ts.map +1 -1
  44. package/dist/functional/doc.d.ts +2 -20
  45. package/dist/functional/doc.d.ts.map +1 -1
  46. package/dist/index.cjs +1238 -662
  47. package/dist/index.cjs.map +4 -4
  48. package/dist/index.d.ts +4 -5
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1256 -6241
  51. package/dist/index.js.map +4 -4
  52. package/dist/plugin/evaluator.d.ts +7 -0
  53. package/dist/plugin/evaluator.d.ts.map +1 -1
  54. package/dist/plugin/index.cjs +1249 -369
  55. package/dist/plugin/index.cjs.map +4 -4
  56. package/dist/plugin/index.d.ts.map +1 -1
  57. package/dist/plugin/index.js +1249 -369
  58. package/dist/plugin/index.js.map +4 -4
  59. package/dist/types.d.ts +32 -9
  60. package/dist/types.d.ts.map +1 -1
  61. package/package.json +8 -3
  62. package/dist/cst/grammar.d.ts +0 -115
  63. package/dist/cst/grammar.d.ts.map +0 -1
  64. package/dist/cst/incremental.d.ts +0 -40
  65. package/dist/cst/incremental.d.ts.map +0 -1
@@ -5,13 +5,14 @@ export type TriviaToken = {
5
5
  readonly span: Span;
6
6
  };
7
7
  /**
8
- * Before/after offset index of captured trivia. Built from a tree's rawChildren
9
- * (trivia is only present there when the grammar enables `_captureTrivia`).
8
+ * Before/after offset index of captured trivia. Built from a tree whose nodes
9
+ * carry a `triviaLog` property (the flat `[start, end, insertIdx, ...]` array
10
+ * produced by parseman when `parser({ captureTrivia: true })` wraps a `node()` grammar).
10
11
  *
11
12
  * index.before.get(node.span.start) // trivia immediately before a node
12
13
  * index.after.get(node.span.end) // trivia immediately after a node
13
14
  *
14
- * A given trivia run is registered under BOTH the following item's start
15
+ * A given trivia entry is registered under BOTH the following item's start
15
16
  * (`before`) and the preceding item's end (`after`), so either lookup finds it.
16
17
  */
17
18
  export type TriviaIndex = {
@@ -22,12 +23,10 @@ export type TriviaIndex = {
22
23
  * Options for trailing/leading trivia at the document boundary. A repeating root
23
24
  * (e.g. `many()`) rolls back the trivia after its last item — it's "trailing" and
24
25
  * belongs to the enclosing context, which at the document root is the document
25
- * itself. Pass `{ input, trivia }` to re-scan and register that boundary trivia,
26
+ * itself. Pass `{ trivia }` to re-scan and register that boundary trivia,
26
27
  * so a round-trippable trivia map isn't missing the run before EOF.
27
28
  */
28
29
  export type TriviaIndexOptions = {
29
- /** The full source string. */
30
- input: string;
31
30
  /**
32
31
  * A regex matching ONE trivia token (a whitespace run or a comment). Applied
33
32
  * repeatedly to tokenize the boundary trivia. Each match becomes one token, so
@@ -37,14 +36,15 @@ export type TriviaIndexOptions = {
37
36
  trivia: RegExp;
38
37
  };
39
38
  /**
40
- * Walk a CST/AST node tree (anything exposing `children` whose items carry
41
- * `_tag`/`span`, with trivia items tagged `'trivia'`) and build a before/after
42
- * trivia index. Generic over the node type — formatters, LSPs, and codemods all
43
- * need this, and Parseman already owns trivia capture.
39
+ * Walk a tree whose nodes carry `triviaLog` (from `node()` + `captureTrivia`)
40
+ * and build a before/after trivia index. Each node must have
41
+ * `triviaLog: readonly number[]` (flat `[start, end, insertIdx, …]` —
42
+ * three numbers per entry) and `rawChildren` (structural items with `.span`).
43
+ * `input` is the source string used to materialize trivia values.
44
44
  *
45
45
  * With `opts`, also captures leading trivia (before the root's content) and
46
46
  * trailing trivia (after it, up to EOF) — the document boundaries a repeating
47
47
  * root rolls back.
48
48
  */
49
- export declare function buildTriviaIndex(root: unknown, opts?: TriviaIndexOptions): TriviaIndex;
49
+ export declare function buildTriviaIndex(root: unknown, input?: string, opts?: TriviaIndexOptions): TriviaIndex;
50
50
  //# sourceMappingURL=trivia-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trivia-index.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAEzE;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;IAC3C,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;CAC3C,CAAA;AAiBD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAqEtF"}
1
+ {"version":3,"file":"trivia-index.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAEzE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;IAC3C,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;CAC3C,CAAA;AAiBD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,SAAK,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAkElG"}
@@ -0,0 +1,47 @@
1
+ import type { Combinator, ParseContext } from '../types.ts';
2
+ export type TriviaChunk = {
3
+ start: number;
4
+ end: number;
5
+ kindIndex: number;
6
+ };
7
+ export type LabeledTriviaSpec = {
8
+ readonly labels: readonly string[];
9
+ readonly arms: ReadonlyArray<{
10
+ label: string;
11
+ kindIndex: number;
12
+ parser: Combinator<unknown>;
13
+ }>;
14
+ readonly minRepeats: number;
15
+ };
16
+ /** Strip `label()` wrapper; returns inner parser for matching. */
17
+ export declare function peelLabel(p: Combinator<unknown>): {
18
+ label: string;
19
+ parser: Combinator<unknown>;
20
+ } | null;
21
+ /**
22
+ * When every trivia arm is `label(name, parser)` inside `oneOrMore(choice(…))`
23
+ * (or a single labeled arm), return the label table and matchers.
24
+ */
25
+ export declare function analyzeLabeledTrivia(trivia: Combinator<unknown>): LabeledTriviaSpec | null;
26
+ /** Label table on a `trivia()` combinator, if all arms are labeled. */
27
+ export declare function triviaKindLabels(trivia: Combinator<unknown> | undefined): readonly string[] | undefined;
28
+ /**
29
+ * Scan maximal labeled trivia chunks (PEG `oneOrMore(choice(…))` semantics).
30
+ * Each successful arm match becomes one entry with that arm's kind index.
31
+ */
32
+ export declare function scanLabeledTriviaChunks(input: string, cur: number, spec: LabeledTriviaSpec): {
33
+ end: number;
34
+ chunks: TriviaChunk[];
35
+ };
36
+ /** Hand-rolled ws / block-comment scan with per-chunk kind indices (interpreter). */
37
+ export declare function scanFastWsCommentsChunks(input: string, cur: number, wsKind: number, commentKind: number): {
38
+ end: number;
39
+ chunks: TriviaChunk[];
40
+ };
41
+ /** Fast scan when trivia is labeled ws + block-comment (CSS `rw`). */
42
+ export declare function tryFastLabeledScan(input: string, cur: number, trivia: Combinator<unknown>): {
43
+ end: number;
44
+ chunks: TriviaChunk[];
45
+ } | null;
46
+ export declare function recordTriviaChunks(ctx: ParseContext, chunks: readonly TriviaChunk[]): void;
47
+ //# sourceMappingURL=trivia-kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trivia-kinds.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-kinds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI3D,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC,CAAA;IAC/F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CAAA;AAQD,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAGvG;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,iBAAiB,GAAG,IAAI,CA2B1F;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAKvG;AAYD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,GACtB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,CAsBxC;AAED,qFAAqF;AACrF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,CA6BxC;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAC1B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,GAAG,IAAI,CAiB/C;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,IAAI,CAQ1F"}
@@ -1,13 +1,12 @@
1
1
  import type { Span } from '../types.ts';
2
2
  /**
3
- * Minimal interface a node must satisfy for IncrementalParser to navigate and
4
- * re-parse the tree. Satisfying this is all that's required for a custom AST
5
- * produced by overriding GrammarParser.buildNode().
3
+ * Minimal interface a node must satisfy for incremental re-parse to navigate and
4
+ * re-parse the tree. Any object with `_tag: 'node'`, `type`, `span`, `state`,
5
+ * and `children` works — whether from `node()` build callbacks or custom ASTs.
6
6
  *
7
- * `children` only needs to be iterable with items that have `_tag` so the
8
- * traversal code can distinguish sub-nodes from leaves. For incremental
9
- * replacement, `rebuild()` on the Parser calls `buildNode()` rather than
10
- * object-spreading, so overriding `buildNode` handles class instances correctly.
7
+ * `children` only needs items with `_tag` so traversal can distinguish sub-nodes
8
+ * from leaves. `makeFunctionalDoc` uses an optional `rebuild` callback (or a
9
+ * shallow spread) when grafting a re-parsed subtree.
11
10
  */
12
11
  export type NodeLike = {
13
12
  readonly _tag: 'node';
@@ -19,9 +18,8 @@ export type NodeLike = {
19
18
  }>;
20
19
  };
21
20
  /**
22
- * A named CST node produced by a capital-letter rule method in GrammarParser.
23
- * Children are in parse order: CSTNode children from named sub-parser interspersed
24
- * with CSTLeaf terminals from literal() / regex() calls inside lowercase helpers.
21
+ * A named CST node from a `node()` rule (or equivalent build callback).
22
+ * Children are in parse order: sub-nodes interspersed with CSTLeaf terminals.
25
23
  */
26
24
  export type CSTNode = {
27
25
  readonly _tag: 'node';
@@ -37,9 +35,7 @@ export type CSTNode = {
37
35
  readonly state: unknown;
38
36
  };
39
37
  /**
40
- * A terminal token — the result of a literal() or regex() match inside a CST rule.
41
- * Lowercase helpers are transparent: their terminals surface as leaves of the
42
- * nearest enclosing capital-letter rule.
38
+ * A terminal token — the result of a literal() or regex() match inside a node rule.
43
39
  */
44
40
  export type CSTLeaf = {
45
41
  readonly _tag: 'leaf';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cst/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;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,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEnD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CACpB,CAAA;AAED,wFAAwF;AACxF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA"}
@@ -1,22 +1,5 @@
1
1
  /**
2
- * Functional incremental document — a class-free counterpart to ParseDoc.
3
- *
4
- * The class-based Parser bakes a rule registry (method name → combinator) and
5
- * a `rebuild()` hook into the grammar object. A *functional* grammar produces
6
- * the same two ingredients without a class:
7
- *
8
- * - the registry is the object returned by `rules()` (rule name → parser fn),
9
- * which the macro compiles to a map of independently-callable functions;
10
- * - `rebuild` is supplied by the caller (or defaults to a shallow spread),
11
- * since functional nodes are whatever the `transform()` callbacks produced.
12
- *
13
- * Given those, incremental re-parsing is identical in spirit to the class path:
14
- * locate the smallest node containing the edit, re-parse that single rule from
15
- * its start offset, and graft the result back into the tree if its end lands
16
- * where the edit's delta predicts.
17
- *
18
- * This module has no dependency on the `Parser` class — it is what lets the
19
- * class be removed once grammars move to the functional shape.
2
+ * Functional incremental document — incremental re-parse over a rules() registry.
20
3
  */
21
4
  import type { ParseContext, ParseFail, ParseResult } from '../types.ts';
22
5
  import type { NodeLike, CSTLeaf, CSTError } from '../cst/types.ts';
@@ -40,8 +23,7 @@ export interface FunctionalDoc<N extends NodeLike> {
40
23
  readonly input: string;
41
24
  /**
42
25
  * Incrementally re-parse after a text change. `from`/`to` are byte offsets in
43
- * the OLD input; `replacement` fills that range. Mirrors editor change events
44
- * (see ParseDoc.edit for the mapping).
26
+ * the OLD input; `replacement` fills that range (editor change-event shape).
45
27
  */
46
28
  edit(from: number, to: number, replacement: string): FunctionalDoc<N>;
47
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/functional/doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAElE,qFAAqF;AACrF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAA;AAEzF,gFAAgF;AAChF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,QAAQ,IAAI;IACrD,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;CAC1E,CAAA;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,QAAQ;IAC/C,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;CACt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