@abaplint/transpiler 2.3.74 → 2.3.76

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.
@@ -1,4 +1,5 @@
1
1
  import * as abaplint from "@abaplint/core";
2
+ export declare const defaultKeywords: string[];
2
3
  /** Replaces javascript keywords in ABAP source code, in-memory only */
3
4
  export declare class Keywords {
4
5
  private readonly keywords;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Keywords = void 0;
3
+ exports.Keywords = exports.defaultKeywords = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  // https://www.w3schools.com/js/js_reserved.asp
6
- const defaultKeywords = [
6
+ exports.defaultKeywords = [
7
7
  "abstract", "arguments", "await",
8
8
  "break", "byte", "catch",
9
9
  "char", "class", "const", "continue",
@@ -31,7 +31,7 @@ class Keywords {
31
31
  this.keywords = keywords;
32
32
  }
33
33
  else {
34
- this.keywords = defaultKeywords;
34
+ this.keywords = exports.defaultKeywords;
35
35
  }
36
36
  }
37
37
  handle(reg) {
@@ -116,6 +116,7 @@ export * from "./start_of_selection";
116
116
  export * from "./submit";
117
117
  export * from "./subtract";
118
118
  export * from "./syntax_check";
119
+ export * from "./tables";
119
120
  export * from "./translate";
120
121
  export * from "./truncate_dataset";
121
122
  export * from "./try";
@@ -132,6 +132,7 @@ __exportStar(require("./start_of_selection"), exports);
132
132
  __exportStar(require("./submit"), exports);
133
133
  __exportStar(require("./subtract"), exports);
134
134
  __exportStar(require("./syntax_check"), exports);
135
+ __exportStar(require("./tables"), exports);
135
136
  __exportStar(require("./translate"), exports);
136
137
  __exportStar(require("./truncate_dataset"), exports);
137
138
  __exportStar(require("./try"), exports);
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IStatementTranspiler } from "./_statement_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class TablesTranspiler implements IStatementTranspiler {
6
+ transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TablesTranspiler = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const transpile_types_1 = require("../transpile_types");
6
+ const chunk_1 = require("../chunk");
7
+ class TablesTranspiler {
8
+ transpile(node, traversal) {
9
+ var _a;
10
+ const token = (_a = node.findFirstExpression(abaplint.Expressions.Field)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
11
+ if (token === undefined) {
12
+ throw new Error("TablesTranspiler, token not found");
13
+ }
14
+ const scope = traversal.findCurrentScopeByToken(token);
15
+ if (scope === undefined) {
16
+ throw new Error("TablesTranspiler, scope not found");
17
+ }
18
+ const found = scope.findVariable(token.getStr());
19
+ if (found === undefined) {
20
+ throw new Error("TablesTranspiler, var not found, \"" + token.getStr() + "\"");
21
+ }
22
+ const ret = new chunk_1.Chunk()
23
+ .appendString("let ")
24
+ .append(found.getName().toLowerCase(), token, traversal)
25
+ .appendString(" = " + new transpile_types_1.TranspileTypes().toType(found.getType()))
26
+ .append(";", node.getLastToken(), traversal);
27
+ return ret;
28
+ }
29
+ }
30
+ exports.TablesTranspiler = TablesTranspiler;
31
+ //# sourceMappingURL=tables.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Validation = exports.config = void 0;
4
4
  const core_1 = require("@abaplint/core");
5
+ const keywords_1 = require("./keywords");
5
6
  exports.config = {
6
7
  "global": {
7
8
  "files": "/**/*.*",
@@ -67,45 +68,40 @@ exports.config = {
67
68
  "setExtended": true,
68
69
  },
69
70
  "forbidden_identifier": {
70
- "check": [
71
- "^abstract$", "^arguments$", "^await$",
72
- "^break$", "^byte$", "^catch$",
73
- "^char$", "^class$", "^const$", "^continue$",
74
- "^debugger$", "^default$", "^do$",
75
- "^double$", "^else$", "^enum$", "^eval$",
76
- "^export$", "^extends$", "^false$", "^final$",
77
- "^finally$", "^for$", "^function$",
78
- "^goto$", "^if$", "^implements$", "^import$",
79
- "^in$", "^instanceof$", "^interface$",
80
- "^let$", "^long$", "^native$", "^new$",
81
- "^null$", "^package$", "^private$",
82
- // "^protected$",
83
- "^public$", "^return$", "^short$", "^static$",
84
- "^switch$", "^synchronized$", "^this$",
85
- "^throw$", "^throws$", "^transient$", "^true$",
86
- "^try$", "^typeof$", "^var$", "^void$",
87
- "^volatile$", "^while$", "^yield$",
88
- "^unique\\d+$"
89
- ],
71
+ "check": [],
90
72
  },
91
73
  },
92
74
  };
93
75
  // todo, make sure nothing is overloaded, eg "lines()", there is a rule for this in abaplint now
76
+ // hmm this ^ is okay? since lines will be prefixed with "abap.builtin"?
94
77
  class Validation {
95
78
  constructor(options) {
96
79
  this.options = options;
97
80
  }
98
81
  run(reg) {
99
- var _a, _b;
82
+ var _a, _b, _c;
100
83
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.ignoreSyntaxCheck) === true) {
101
84
  exports.config.rules["check_syntax"] = false;
102
85
  }
103
86
  else {
104
87
  exports.config.rules["check_syntax"] = true;
105
88
  }
106
- if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.unknownTypes) === "runtimeError") {
107
- exports.config.syntax.errorNamespace = "VOID_EVERYTHING"; // this is not a constant, just a regex that happens to not match anything
108
- // config.rules["unknown_types"] = false;
89
+ exports.config.rules["forbidden_identifier"]["check"] = ["^unique\\d+$"];
90
+ if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.keywords) === undefined) {
91
+ for (const d of keywords_1.defaultKeywords) {
92
+ const add = "^" + d + "$";
93
+ exports.config.rules["forbidden_identifier"]["check"].push(add);
94
+ }
95
+ }
96
+ else {
97
+ for (const d of this.options.keywords) {
98
+ const add = "^" + d + "$";
99
+ exports.config.rules["forbidden_identifier"]["check"].push(add);
100
+ }
101
+ }
102
+ if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.unknownTypes) === "runtimeError") {
103
+ // this is not a constant, just a regex that happens to not match anything
104
+ exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
109
105
  }
110
106
  const conf = new core_1.Config(JSON.stringify(exports.config));
111
107
  reg.setConfig(conf);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.74",
3
+ "version": "2.3.76",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",