allang-compiler-base 0.0.1

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 (47) hide show
  1. package/dist/base/log.d.ts +7 -0
  2. package/dist/base/log.d.ts.map +1 -0
  3. package/dist/base/log.js +2 -0
  4. package/dist/base/log.js.map +1 -0
  5. package/dist/base/model.d.ts +7 -0
  6. package/dist/base/model.d.ts.map +1 -0
  7. package/dist/base/model.js +8 -0
  8. package/dist/base/model.js.map +1 -0
  9. package/dist/core/parser/grammar.d.ts +19 -0
  10. package/dist/core/parser/grammar.d.ts.map +1 -0
  11. package/dist/core/parser/grammar.js +4 -0
  12. package/dist/core/parser/grammar.js.map +1 -0
  13. package/dist/core/pre/index.d.ts +13 -0
  14. package/dist/core/pre/index.d.ts.map +1 -0
  15. package/dist/core/pre/index.js +12 -0
  16. package/dist/core/pre/index.js.map +1 -0
  17. package/dist/core/pre/match.d.ts +12 -0
  18. package/dist/core/pre/match.d.ts.map +1 -0
  19. package/dist/core/pre/match.js +162 -0
  20. package/dist/core/pre/match.js.map +1 -0
  21. package/dist/core/pre/model.d.ts +25 -0
  22. package/dist/core/pre/model.d.ts.map +1 -0
  23. package/dist/core/pre/model.js +29 -0
  24. package/dist/core/pre/model.js.map +1 -0
  25. package/dist/core/pre/segment.d.ts +22 -0
  26. package/dist/core/pre/segment.d.ts.map +1 -0
  27. package/dist/core/pre/segment.js +136 -0
  28. package/dist/core/pre/segment.js.map +1 -0
  29. package/dist/core/test.d.ts +2 -0
  30. package/dist/core/test.d.ts.map +1 -0
  31. package/dist/core/test.js +11 -0
  32. package/dist/core/test.js.map +1 -0
  33. package/dist/index.d.ts +5 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +4 -0
  36. package/dist/index.js.map +1 -0
  37. package/index.js +13 -0
  38. package/index.ts +13 -0
  39. package/package.json +15 -0
  40. package/src/base/log.ts +6 -0
  41. package/src/core/parser/grammar.ts +20 -0
  42. package/src/core/pre/index.ts +11 -0
  43. package/src/core/pre/match.ts +153 -0
  44. package/src/core/pre/model.ts +30 -0
  45. package/src/core/pre/segment.ts +135 -0
  46. package/src/core/test.ts +10 -0
  47. package/tsconfig.json +21 -0
