@mirascript/constants 0.1.26
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/constants.g.d.ts +735 -0
- package/dist/constants.g.d.ts.map +1 -0
- package/dist/constants.g.js +810 -0
- package/dist/constants.g.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -0
- package/src/constants.g.ts +820 -0
- package/src/index.ts +35 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type * as wasm from './constants.g.js';
|
|
2
|
+
import { KEYWORDS } from './constants.g.js';
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
DiagnosticCode,
|
|
6
|
+
OpCode,
|
|
7
|
+
DIAGNOSTIC_MESSAGES,
|
|
8
|
+
KEYWORDS,
|
|
9
|
+
CONTROL_KEYWORDS,
|
|
10
|
+
NUMERIC_KEYWORDS,
|
|
11
|
+
CONSTANT_KEYWORDS,
|
|
12
|
+
RESERVED_KEYWORDS,
|
|
13
|
+
} from './constants.g.js';
|
|
14
|
+
|
|
15
|
+
/** 配置选项 */
|
|
16
|
+
export type Config = Partial<
|
|
17
|
+
Omit<wasm.Config, 'free' | 'input_mode' | 'diagnostic_position_encoding' | typeof Symbol.dispose>
|
|
18
|
+
> & {
|
|
19
|
+
input_mode?: InputMode;
|
|
20
|
+
diagnostic_position_encoding?: DiagnosticPositionEncoding;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** 编译输入,支持字符串和 UTF-8 字节数组 */
|
|
24
|
+
export type ScriptInput = string | Uint8Array;
|
|
25
|
+
/** Encoding for counting positions in diagnostics. */
|
|
26
|
+
export type DiagnosticPositionEncoding = keyof typeof wasm.DiagnosticPositionEncoding;
|
|
27
|
+
/** 输入模式 */
|
|
28
|
+
export type InputMode = keyof typeof wasm.InputMode;
|
|
29
|
+
|
|
30
|
+
const keywordsSet = new Set<string>(KEYWORDS);
|
|
31
|
+
/** 检查是否为 MiraScript 关键字 */
|
|
32
|
+
export function isKeyword(word: string): word is (typeof KEYWORDS)[number] {
|
|
33
|
+
if (typeof word !== 'string') return false;
|
|
34
|
+
return keywordsSet.has(word);
|
|
35
|
+
}
|