@sdkgen/parser 0.0.0-dev.20231002144112 → 0.0.0-dev.20231002175619
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/ast.js +298 -0
- package/dist/compatibility/index.js +206 -0
- package/dist/helpers.js +20 -0
- package/dist/index.js +9 -0
- package/dist/json.js +225 -0
- package/dist/lexer.js +283 -0
- package/dist/parser.js +419 -0
- package/dist/restparser.js +59 -0
- package/dist/semantic/01_check_multiple_declaration.js +19 -0
- package/dist/semantic/02_give_struct_and_enum_names.js +58 -0
- package/dist/semantic/03_match_type_definitions.js +15 -0
- package/dist/semantic/04_check_dont_return_secret.js +39 -0
- package/dist/semantic/05_expand_spreads.js +57 -0
- package/dist/semantic/06_check_empty_struct_or_enum.js +18 -0
- package/dist/semantic/07_validate_recursive_types.js +46 -0
- package/dist/semantic/08_collect_struct_and_enum_types.js +22 -0
- package/dist/semantic/09_validate_annotations.js +122 -0
- package/dist/semantic/10_check_duplicate_members_on_enum.js +13 -0
- package/dist/semantic/analyser.js +27 -0
- package/dist/semantic/transformer.js +46 -0
- package/dist/semantic/visitor.js +61 -0
- package/dist/token.js +93 -0
- package/dist/utils.js +25 -0
- package/package.json +10 -3
- package/.eslintrc.json +0 -3
- package/.prettierrc +0 -12
- package/dist/spec/lexer.spec.d.ts +0 -1
- package/dist/spec/lexer.spec.js +0 -152
- package/dist/spec/parser.spec.d.ts +0 -1
- package/dist/spec/parser.spec.js +0 -967
- package/dist/src/ast.js +0 -355
- package/dist/src/compatibility/index.js +0 -211
- package/dist/src/helpers.js +0 -23
- package/dist/src/index.js +0 -29
- package/dist/src/json.js +0 -234
- package/dist/src/lexer.js +0 -287
- package/dist/src/parser.js +0 -423
- package/dist/src/restparser.js +0 -65
- package/dist/src/semantic/01_check_multiple_declaration.js +0 -22
- package/dist/src/semantic/02_give_struct_and_enum_names.js +0 -61
- package/dist/src/semantic/03_match_type_definitions.js +0 -18
- package/dist/src/semantic/04_check_dont_return_secret.js +0 -42
- package/dist/src/semantic/05_expand_spreads.js +0 -60
- package/dist/src/semantic/06_check_empty_struct_or_enum.js +0 -21
- package/dist/src/semantic/07_validate_recursive_types.js +0 -49
- package/dist/src/semantic/08_collect_struct_and_enum_types.js +0 -25
- package/dist/src/semantic/09_validate_annotations.js +0 -125
- package/dist/src/semantic/10_check_duplicate_members_on_enum.js +0 -16
- package/dist/src/semantic/analyser.js +0 -30
- package/dist/src/semantic/transformer.js +0 -50
- package/dist/src/semantic/visitor.js +0 -65
- package/dist/src/token.js +0 -119
- package/dist/src/utils.js +0 -27
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/ast.ts +0 -273
- package/src/compatibility/index.ts +0 -273
- package/src/helpers.ts +0 -28
- package/src/index.ts +0 -8
- package/src/json.ts +0 -350
- package/src/lexer.ts +0 -343
- package/src/parser.ts +0 -604
- package/src/restparser.ts +0 -81
- package/src/semantic/01_check_multiple_declaration.ts +0 -21
- package/src/semantic/02_give_struct_and_enum_names.ts +0 -57
- package/src/semantic/03_match_type_definitions.ts +0 -19
- package/src/semantic/04_check_dont_return_secret.ts +0 -40
- package/src/semantic/05_expand_spreads.ts +0 -67
- package/src/semantic/06_check_empty_struct_or_enum.ts +0 -21
- package/src/semantic/07_validate_recursive_types.ts +0 -47
- package/src/semantic/08_collect_struct_and_enum_types.ts +0 -23
- package/src/semantic/09_validate_annotations.ts +0 -158
- package/src/semantic/10_check_duplicate_members_on_enum.ts +0 -15
- package/src/semantic/analyser.ts +0 -29
- package/src/semantic/transformer.ts +0 -41
- package/src/semantic/visitor.ts +0 -60
- package/src/token.ts +0 -92
- package/src/utils.ts +0 -63
- /package/dist/{src/ast.d.ts → ast.d.ts} +0 -0
- /package/dist/{src/compatibility → compatibility}/index.d.ts +0 -0
- /package/dist/{src/helpers.d.ts → helpers.d.ts} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/json.d.ts → json.d.ts} +0 -0
- /package/dist/{src/lexer.d.ts → lexer.d.ts} +0 -0
- /package/dist/{src/parser.d.ts → parser.d.ts} +0 -0
- /package/dist/{src/restparser.d.ts → restparser.d.ts} +0 -0
- /package/dist/{src/semantic → semantic}/01_check_multiple_declaration.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/02_give_struct_and_enum_names.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/03_match_type_definitions.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/04_check_dont_return_secret.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/05_expand_spreads.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/06_check_empty_struct_or_enum.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/07_validate_recursive_types.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/08_collect_struct_and_enum_types.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/09_validate_annotations.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/10_check_duplicate_members_on_enum.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/analyser.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/transformer.d.ts +0 -0
- /package/dist/{src/semantic → semantic}/visitor.d.ts +0 -0
- /package/dist/{src/token.d.ts → token.d.ts} +0 -0
- /package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdkgen/parser",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20231002175619",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"directories": {
|
|
8
|
+
"lib": "dist"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
6
13
|
"scripts": {
|
|
7
14
|
"test": "jest --passWithNoTests",
|
|
8
15
|
"eslint:fix": "eslint --fix '{src,spec}/**/*.ts'",
|
|
@@ -47,5 +54,5 @@
|
|
|
47
54
|
"/node_modules/"
|
|
48
55
|
]
|
|
49
56
|
},
|
|
50
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "611061fbde3388caebebe076bf41ad78518cbbb0"
|
|
51
58
|
}
|
package/.eslintrc.json
DELETED
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/spec/lexer.spec.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const lexer_1 = require("../src/lexer");
|
|
4
|
-
const token_1 = require("../src/token");
|
|
5
|
-
function itLexes(source, expectedTokens) {
|
|
6
|
-
test(`lexes ${JSON.stringify(source)} as [${expectedTokens.join(", ")}]`, () => {
|
|
7
|
-
const lexer = new lexer_1.Lexer(source);
|
|
8
|
-
let tokens = [];
|
|
9
|
-
for (;;) {
|
|
10
|
-
const token = lexer.nextToken();
|
|
11
|
-
if (!token) {
|
|
12
|
-
break;
|
|
13
|
-
}
|
|
14
|
-
tokens.push(token);
|
|
15
|
-
}
|
|
16
|
-
tokens = tokens.map((token, i) => (expectedTokens[i] instanceof token_1.IdentifierToken ? token.maybeAsIdentifier() : token));
|
|
17
|
-
expect(tokens.join(", ")).toEqual(expectedTokens.join(", "));
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function itDoesntLex(source, message) {
|
|
21
|
-
test(`doesn't lex ${JSON.stringify(source)}`, () => {
|
|
22
|
-
const lexer = new lexer_1.Lexer(source);
|
|
23
|
-
expect(() => {
|
|
24
|
-
while (lexer.nextToken()) {
|
|
25
|
-
//
|
|
26
|
-
}
|
|
27
|
-
}).toThrowError(message);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
describe(lexer_1.Lexer, () => {
|
|
31
|
-
itLexes("", []);
|
|
32
|
-
itLexes("type", [new token_1.TypeKeywordToken()]);
|
|
33
|
-
itDoesntLex("23", 'Unexpected character "2" at -:1:1');
|
|
34
|
-
itDoesntLex("2a", 'Unexpected character "2" at -:1:1');
|
|
35
|
-
itLexes("type2", [new token_1.IdentifierToken("type2")]);
|
|
36
|
-
itLexes("aaa", [new token_1.IdentifierToken("aaa")]);
|
|
37
|
-
itLexes("...aaa", [new token_1.SpreadSymbolToken(), new token_1.IdentifierToken("aaa")]);
|
|
38
|
-
itLexes("a b c", [new token_1.IdentifierToken("a"), new token_1.IdentifierToken("b"), new token_1.IdentifierToken("c")]);
|
|
39
|
-
itLexes("aa_bb", [new token_1.IdentifierToken("aa_bb")]);
|
|
40
|
-
itLexes("type type", [new token_1.TypeKeywordToken(), new token_1.TypeKeywordToken()]);
|
|
41
|
-
itLexes("enum", [new token_1.EnumKeywordToken()]);
|
|
42
|
-
itLexes("error", [new token_1.ErrorKeywordToken()]);
|
|
43
|
-
itLexes("import", [new token_1.ImportKeywordToken()]);
|
|
44
|
-
itLexes("Get", [new token_1.IdentifierToken("Get")]);
|
|
45
|
-
itLexes("fn", [new token_1.FnKeywordToken()]);
|
|
46
|
-
itLexes("enuma", [new token_1.IdentifierToken("enuma")]);
|
|
47
|
-
itLexes("errorh", [new token_1.IdentifierToken("errorh")]);
|
|
48
|
-
for (const kw of ["enum", "type", "error", "import", "get", "function", "fn", "true", "false"]) {
|
|
49
|
-
itLexes(kw, [new token_1.IdentifierToken(kw)]);
|
|
50
|
-
}
|
|
51
|
-
for (const primitive of lexer_1.Lexer.PRIMITIVES) {
|
|
52
|
-
itLexes(primitive, [new token_1.PrimitiveTypeToken(primitive)]);
|
|
53
|
-
itLexes(primitive, [new token_1.IdentifierToken(primitive)]);
|
|
54
|
-
itLexes(`${primitive}a`, [new token_1.IdentifierToken(`${primitive}a`)]);
|
|
55
|
-
}
|
|
56
|
-
itLexes("err", [new token_1.IdentifierToken("err")]);
|
|
57
|
-
itLexes("{", [new token_1.CurlyOpenSymbolToken()]);
|
|
58
|
-
itLexes("{{", [new token_1.CurlyOpenSymbolToken(), new token_1.CurlyOpenSymbolToken()]);
|
|
59
|
-
itLexes("}{", [new token_1.CurlyCloseSymbolToken(), new token_1.CurlyOpenSymbolToken()]);
|
|
60
|
-
itLexes(" } { ", [new token_1.CurlyCloseSymbolToken(), new token_1.CurlyOpenSymbolToken()]);
|
|
61
|
-
itLexes("({!:?,=})", [
|
|
62
|
-
new token_1.ParensOpenSymbolToken(),
|
|
63
|
-
new token_1.CurlyOpenSymbolToken(),
|
|
64
|
-
new token_1.ExclamationMarkSymbolToken(),
|
|
65
|
-
new token_1.ColonSymbolToken(),
|
|
66
|
-
new token_1.OptionalSymbolToken(),
|
|
67
|
-
new token_1.CommaSymbolToken(),
|
|
68
|
-
new token_1.EqualSymbolToken(),
|
|
69
|
-
new token_1.CurlyCloseSymbolToken(),
|
|
70
|
-
new token_1.ParensCloseSymbolToken(),
|
|
71
|
-
]);
|
|
72
|
-
itLexes(" [][] ", [new token_1.ArraySymbolToken(), new token_1.ArraySymbolToken()]);
|
|
73
|
-
itLexes("nice[]", [new token_1.IdentifierToken("nice"), new token_1.ArraySymbolToken()]);
|
|
74
|
-
itLexes("nice\n[]", [new token_1.IdentifierToken("nice"), new token_1.ArraySymbolToken()]);
|
|
75
|
-
itDoesntLex("[", "Unexpected end of file");
|
|
76
|
-
itLexes("type Str string", [new token_1.TypeKeywordToken(), new token_1.IdentifierToken("Str"), new token_1.PrimitiveTypeToken("string")]);
|
|
77
|
-
itLexes('"ab"', [new token_1.StringLiteralToken("ab")]);
|
|
78
|
-
itLexes('""', [new token_1.StringLiteralToken("")]);
|
|
79
|
-
itLexes('"aa\\nbb"', [new token_1.StringLiteralToken("aa\nbb")]);
|
|
80
|
-
itLexes('"aa\\bb"', [new token_1.StringLiteralToken("aabb")]);
|
|
81
|
-
itLexes('"\'"', [new token_1.StringLiteralToken("'")]);
|
|
82
|
-
itLexes('"\\n\\t\\""', [new token_1.StringLiteralToken('\n\t"')]);
|
|
83
|
-
itLexes('"/* */"', [new token_1.StringLiteralToken("/* */")]);
|
|
84
|
-
itLexes("//hmmm", []);
|
|
85
|
-
itLexes("x//hmmm", [new token_1.IdentifierToken("x")]);
|
|
86
|
-
itLexes("a//hmmm\nb", [new token_1.IdentifierToken("a"), new token_1.IdentifierToken("b")]);
|
|
87
|
-
itLexes("a // hmmm \n b", [new token_1.IdentifierToken("a"), new token_1.IdentifierToken("b")]);
|
|
88
|
-
itLexes("// héýça\n z", [new token_1.IdentifierToken("z")]);
|
|
89
|
-
itDoesntLex("2", 'Unexpected character "2" at -:1:1');
|
|
90
|
-
itDoesntLex("\n2", 'Unexpected character "2" at -:2:1');
|
|
91
|
-
itDoesntLex("//\n2", 'Unexpected character "2" at -:2:1');
|
|
92
|
-
itDoesntLex("//\n 2", 'Unexpected character "2" at -:2:2');
|
|
93
|
-
itDoesntLex("//x\n2", 'Unexpected character "2" at -:2:1');
|
|
94
|
-
itDoesntLex("//x\n 2", 'Unexpected character "2" at -:2:2');
|
|
95
|
-
itDoesntLex("/*\n*/3", 'Unexpected character "3" at -:2:3');
|
|
96
|
-
itDoesntLex("/*\n\n\n\n*/ 2", 'Unexpected character "2" at -:5:4');
|
|
97
|
-
itDoesntLex("/*a*/\n2", 'Unexpected character "2" at -:2:1');
|
|
98
|
-
itDoesntLex("/*a*/\n 2", 'Unexpected character "2" at -:2:2');
|
|
99
|
-
itDoesntLex("/*\n", "Unexpected end of file");
|
|
100
|
-
itDoesntLex("/* *", "Unexpected end of file");
|
|
101
|
-
itDoesntLex("/* \tae\n\n", "Unexpected end of file");
|
|
102
|
-
itDoesntLex("/*", "Unexpected end of file");
|
|
103
|
-
itDoesntLex("/*", "Unexpected end of file");
|
|
104
|
-
itDoesntLex("/* dsvibwi", "Unexpected end of file");
|
|
105
|
-
itDoesntLex("/* cdibweic *", "Unexpected end of file");
|
|
106
|
-
itDoesntLex("/* cdibweic *a", "Unexpected end of file");
|
|
107
|
-
itDoesntLex("/* * /", "Unexpected end of file");
|
|
108
|
-
itDoesntLex("/* * /", "Unexpected end of file");
|
|
109
|
-
itDoesntLex("/* * /", "Unexpected end of file");
|
|
110
|
-
itDoesntLex("/*/", "Unexpected end of file");
|
|
111
|
-
itDoesntLex("/* /", "Unexpected end of file");
|
|
112
|
-
itDoesntLex("/* * /", "Unexpected end of file");
|
|
113
|
-
itDoesntLex("/* * * * /", "Unexpected end of file");
|
|
114
|
-
itDoesntLex("/* *a/", "Unexpected end of file");
|
|
115
|
-
itLexes("/*\n*/", []);
|
|
116
|
-
itLexes("/* * * * * */", []);
|
|
117
|
-
itLexes("/* * ***_ */", []);
|
|
118
|
-
itLexes("/**/", []);
|
|
119
|
-
itLexes("/***/", []);
|
|
120
|
-
itLexes("/****/", []);
|
|
121
|
-
itLexes("/*****/", []);
|
|
122
|
-
itLexes("/******/", []);
|
|
123
|
-
itLexes("/*******/", []);
|
|
124
|
-
itLexes("/********/", []);
|
|
125
|
-
itLexes("/****aas ********/", []);
|
|
126
|
-
itLexes("/*******a ********/", []);
|
|
127
|
-
itLexes("/**********/", []);
|
|
128
|
-
itLexes("/************/", []);
|
|
129
|
-
itLexes("/*************/", []);
|
|
130
|
-
itLexes("/**************/", []);
|
|
131
|
-
itLexes("/***************/", []);
|
|
132
|
-
itLexes("/*a */", []);
|
|
133
|
-
itLexes("/*a \n*/", []);
|
|
134
|
-
itLexes("/*a \n\n\n\n\n*/", []);
|
|
135
|
-
itLexes("/**a*/", []);
|
|
136
|
-
itLexes("/*a**/", []);
|
|
137
|
-
itLexes("/* */", []);
|
|
138
|
-
itLexes("/*a*/b/*c*/", [new token_1.IdentifierToken("b")]);
|
|
139
|
-
itLexes("/* đðđ\n */u", [new token_1.IdentifierToken("u")]);
|
|
140
|
-
itLexes("c/* a*/", [new token_1.IdentifierToken("c")]);
|
|
141
|
-
itLexes("/* bce */a", [new token_1.IdentifierToken("a")]);
|
|
142
|
-
itLexes("b/* baed */c", [new token_1.IdentifierToken("b"), new token_1.IdentifierToken("c")]);
|
|
143
|
-
itLexes("/* \n\nb */a", [new token_1.IdentifierToken("a")]);
|
|
144
|
-
itLexes("/* */a", [new token_1.IdentifierToken("a")]);
|
|
145
|
-
itLexes("@aa bb cc", [new token_1.AnnotationToken("aa bb cc")]);
|
|
146
|
-
itLexes(" @ ", [new token_1.AnnotationToken("")]);
|
|
147
|
-
itLexes("@", [new token_1.AnnotationToken("")]);
|
|
148
|
-
itLexes(" @ aa bb cc ", [new token_1.AnnotationToken("aa bb cc")]);
|
|
149
|
-
itLexes(" @ aa bb \n cc ", [new token_1.AnnotationToken("aa bb"), new token_1.IdentifierToken("cc")]);
|
|
150
|
-
itLexes(" @ aa bb \\ \n cc ", [new token_1.AnnotationToken("aa bb cc")]);
|
|
151
|
-
itLexes("@\\\n cc ", [new token_1.AnnotationToken("cc")]);
|
|
152
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|