@@ -0,0 +1,7 @@
1
+ interface log {
2
+ error(text: string, line: number): void;
3
+ warn(text: string, line: number): void;
4
+ info(text: string, line: number): void;
5
+ }
6
+ export { log };
7
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/base/log.ts"],"names":[],"mappings":"AAAA,UAAU,GAAG;IACT,KAAK,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAE,IAAI,CAAA;IACnC,IAAI,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAE,IAAI,CAAA;IAClC,IAAI,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAE,IAAI,CAAA;CACrC;AACD,OAAO,EAAC,GAAG,EAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/base/log.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ declare class KV<K, V> {
2
+ key: K;
3
+ value: V;
4
+ constructor(key: K, value: V);
5
+ }
6
+ export { KV };
7
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/base/model.ts"],"names":[],"mappings":"AAAA,cAAM,EAAE,CAAC,CAAC,EAAC,CAAC;IACD,GAAG,EAAC,CAAC,CAAA;IACL,KAAK,EAAC,CAAC,CAAA;gBACF,GAAG,EAAC,CAAC,EAAC,KAAK,EAAC,CAAC;CAI5B;AACD,OAAO,EAAC,EAAE,EAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ class KV {
2
+ constructor(key, value) {
3
+ this.key = key;
4
+ this.value = value;
5
+ }
6
+ }
7
+ export { KV };
8
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/base/model.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE;IAGJ,YAAY,GAAK,EAAC,KAAO;QACrB,IAAI,CAAC,GAAG,GAAC,GAAG,CAAA;QACZ,IAAI,CAAC,KAAK,GAAC,KAAK,CAAA;IACpB,CAAC;CACJ;AACD,OAAO,EAAC,EAAE,EAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { token, token_type } from '../pre';
2
+ import { log } from '../../base/log';
3
+ interface tools {
4
+ peek(): token;
5
+ now(): token;
6
+ next(): token;
7
+ match(data: token): boolean;
8
+ match(data: token_type): boolean;
9
+ backup(): void;
10
+ restore(): void;
11
+ }
12
+ declare class Tree {
13
+ }
14
+ interface grammar {
15
+ match(tool: tools, log: log): boolean;
16
+ tree(): Tree;
17
+ }
18
+ export { tools, grammar, Tree };
19
+ //# sourceMappingURL=grammar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../../src/core/parser/grammar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAA;AAElC,UAAU,KAAK;IACX,IAAI,IAAG,KAAK,CAAA;IACZ,GAAG,IAAG,KAAK,CAAA;IACX,IAAI,IAAG,KAAK,CAAA;IACZ,KAAK,CAAC,IAAI,EAAC,KAAK,GAAE,OAAO,CAAA;IACzB,KAAK,CAAC,IAAI,EAAC,UAAU,GAAE,OAAO,CAAA;IAC9B,MAAM,IAAG,IAAI,CAAA;IACb,OAAO,IAAG,IAAI,CAAA;CACjB;AACD,cAAM,IAAI;CACT;AACD,UAAU,OAAO;IACb,KAAK,CAAC,IAAI,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,GAAE,OAAO,CAAA;IACjC,IAAI,IAAG,IAAI,CAAA;CACd;AACD,OAAO,EAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ class Tree {
2
+ }
3
+ export { Tree };
4
+ //# sourceMappingURL=grammar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammar.js","sourceRoot":"","sources":["../../../src/core/parser/grammar.ts"],"names":[],"mappings":"AAYA,MAAM,IAAI;CACT;AAKD,OAAO,EAAe,IAAI,EAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { token, token_type, word, match_type } from './model';
2
+ import { match } from './match';
3
+ import segment from './segment';
4
+ declare const _default: {
5
+ segment: typeof segment;
6
+ token: typeof token;
7
+ token_type: typeof token_type;
8
+ word: typeof word;
9
+ match_type: typeof match_type;
10
+ };
11
+ export default _default;
12
+ export { segment, token, token_type, word, match_type, match };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/pre/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAC7B,OAAO,OAAO,MAAM,WAAW,CAAA;;;;;;;;AAC/B,wBAMC;AACD,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,UAAU,EAAC,IAAI,EAAC,UAAU,EAAE,KAAK,EAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { token, token_type, word, match_type } from './model';
2
+ import { match } from './match';
3
+ import segment from './segment';
4
+ export default {
5
+ segment: segment,
6
+ token: token,
7
+ token_type: token_type,
8
+ word: word,
9
+ match_type: match_type
10
+ };
11
+ export { segment, token, token_type, word, match_type, match };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/pre/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAC7B,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,eAAe;IACX,OAAO,EAAC,OAAO;IACf,KAAK,EAAC,KAAK;IACX,UAAU,EAAC,UAAU;IACrB,IAAI,EAAC,IAAI;IACT,UAAU,EAAC,UAAU;CACxB,CAAA;AACD,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,UAAU,EAAC,IAAI,EAAC,UAAU,EAAE,KAAK,EAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 用于匹配string,identifier,number
3
+ * 作者:白子煦
4
+ * 最新修改:2026.4.4
5
+ */
6
+ import { match_type } from './model';
7
+ export declare function match(code: string[], i: number, type: match_type): {
8
+ i: number;
9
+ v: string;
10
+ o: boolean;
11
+ };
12
+ //# sourceMappingURL=match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/core/pre/match.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAA;AA0IlC,wBAAgB,KAAK,CAAC,IAAI,EAAC,MAAM,EAAE,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,UAAU,GAAE;IAAC,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,OAAO,CAAA;CAAC,CAS5F"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * 用于匹配string,identifier,number
3
+ * 作者:白子煦
4
+ * 最新修改:2026.4.4
5
+ */
6
+ import { match_type } from './model';
7
+ //索引,进制,是否成功
8
+ //可以作为开头的
9
+ const identifier_start = new Set([
10
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
11
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
12
+ '_'
13
+ ]);
14
+ //可以作为内容的
15
+ const identifier_content = new Set([
16
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
17
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
18
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
19
+ '_', '$'
20
+ ]);
21
+ //字符串起始
22
+ const str = new Set([
23
+ '"', '\'', '`'
24
+ ]);
25
+ function match_string(code, start) {
26
+ let i = start;
27
+ let v = '';
28
+ let o = false;
29
+ let _s;
30
+ if (str.has(code[i])) {
31
+ _s = code[i];
32
+ o = true;
33
+ while (i < code.length) {
34
+ if (code[i] == '\n') {
35
+ i++;
36
+ continue;
37
+ }
38
+ if (code[i] == '\\') {
39
+ v += code[i];
40
+ i++;
41
+ if (i >= code.length)
42
+ break;
43
+ }
44
+ v += code[i];
45
+ if (code[i] == _s && i != start) {
46
+ break;
47
+ }
48
+ i++;
49
+ }
50
+ i++;
51
+ }
52
+ return { i, v, o };
53
+ }
54
+ function match_identifier(code, start) {
55
+ let i = start;
56
+ let v = '';
57
+ let o = false;
58
+ if (identifier_start.has(code[i])) {
59
+ o = true;
60
+ v += code[i];
61
+ i++;
62
+ while (i < code.length) {
63
+ if (code[i] == '\n')
64
+ break;
65
+ if (code[i] == ' ')
66
+ break;
67
+ if (!identifier_content.has(code[i]))
68
+ break;
69
+ v += code[i];
70
+ i++;
71
+ }
72
+ i++;
73
+ }
74
+ return { i, v, o };
75
+ }
76
+ function match_number(code, start) {
77
+ let i = start;
78
+ let o = false;
79
+ let v = '';
80
+ if (code[i] == '0') {
81
+ o = true;
82
+ v += '0';
83
+ var point = false;
84
+ if (code[i + 1] == 'x' || code[i + 1] == 'X') {
85
+ v += 'x';
86
+ i += 2;
87
+ while (i < code.length) {
88
+ if (code[i] == ' ') {
89
+ break;
90
+ }
91
+ if (!(code[i] >= '0' && code[i] <= '9' || code[i] >= 'a' && code[i] <= 'f' || code[i] >= 'A' && code[i] <= 'F'))
92
+ break;
93
+ v += code[i];
94
+ i++;
95
+ }
96
+ }
97
+ else if (code[i + 1] == 'b' || code[i + 1] == 'B') {
98
+ v += 'b';
99
+ i += 2;
100
+ while (i < code.length) {
101
+ if (code[i] == ' ') {
102
+ break;
103
+ }
104
+ if (!(code[i] >= '0' && code[i] <= '1'))
105
+ break;
106
+ v += code[i];
107
+ i++;
108
+ }
109
+ }
110
+ else if (code[i + 1] == 'o' || code[i + 1] == 'O') {
111
+ v += 'o';
112
+ i += 2;
113
+ while (i < code.length) {
114
+ if (code[i] == ' ') {
115
+ break;
116
+ }
117
+ if (!(code[i] >= '0' && code[i] <= '7'))
118
+ break;
119
+ v += code[i];
120
+ i++;
121
+ }
122
+ }
123
+ else {
124
+ o = true;
125
+ i++;
126
+ v = '0';
127
+ }
128
+ }
129
+ else if (code[i] >= '1' && code[i] <= '9') {
130
+ o = true;
131
+ while (i < code.length) {
132
+ if (code[i] == ' ')
133
+ break;
134
+ if (!(code[i] >= '0' && code[i] <= '9' || code[i] == '.')) {
135
+ if (v[v.length - 1] == '.') {
136
+ v = v.substring(0, v.length - 1);
137
+ i--;
138
+ }
139
+ break;
140
+ }
141
+ if (code[i] == '.') {
142
+ if (point)
143
+ break;
144
+ point = true;
145
+ }
146
+ v += code[i];
147
+ i++;
148
+ }
149
+ }
150
+ return { i, v, o };
151
+ }
152
+ export function match(code, i, type) {
153
+ switch (type) {
154
+ case match_type.string:
155
+ return match_string(code, i);
156
+ case match_type.identifier:
157
+ return match_identifier(code, i);
158
+ case match_type.number:
159
+ return match_number(code, i);
160
+ }
161
+ }
162
+ //# sourceMappingURL=match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.js","sourceRoot":"","sources":["../../../src/core/pre/match.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAA;AAClC,YAAY;AACZ,SAAS;AACT,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC7B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAChI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAChI,GAAG;CACN,CAAC,CAAA;AACF,SAAS;AACT,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IAC/B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GA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keyword = 1,
4
+ space = 2,
5
+ number = 3,
6
+ string = 4,
7
+ unknow = 5
8
+ }
9
+ declare enum match_type {
10
+ number = 0,
11
+ string = 1,
12
+ identifier = 2
13
+ }
14
+ declare class word {
15
+ name: string;
16
+ constructor(name: string);
17
+ }
18
+ declare class token {
19
+ name: string;
20
+ type: token_type;
21
+ line: string;
22
+ constructor(name: string, type: token_type, line: string);
23
+ }
24
+ export { token, token_type, word, match_type };
25
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/core/pre/model.ts"],"names":[],"mappings":"AAAA,aAAK,UAAU;IACX,UAAU,IAAA;IACV,OAAO,IAAA;IACP,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,MAAM,IAAA;CACT;AACD,aAAK,UAAU;IACX,MAAM,IAAA;IACN,MAAM,IAAA;IACN,UAAU,IAAA;CACb;AACD,cAAM,IAAI;IACC,IAAI,EAAC,MAAM,CAAA;gBACN,IAAI,EAAC,MAAM;CAG1B;AACD,cAAM,KAAK;IACA,IAAI,EAAC,MAAM,CAAA;IACX,IAAI,EAAC,UAAU,CAAA;IACf,IAAI,EAAC,MAAM,CAAA;gBACN,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM;CAKtD;AACD,OAAO,EAAC,KAAK,EAAC,UAAU,EAAC,IAAI,EAAC,UAAU,EAAC,CAAA"}
@@ -0,0 +1,29 @@
1
+ var token_type;
2
+ (function (token_type) {
3
+ token_type[token_type["identifier"] = 0] = "identifier";
4
+ token_type[token_type["keyword"] = 1] = "keyword";
5
+ token_type[token_type["space"] = 2] = "space";
6
+ token_type[token_type["number"] = 3] = "number";
7
+ token_type[token_type["string"] = 4] = "string";
8
+ token_type[token_type["unknow"] = 5] = "unknow";
9
+ })(token_type || (token_type = {}));
10
+ var match_type;
11
+ (function (match_type) {
12
+ match_type[match_type["number"] = 0] = "number";
13
+ match_type[match_type["string"] = 1] = "string";
14
+ match_type[match_type["identifier"] = 2] = "identifier";
15
+ })(match_type || (match_type = {}));
16
+ class word {
17
+ constructor(name) {
18
+ this.name = name;
19
+ }
20
+ }
21
+ class token {
22
+ constructor(name, type, line) {
23
+ this.name = name;
24
+ this.type = type;
25
+ this.line = line;
26
+ }
27
+ }
28
+ export { token, token_type, word, match_type };
29
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/core/pre/model.ts"],"names":[],"mappings":"AAAA,IAAK,UAOJ;AAPD,WAAK,UAAU;IACX,uDAAU,CAAA;IACV,iDAAO,CAAA;IACP,6CAAK,CAAA;IACL,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,+CAAM,CAAA;AACV,CAAC,EAPI,UAAU,KAAV,UAAU,QAOd;AACD,IAAK,UAIJ;AAJD,WAAK,UAAU;IACX,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,uDAAU,CAAA;AACd,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;AACD,MAAM,IAAI;IAEN,YAAY,IAAW;QACnB,IAAI,CAAC,IAAI,GAAC,IAAI,CAAA;IAClB,CAAC;CACJ;AACD,MAAM,KAAK;IAIP,YAAY,IAAW,EAAC,IAAe,EAAC,IAAW;QAC/C,IAAI,CAAC,IAAI,GAAC,IAAI,CAAA;QACd,IAAI,CAAC,IAAI,GAAC,IAAI,CAAA;QACd,IAAI,CAAC,IAAI,GAAC,IAAI,CAAA;IAClB,CAAC;CACJ;AACD,OAAO,EAAC,KAAK,EAAC,UAAU,EAAC,IAAI,EAAC,UAAU,EAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 进行预分词
3
+ * 之后会被进一步加工成可用token
4
+ */
5
+ import { token, word } from './model';
6
+ declare class segment {
7
+ code: string[];
8
+ words: word[];
9
+ index: number;
10
+ line: number;
11
+ ret: token[];
12
+ private line_code;
13
+ constructor(code: string, words: word[]);
14
+ lines(): string;
15
+ segment(): token[];
16
+ is(i: number): boolean;
17
+ match_comment(): boolean;
18
+ match_other(): boolean;
19
+ match(w: word): boolean;
20
+ }
21
+ export default segment;
22
+ //# sourceMappingURL=segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/core/pre/segment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAa,KAAK,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AAG3D,cAAM,OAAO;IACF,IAAI,EAAC,MAAM,EAAE,CAAA;IACb,KAAK,EAAC,IAAI,EAAE,CAAA;IACZ,KAAK,EAAC,MAAM,CAAA;IACZ,IAAI,EAAC,MAAM,CAAA;IACX,GAAG,EAAC,KAAK,EAAE,CAAA;IAClB,OAAO,CAAC,SAAS,CAAS;gBACd,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,IAAI,EAAE;IAWpC,KAAK,IAAG,MAAM;IAGd,OAAO,IAAG,KAAK,EAAE;IAoDjB,EAAE,CAAC,CAAC,EAAC,MAAM;IAGX,aAAa,IAAG,OAAO;IA2BvB,WAAW,IAAG,OAAO;IAcrB,KAAK,CAAC,CAAC,EAAC,IAAI,GAAE,OAAO;CASxB;AACD,eAAe,OAAO,CAAA"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * 进行预分词
3
+ * 之后会被进一步加工成可用token
4
+ */
5
+ import { token_type, token, match_type } from './model';
6
+ import { match } from './match';
7
+ class segment {
8
+ constructor(code, words) {
9
+ code = code.replace(/\r\n/g, '\n');
10
+ //将words降序排序
11
+ words.sort((a, b) => {
12
+ return b.name.length - a.name.length;
13
+ });
14
+ this.code = [...code];
15
+ this.words = words;
16
+ this.line = 1;
17
+ this.line_code = code.replace(/\r\n/g, '\n').split('\n');
18
+ }
19
+ lines() {
20
+ return this.line_code[this.line - 1] + ': line ' + (this.line - 1);
21
+ }
22
+ segment() {
23
+ this.ret = [];
24
+ this.index = 0;
25
+ this.line = 1;
26
+ while (this.is(this.index)) {
27
+ if (this.code[this.index] == '\n') {
28
+ this.index++;
29
+ this.line++;
30
+ continue;
31
+ }
32
+ if (this.code[this.index] == ' ') {
33
+ this.ret.push(new token(' ', token_type.space, this.lines()));
34
+ while (this.is(this.index)) {
35
+ if (!(this.code[this.index] == ' '))
36
+ break;
37
+ this.index++;
38
+ }
39
+ continue;
40
+ }
41
+ //注释
42
+ if (this.match_comment())
43
+ continue;
44
+ //数字字符串
45
+ if (this.match_other())
46
+ continue;
47
+ var word_match = false;
48
+ for (let i = 0; i < this.words.length; i++) {
49
+ if (!this.match(this.words[i]))
50
+ continue;
51
+ var a = match(this.code, this.index, match_type.identifier);
52
+ if (a.o && a.v != this.words[i].name) {
53
+ console.log(a);
54
+ this.index = a.i;
55
+ this.ret.push(new token(a.v, token_type.identifier, this.lines()));
56
+ break;
57
+ }
58
+ this.ret.push(new token(this.words[i].name, token_type.keyword, this.lines()));
59
+ this.index += this.words[i].name.length;
60
+ word_match = true;
61
+ break;
62
+ }
63
+ //标识符
64
+ if (!word_match) {
65
+ if (match(this.code, this.index, match_type.identifier).o) {
66
+ var a = match(this.code, this.index, match_type.identifier);
67
+ this.index = a.i - 1;
68
+ this.ret.push(new token(a.v, token_type.identifier, this.lines()));
69
+ }
70
+ else {
71
+ this.ret.push(new token(this.code[this.index], token_type.unknow, this.lines()));
72
+ this.index++;
73
+ }
74
+ }
75
+ }
76
+ return this.ret;
77
+ }
78
+ is(i) {
79
+ return i >= 0 && i < this.code.length;
80
+ }
81
+ match_comment() {
82
+ if (this.code[this.index] == '/') {
83
+ if (this.code[this.index + 1] == '/') {
84
+ this.index += 2;
85
+ while (this.is(this.index)) {
86
+ if (this.code[this.index] == '\n') {
87
+ this.index++;
88
+ this.line++;
89
+ break;
90
+ }
91
+ this.index++;
92
+ }
93
+ return true;
94
+ }
95
+ else if (this.code[this.index + 1] == '*') {
96
+ this.index += 2;
97
+ while (this.is(this.index)) {
98
+ if (this.code[this.index] == '*' && this.is(this.index + 1) && this.code[this.index + 1] == '/') {
99
+ this.index += 2;
100
+ break;
101
+ }
102
+ this.index++;
103
+ }
104
+ return true;
105
+ }
106
+ }
107
+ return false;
108
+ }
109
+ match_other() {
110
+ var a = match(this.code, this.index, match_type.string);
111
+ if (match(this.code, this.index, match_type.string).o) {
112
+ this.ret.push(new token(a.v, token_type.string, this.lines()));
113
+ this.index = a.i;
114
+ return true;
115
+ }
116
+ else if (match(this.code, this.index, match_type.number).o) {
117
+ a = match(this.code, this.index, match_type.number);
118
+ this.ret.push(new token(a.v, token_type.number, this.lines()));
119
+ this.index = a.i;
120
+ return true;
121
+ }
122
+ return false;
123
+ }
124
+ match(w) {
125
+ if (this.is(this.index + w.name.length - 1)) {
126
+ for (let i = 0; i < w.name.length; i++) {
127
+ if (this.code[this.index + i] != w.name[i])
128
+ return false;
129
+ }
130
+ return true;
131
+ }
132
+ return false;
133
+ }
134
+ }
135
+ export default segment;
136
+ //# sourceMappingURL=segment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.js","sourceRoot":"","sources":["../../../src/core/pre/segment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,UAAU,EAAE,KAAK,EAAQ,UAAU,EAAC,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,OAAO;IAOT,YAAY,IAAW,EAAC,KAAY;QAChC,IAAI,GAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAC,IAAI,CAAC,CAAA;QAC/B,YAAY;QACZ,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE;YACd,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,GAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;QACtC,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACn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# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { segment, word } from './pre';
2
+ /**
3
+ * 测试用
4
+ */
5
+ let a = [
6
+ new word(';'),
7
+ new word('if'),
8
+ new word('else if')
9
+ ];
10
+ console.log(new segment("ifif 0x1234 123", a).segment());
11
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAO,IAAI,EAAC,MAAM,OAAO,CAAA;AACnD;;GAEG;AACH,IAAI,CAAC,GAAQ;IACT,IAAI,IAAI,CAAC,GAAG,CAAC;IACb,IAAI,IAAI,CAAC,IAAI,CAAC;IACd,IAAI,IAAI,CAAC,SAAS,CAAC;CACtB,CAAA;AACD,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,kBAAkB,EAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Tree, grammar, tools } from './core/parser/grammar';
2
+ import { token, token_type, word, segment } from './core/pre';
3
+ import { log } from './base/log';
4
+ export { Tree, grammar, tools, token, token_type, word, segment, log };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAc,OAAO,EAAQ,MAAM,YAAY,CAAA;AAC9E,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAA;AAC9B,OAAO,EACH,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,EACV,IAAI,EACJ,OAAO,EACP,GAAG,EACN,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { Tree } from './core/parser/grammar';
2
+ import { token, token_type, word, segment } from './core/pre';
3
+ export { Tree, token, token_type, word, segment };
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAiB,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAc,OAAO,EAAQ,MAAM,YAAY,CAAA;AAE9E,OAAO,EACH,IAAI,EAGJ,KAAK,EACL,UAAU,EACV,IAAI,EACJ,OAAO,EAEV,CAAA"}
package/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import {Tree, grammar, tools} from './dist/core/parser/grammar'
2
+ import {token, token_type, word, segment} from './dist/core/pre'
3
+ import {log} from './dist/base/log'
4
+ export {
5
+ Tree,
6
+ grammar,
7
+ tools,
8
+ token,
9
+ token_type,
10
+ word,
11
+ segment,
12
+ log
13
+ }
package/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import {Tree, grammar, tools} from './src/core/parser/grammar'
2
+ import {token, token_type, word, segment} from './src/core/pre'
3
+ import {log} from './src/base/log'
4
+ export {
5
+ Tree,
6
+ grammar,
7
+ tools,
8
+ token,
9
+ token_type,
10
+ word,
11
+ segment,
12
+ log
13
+ }
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "allang-compiler-base",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "upload": "npm publish",
9
+ "local_test": "node.exe --import file:/D:/Program%20Files/JetBrains/WebStorm%202025.1.4.1/plugins/nodeJS/js/ts-file-loader/node_modules/tsx/dist/loader.cjs E:\\alLang\\base\\src\\core\\test.ts"
10
+ },
11
+ "type": "module",
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "MIT"
15
+ }
@@ -0,0 +1,6 @@
1
+ interface log{
2
+ error(text:string,line:number):void
3
+ warn(text:string,line:number):void
4
+ info(text:string,line:number):void
5
+ }
6
+ export {log}
@@ -0,0 +1,20 @@
1
+ import {token, token_type} from '../pre'
2
+ import {log} from '../../base/log'
3
+
4
+ interface tools{
5
+ peek():token
6
+ now():token
7
+ next():token
8
+ match(data:token):boolean
9
+ match(data:token_type):boolean
10
+ backup():void
11
+ restore():void
12
+ }
13
+ class Tree{
14
+ }
15
+ interface grammar{
16
+ match(tool:tools,log:log):boolean
17
+ tree():Tree
18
+ no_match(log:log):void
19
+ }
20
+ export {tools,grammar,Tree}
@@ -0,0 +1,11 @@
1
+ import {token,token_type, word, match_type} from './model'
2
+ import {match} from './match'
3
+ import segment from './segment'
4
+ export default {
5
+ segment:segment,
6
+ token:token,
7
+ token_type:token_type,
8
+ word:word,
9
+ match_type:match_type
10
+ }
11
+ export {segment,token,token_type,word,match_type, match}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * 用于匹配string,identifier,number
3
+ * 作者:白子煦
4
+ * 最新修改:2026.4.4
5
+ */
6
+ import {match_type} from './model'
7
+ //索引,进制,是否成功
8
+ //可以作为开头的
9
+ const identifier_start = new Set([
10
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
11
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
12
+ '_'
13
+ ])
14
+ //可以作为内容的
15
+ const identifier_content = new Set([
16
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
17
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
18
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
19
+ '_','$'
20
+ ])
21
+ //字符串起始
22
+ const str =new Set([
23
+ '"', '\'', '`'])
24
+
25
+ function match_string(code:string[], start:number):{i:number,v:string,o:boolean}{
26
+ let i=start
27
+ let v=''
28
+ let o=false
29
+ let _s:string
30
+ if(str.has(code[i])){
31
+ _s=code[i]
32
+ o=true
33
+ while(i<code.length){
34
+ if(code[i]=='\n') {
35
+ i++
36
+ continue
37
+ }
38
+ if(code[i]=='\\'){
39
+ v+=code[i]
40
+ i++
41
+ if(i>=code.length)break
42
+ }
43
+ v+=code[i]
44
+ if(code[i]==_s&&i!=start){
45
+ break
46
+ }
47
+ i++
48
+ }
49
+ i++
50
+ }
51
+ return {i,v,o}
52
+ }
53
+ function match_identifier(code:string[], start:number):{i:number,v:string,o:boolean}{
54
+ let i=start
55
+ let v=''
56
+ let o=false
57
+ if(identifier_start.has(code[i])){
58
+ o=true
59
+ v+=code[i]
60
+ i++
61
+ while(i<code.length){
62
+ if(code[i]=='\n')break
63
+ if(code[i]==' ')
64
+ break
65
+ if(!identifier_content.has(code[i]))
66
+ break
67
+ v+=code[i]
68
+ i++
69
+ }
70
+ i++
71
+ }
72
+ return {i,v,o}
73
+ }
74
+ function match_number(code:string[], start:number):{i:number,v:string,o:boolean}{
75
+ let i=start
76
+ let o=false
77
+ let v=''
78
+ if(code[i]=='0'){
79
+ o=true
80
+ v+='0'
81
+ var point=false
82
+ if(code[i+1]=='x'||code[i+1]=='X'){
83
+ v+='x'
84
+ i+=2
85
+ while(i<code.length){
86
+ if(code[i]==' '){
87
+ break
88
+ }
89
+ if(!(code[i]>='0'&&code[i]<='9'||code[i]>='a'&&code[i]<='f'||code[i]>='A'&&code[i]<='F'))
90
+ break
91
+ v+=code[i]
92
+ i++
93
+ }
94
+ }else if(code[i+1]=='b'||code[i+1]=='B'){
95
+ v+='b'
96
+ i+=2
97
+ while(i<code.length){
98
+ if(code[i]==' '){
99
+ break
100
+ }
101
+ if(!(code[i]>='0'&&code[i]<='1'))
102
+ break
103
+ v+=code[i]
104
+ i++
105
+ }
106
+ }else if(code[i+1]=='o'||code[i+1]=='O'){
107
+ v+='o'
108
+ i+=2
109
+ while(i<code.length){
110
+ if(code[i]==' '){
111
+ break
112
+ }
113
+ if(!(code[i]>='0'&&code[i]<='7'))
114
+ break
115
+ v+=code[i]
116
+ i++
117
+ }
118
+ }else{
119
+ o=true
120
+ i++
121
+ v='0'
122
+ }
123
+ }else if(code[i]>='1'&&code[i]<='9'){
124
+ o=true
125
+ while(i<code.length){
126
+ if(code[i]==' ')break
127
+ if(!(code[i]>='0'&&code[i]<='9'||code[i]=='.')){
128
+ if(v[v.length-1]=='.'){
129
+ v=v.substring(0,v.length-1)
130
+ i--
131
+ }
132
+ break
133
+ }
134
+ if(code[i]=='.'){
135
+ if(point)break
136
+ point=true
137
+ }
138
+ v+=code[i]
139
+ i++
140
+ }
141
+ }
142
+ return {i,v,o}
143
+ }
144
+ export function match(code:string[], i:number, type:match_type):{i:number,v:string,o:boolean}{
145
+ switch ( type){
146
+ case match_type.string:
147
+ return match_string(code, i)
148
+ case match_type.identifier:
149
+ return match_identifier(code, i)
150
+ case match_type.number:
151
+ return match_number(code, i)
152
+ }
153
+ }
@@ -0,0 +1,30 @@
1
+ enum token_type{
2
+ identifier,
3
+ keyword,
4
+ space,
5
+ number,
6
+ string,
7
+ unknow
8
+ }
9
+ enum match_type{
10
+ number,
11
+ string,
12
+ identifier
13
+ }
14
+ class word{
15
+ public name:string
16
+ constructor(name:string) {
17
+ this.name=name
18
+ }
19
+ }
20
+ class token{
21
+ public name:string
22
+ public type:token_type
23
+ public line:string
24
+ constructor(name:string,type:token_type,line:string) {
25
+ this.name=name
26
+ this.type=type
27
+ this.line=line
28
+ }
29
+ }
30
+ export {token,token_type,word,match_type}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * 进行预分词
3
+ * 之后会被进一步加工成可用token
4
+ */
5
+ import {token_type, token, word, match_type} from './model'
6
+ import {match} from './match'
7
+
8
+ class segment{
9
+ public code:string[]
10
+ public words:word[]
11
+ public index:number
12
+ public line:number
13
+ public ret:token[]
14
+ private line_code:string[]
15
+ constructor(code:string,words:word[]) {
16
+ code=code.replace(/\r\n/g,'\n')
17
+ //将words降序排序
18
+ words.sort((a,b)=>{
19
+ return b.name.length-a.name.length
20
+ })
21
+ this.code=[...code]
22
+ this.words=words
23
+ this.line=1
24
+ this.line_code=code.replace(/\r\n/g,'\n').split('\n')
25
+ }
26
+ lines():string{
27
+ return this.line_code[this.line-1]+': line '+(this.line-1)
28
+ }
29
+ segment():token[]{
30
+ this.ret=[]
31
+ this.index=0
32
+ this.line=1
33
+ while(this.is(this.index)){
34
+ if(this.code[this.index]=='\n'){
35
+ this.index++
36
+ this.line++
37
+ continue
38
+ }
39
+ if(this.code[this.index]==' '){
40
+ this.ret.push(new token(' ',token_type.space,this.lines()))
41
+ while(this.is(this.index)){
42
+ if(!(this.code[this.index]==' '))
43
+ break
44
+ this.index++
45
+ }
46
+ continue
47
+ }
48
+ //注释
49
+ if(this.match_comment()) continue
50
+ //数字字符串
51
+ if(this.match_other()) continue
52
+ var word_match=false
53
+ for(let i=0;i<this.words.length;i++){
54
+ if(!this.match(this.words[i]))continue
55
+ var a=match(this.code,this.index,match_type.identifier)
56
+ if(a.o&&a.v!=this.words[i].name){
57
+ console.log(a)
58
+ this.index=a.i
59
+ this.ret.push(new token(a.v,token_type.identifier,this.lines()))
60
+ break
61
+ }
62
+ this.ret.push(new token(this.words[i].name,token_type.keyword,this.lines()))
63
+ this.index+=this.words[i].name.length
64
+ word_match=true
65
+ break
66
+ }
67
+ //标识符
68
+ if(!word_match){
69
+ if(match(this.code,this.index,match_type.identifier).o){
70
+ var a=match(this.code,this.index,match_type.identifier)
71
+ this.index=a.i-1
72
+ this.ret.push(new token(a.v,token_type.identifier,this.lines()))
73
+ }else{
74
+ this.ret.push(new token(this.code[this.index],token_type.unknow,this.lines()))
75
+ this.index++
76
+ }
77
+ }
78
+ }
79
+ return this.ret
80
+ }
81
+ is(i:number){
82
+ return i>=0&&i<this.code.length
83
+ }
84
+ match_comment():boolean{
85
+ if(this.code[this.index]=='/'){
86
+ if(this.code[this.index+1]=='/'){
87
+ this.index+=2
88
+ while(this.is(this.index)){
89
+ if(this.code[this.index]=='\n'){
90
+ this.index++
91
+ this.line++
92
+ break
93
+ }
94
+ this.index++
95
+ }
96
+ return true
97
+ }else if(this.code[this.index+1]=='*'){
98
+ this.index+=2
99
+ while(this.is(this.index)){
100
+ if(this.code[this.index]=='*'&&this.is(this.index+1)&&this.code[this.index+1]=='/'){
101
+ this.index+=2
102
+ break
103
+ }
104
+ this.index++
105
+ }
106
+ return true
107
+ }
108
+ }
109
+ return false
110
+ }
111
+ match_other():boolean{
112
+ var a=match(this.code,this.index,match_type.string)
113
+ if(match(this.code,this.index,match_type.string).o){
114
+ this.ret.push(new token(a.v,token_type.string,this.lines()))
115
+ this.index=a.i
116
+ return true
117
+ }else if(match(this.code,this.index,match_type.number).o){
118
+ a=match(this.code,this.index,match_type.number)
119
+ this.ret.push(new token(a.v,token_type.number,this.lines()))
120
+ this.index=a.i
121
+ return true
122
+ }
123
+ return false
124
+ }
125
+ match(w:word):boolean{
126
+ if(this.is(this.index+w.name.length-1)){
127
+ for(let i=0;i<w.name.length;i++){
128
+ if(this.code[this.index+i]!=w.name[i]) return false
129
+ }
130
+ return true
131
+ }
132
+ return false
133
+ }
134
+ }
135
+ export default segment
@@ -0,0 +1,10 @@
1
+ import {token_type,segment,token,word} from './pre'
2
+ /**
3
+ * 测试用
4
+ */
5
+ let a:word[]=[
6
+ new word(';'),
7
+ new word('if'),
8
+ new word('else if')
9
+ ]
10
+ console.log(new segment("ifif 0x1234 123",a).segment())
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "ES6",
5
+ "lib": ["ES6","DOM"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": false,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "moduleResolution": "bundler",
16
+ "resolveJsonModule": true,
17
+ "allowSyntheticDefaultImports": true
18
+ },
19
+ "include": ["src/**/*"],
20
+ "exclude": ["node_modules", "dist"]
21
+ }