@gmb/bitmark-parser-generator 1.5.11 → 1.5.13

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 (67) hide show
  1. package/dist/browser/bitmark-parser-generator.min.js +1 -1
  2. package/dist/browser/bundle-report.html +2 -2
  3. package/dist/cjs/ast/Ast.js +13 -13
  4. package/dist/cjs/ast/Ast.js.map +1 -1
  5. package/dist/cjs/ast/Builder.js +1 -1
  6. package/dist/cjs/ast/Builder.js.map +1 -1
  7. package/dist/cjs/generated/build-info.js +1 -1
  8. package/dist/cjs/generated/parser/text/text-peggy-parser.js +1126 -651
  9. package/dist/cjs/generated/parser/text/text-peggy-parser.js.map +1 -1
  10. package/dist/cjs/generator/AstWalkerGenerator.js +83 -0
  11. package/dist/cjs/generator/AstWalkerGenerator.js.map +1 -0
  12. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +144 -180
  13. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  14. package/dist/cjs/generator/json/JsonGenerator.js +84 -114
  15. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  16. package/dist/cjs/generator/text/TextGenerator.js +91 -124
  17. package/dist/cjs/generator/text/TextGenerator.js.map +1 -1
  18. package/dist/cjs/model/enum/TextMarkType.js +13 -2
  19. package/dist/cjs/model/enum/TextMarkType.js.map +1 -1
  20. package/dist/cjs/model/enum/TextNodeType.js +1 -0
  21. package/dist/cjs/model/enum/TextNodeType.js.map +1 -1
  22. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +20 -10
  23. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  24. package/dist/cjs/parser/json/JsonParser.js +1 -1
  25. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  26. package/dist/esm/ast/Ast.js +13 -13
  27. package/dist/esm/ast/Ast.js.map +1 -1
  28. package/dist/esm/ast/Builder.js +1 -1
  29. package/dist/esm/ast/Builder.js.map +1 -1
  30. package/dist/esm/generated/build-info.js +1 -1
  31. package/dist/esm/generated/parser/text/text-peggy-parser.js +1126 -651
  32. package/dist/esm/generated/parser/text/text-peggy-parser.js.map +1 -1
  33. package/dist/esm/generator/AstWalkerGenerator.js +80 -0
  34. package/dist/esm/generator/AstWalkerGenerator.js.map +1 -0
  35. package/dist/esm/generator/bitmark/BitmarkGenerator.js +144 -180
  36. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  37. package/dist/esm/generator/json/JsonGenerator.js +84 -114
  38. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  39. package/dist/esm/generator/text/TextGenerator.js +91 -124
  40. package/dist/esm/generator/text/TextGenerator.js.map +1 -1
  41. package/dist/esm/model/enum/TextMarkType.js +13 -2
  42. package/dist/esm/model/enum/TextMarkType.js.map +1 -1
  43. package/dist/esm/model/enum/TextNodeType.js +1 -0
  44. package/dist/esm/model/enum/TextNodeType.js.map +1 -1
  45. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +20 -10
  46. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  47. package/dist/esm/parser/json/JsonParser.js +1 -1
  48. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  49. package/dist/types/ast/Ast.d.ts +4 -8
  50. package/dist/types/ast/Ast.d.ts.map +1 -1
  51. package/dist/types/generated/parser/text/text-peggy-parser.d.ts.map +1 -1
  52. package/dist/types/generator/AstWalkerGenerator.d.ts +32 -0
  53. package/dist/types/generator/AstWalkerGenerator.d.ts.map +1 -0
  54. package/dist/types/generator/Generator.d.ts +2 -2
  55. package/dist/types/generator/Generator.d.ts.map +1 -1
  56. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +121 -127
  57. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  58. package/dist/types/generator/json/JsonGenerator.d.ts +43 -48
  59. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  60. package/dist/types/generator/text/TextGenerator.d.ts +13 -17
  61. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  62. package/dist/types/model/enum/TextMarkType.d.ts +26 -4
  63. package/dist/types/model/enum/TextMarkType.d.ts.map +1 -1
  64. package/dist/types/model/enum/TextNodeType.d.ts +2 -0
  65. package/dist/types/model/enum/TextNodeType.d.ts.map +1 -1
  66. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
  67. package/package.json +13 -13
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AstWalkerGenerator = void 0;
4
+ const Ast_1 = require("../ast/Ast");
5
+ /**
6
+ * Generator that walks bitmark AST.
7
+ *
8
+ * The implementation should implement functions with the correct naming, and these will be called when
9
+ * walking the AST:
10
+ *
11
+ * enter_<nodeKey>() - called when entering a branch node
12
+ * between_<nodeKey>() - called when between child nodes
13
+ * exit_<nodeKey>() - called when exiting a branch node
14
+ * leaf_<nodeKey>() - called when entering a leaf node
15
+ */
16
+ class AstWalkerGenerator {
17
+ constructor() {
18
+ this.ast = new Ast_1.Ast();
19
+ // Debugging
20
+ this.debugGenerationInline = false;
21
+ this.printed = false;
22
+ }
23
+ enter(node, route, context) {
24
+ let res = void 0;
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ const gen = this;
27
+ const funcName = `enter_${node.key}`;
28
+ if (!this.printed) {
29
+ this.printed = true;
30
+ }
31
+ if (this.debugGenerationInline)
32
+ this.writeInlineDebug(node.key, { open: true });
33
+ if (typeof gen[funcName] === 'function') {
34
+ res = gen[funcName](node, route, context);
35
+ }
36
+ return res;
37
+ }
38
+ between(node, left, right, route, context) {
39
+ let res = void 0;
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ const gen = this;
42
+ const funcName = `between_${node.key}`;
43
+ if (this.debugGenerationInline)
44
+ this.writeInlineDebug(node.key, { single: true });
45
+ if (typeof gen[funcName] === 'function') {
46
+ res = gen[funcName](node, left, right, route, context);
47
+ }
48
+ return res;
49
+ }
50
+ exit(node, route, context) {
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ const gen = this;
53
+ const funcName = `exit_${node.key}`;
54
+ if (this.debugGenerationInline)
55
+ this.writeInlineDebug(node.key, { close: true });
56
+ if (typeof gen[funcName] === 'function') {
57
+ gen[funcName](node, route, context);
58
+ }
59
+ }
60
+ leaf(node, route, context) {
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ const gen = this;
63
+ const funcName = `leaf_${node.key}`;
64
+ if (this.debugGenerationInline)
65
+ this.writeInlineDebug(node.key, { open: true });
66
+ if (typeof gen[funcName] === 'function') {
67
+ gen[funcName](node, route, context);
68
+ }
69
+ if (this.debugGenerationInline)
70
+ this.writeInlineDebug(node.key, { close: true });
71
+ }
72
+ //
73
+ // HELPER FUNCTIONS
74
+ //
75
+ getParentNode(route, nodesBack = 1) {
76
+ if (route.length > nodesBack + 1) {
77
+ return route[route.length - nodesBack - 1];
78
+ }
79
+ return undefined;
80
+ }
81
+ }
82
+ exports.AstWalkerGenerator = AstWalkerGenerator;
83
+ //# sourceMappingURL=AstWalkerGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AstWalkerGenerator.js","sourceRoot":"","sources":["../../../src/generator/AstWalkerGenerator.ts"],"names":[],"mappings":";;;AAAA,oCAA6D;AAI7D;;;;;;;;;;GAUG;AACH,MAAe,kBAAkB;IAAjC;QACY,QAAG,GAAG,IAAI,SAAG,EAAE,CAAC;QAE1B,YAAY;QACF,0BAAqB,GAAG,KAAK,CAAC;QAC9B,YAAO,GAAG,KAAK,CAAC;IAkF5B,CAAC;IA5EC,KAAK,CAAC,IAAc,EAAE,KAAiB,EAAE,OAAgB;QACvD,IAAI,GAAG,GAAmB,KAAK,CAAC,CAAC;QACjC,8DAA8D;QAC9D,MAAM,GAAG,GAAG,IAAW,CAAC;QACxB,MAAM,QAAQ,GAAG,SAA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