@abapify/acds 0.4.23 → 0.4.25
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/dist/index.mjs +59 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,52 @@ const Identifier = createToken({
|
|
|
51
51
|
name: "Identifier",
|
|
52
52
|
pattern: /[A-Za-z_][A-Za-z0-9_]*/
|
|
53
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* ABAP namespace-qualified identifier: `/NS/NAME` (optionally with further
|
|
56
|
+
* segments, e.g. `/NS/SUB/NAME`). Used for repository object names that live
|
|
57
|
+
* in a namespace. Must be tried before the generic `Slash` token so the
|
|
58
|
+
* whole qualified name is captured as one token.
|
|
59
|
+
*/
|
|
60
|
+
/** Token types that may end an expression atom; a following `/` is division. */
|
|
61
|
+
const EXPRESSION_ATOMS = /* @__PURE__ */ new Set([
|
|
62
|
+
"Identifier",
|
|
63
|
+
"NamespacedIdentifier",
|
|
64
|
+
"NumberLiteral",
|
|
65
|
+
"StringLiteral",
|
|
66
|
+
"EnumLiteral",
|
|
67
|
+
"RParen",
|
|
68
|
+
"RBracket",
|
|
69
|
+
"RBrace"
|
|
70
|
+
]);
|
|
71
|
+
function lastScannedToken(tokens) {
|
|
72
|
+
if (!tokens) return null;
|
|
73
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
74
|
+
const token = tokens[i];
|
|
75
|
+
if (token?.tokenType?.name !== "WhiteSpace") return token;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* ABAP namespace-qualified identifier: `/NS/NAME` (optionally with further
|
|
81
|
+
* segments, e.g. `/NS/SUB/NAME`). Used for repository object names that live
|
|
82
|
+
* in a namespace.
|
|
83
|
+
*
|
|
84
|
+
* The lexer cannot tell a namespace name apart from a division chain on
|
|
85
|
+
* syntax alone (`a/b/c` vs `/b/c`), so the match is context-sensitive: it
|
|
86
|
+
* only fires when the preceding token is NOT an expression atom, keeping
|
|
87
|
+
* compact division (`a/b/c`) tokenized as `Slash` operators. Numeric-leading
|
|
88
|
+
* namespace segments (e.g. `/1BCDWB/NAME`) are allowed.
|
|
89
|
+
*/
|
|
90
|
+
const NamespacedIdentifier = createToken({
|
|
91
|
+
name: "NamespacedIdentifier",
|
|
92
|
+
pattern: (text, offset, tokens) => {
|
|
93
|
+
if (text.charAt(offset) !== "/") return null;
|
|
94
|
+
const previous = lastScannedToken(tokens);
|
|
95
|
+
if (EXPRESSION_ATOMS.has(previous?.tokenType?.name)) return null;
|
|
96
|
+
const match = /^\/\w+(?:\/\w+)+/.exec(text.slice(offset));
|
|
97
|
+
return match ? [match[0]] : null;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
54
100
|
const Define = createToken({
|
|
55
101
|
name: "Define",
|
|
56
102
|
pattern: /define/i,
|
|
@@ -984,6 +1030,7 @@ const allTokens = [
|
|
|
984
1030
|
EnumLiteral,
|
|
985
1031
|
...keywordTokens,
|
|
986
1032
|
Identifier,
|
|
1033
|
+
NamespacedIdentifier,
|
|
987
1034
|
EqEq,
|
|
988
1035
|
NotEq,
|
|
989
1036
|
LtEq,
|
|
@@ -1045,7 +1092,11 @@ var CdsParser = class CdsParser extends CstParser {
|
|
|
1045
1092
|
* for the `cdsName` rule and for the bare-alias rule — the latter removes
|
|
1046
1093
|
* the FROM-region starters.
|
|
1047
1094
|
*/
|
|
1048
|
-
static NAME_TOKENS = [
|
|
1095
|
+
static NAME_TOKENS = [
|
|
1096
|
+
Identifier,
|
|
1097
|
+
NamespacedIdentifier,
|
|
1098
|
+
...keywordTokens
|
|
1099
|
+
];
|
|
1049
1100
|
static NAME_TOKEN_SET = new Set(CdsParser.NAME_TOKENS);
|
|
1050
1101
|
/** Comparison operators that end a parenthesized *operand*. */
|
|
1051
1102
|
static COMPARISON_TOKEN_SET = /* @__PURE__ */ new Set([
|
|
@@ -2740,6 +2791,13 @@ var CdsParser = class CdsParser extends CstParser {
|
|
|
2740
2791
|
* (bare operands are legal inside argument lists).
|
|
2741
2792
|
*/
|
|
2742
2793
|
callArgument = this.RULE("callArgument", () => {
|
|
2794
|
+
this.OPTION({
|
|
2795
|
+
GATE: () => this.isNameToken(this.LA(1)) && this.LA(2).tokenType === FatArrow,
|
|
2796
|
+
DEF: () => {
|
|
2797
|
+
this.SUBRULE(this.cdsName);
|
|
2798
|
+
this.CONSUME(FatArrow);
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2743
2801
|
this.OR([
|
|
2744
2802
|
{ ALT: () => this.CONSUME(Star) },
|
|
2745
2803
|
{
|