motoko 3.0.0-beta5 → 3.0.0-beta7
Sign up to get free protection for your applications and to get access to all the features.
- package/contrib/hljs.js +13 -15
- package/contrib/monaco.js +4 -10
- package/lib/ast.d.ts +7 -1
- package/lib/ast.d.ts.map +1 -1
- package/lib/ast.js +5 -5
- package/lib/ast.js.map +1 -1
- package/lib/keywords.d.ts +3 -0
- package/lib/keywords.d.ts.map +1 -0
- package/lib/keywords.js +75 -0
- package/lib/keywords.js.map +1 -0
- package/package.json +1 -1
- package/packages/latest/base.json +1 -1
- package/src/ast.ts +13 -6
- package/src/keywords.ts +72 -0
- package/versions/latest/moc.min.js +1 -1
- package/versions/latest/moc_interpreter.min.js +1 -1
package/src/ast.ts
CHANGED
@@ -9,12 +9,19 @@ export interface CompilerNode {
|
|
9
9
|
export type Span = [number, number];
|
10
10
|
export type AST = AST[] | Node | string | null;
|
11
11
|
|
12
|
-
export interface
|
12
|
+
export interface Source {
|
13
|
+
file?: string;
|
14
|
+
start?: Span;
|
15
|
+
end?: Span;
|
16
|
+
}
|
17
|
+
|
18
|
+
export interface Node extends Source {
|
13
19
|
name: string;
|
14
20
|
file?: string;
|
15
21
|
start?: Span;
|
16
22
|
end?: Span;
|
17
23
|
type?: Node;
|
24
|
+
declaration?: Source;
|
18
25
|
args?: AST[];
|
19
26
|
}
|
20
27
|
|
@@ -51,12 +58,12 @@ export function simplifyAST(ast: CompilerAST): AST {
|
|
51
58
|
};
|
52
59
|
}
|
53
60
|
if (ast.name === ':') {
|
54
|
-
const [
|
55
|
-
// console.log(
|
61
|
+
const [typeAst, type] = ast.args as [CompilerAST, CompilerNode];
|
62
|
+
// console.log(typeAst); ////
|
56
63
|
return {
|
57
|
-
...(typeof
|
58
|
-
? { name:
|
59
|
-
: simplifyAST(
|
64
|
+
...(typeof typeAst === 'string'
|
65
|
+
? { name: typeAst }
|
66
|
+
: simplifyAST(typeAst)),
|
60
67
|
type: simplifyAST(type),
|
61
68
|
};
|
62
69
|
}
|
package/src/keywords.ts
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
export const keywords = [
|
2
|
+
'actor',
|
3
|
+
'and',
|
4
|
+
'async',
|
5
|
+
'assert',
|
6
|
+
'await',
|
7
|
+
'break',
|
8
|
+
'case',
|
9
|
+
'catch',
|
10
|
+
'class',
|
11
|
+
'continue',
|
12
|
+
'debug',
|
13
|
+
'debug_show',
|
14
|
+
'do',
|
15
|
+
'else',
|
16
|
+
'false',
|
17
|
+
'flexible',
|
18
|
+
'for',
|
19
|
+
'from_candid',
|
20
|
+
'func',
|
21
|
+
'if',
|
22
|
+
'ignore',
|
23
|
+
'in',
|
24
|
+
'import',
|
25
|
+
'label',
|
26
|
+
'let',
|
27
|
+
'loop',
|
28
|
+
'module',
|
29
|
+
'not',
|
30
|
+
'null',
|
31
|
+
'object',
|
32
|
+
'or',
|
33
|
+
'private',
|
34
|
+
'public',
|
35
|
+
'query',
|
36
|
+
'return',
|
37
|
+
'shared',
|
38
|
+
'stable',
|
39
|
+
'switch',
|
40
|
+
'system',
|
41
|
+
'throw',
|
42
|
+
'to_candid',
|
43
|
+
'true',
|
44
|
+
'try',
|
45
|
+
'type',
|
46
|
+
'var',
|
47
|
+
'while',
|
48
|
+
'with',
|
49
|
+
];
|
50
|
+
|
51
|
+
export const typeKeywords = [
|
52
|
+
'Any',
|
53
|
+
'None',
|
54
|
+
'Null',
|
55
|
+
'Bool',
|
56
|
+
'Int',
|
57
|
+
'Int8',
|
58
|
+
'Int16',
|
59
|
+
'Int32',
|
60
|
+
'Int64',
|
61
|
+
'Nat',
|
62
|
+
'Nat8',
|
63
|
+
'Nat16',
|
64
|
+
'Nat32',
|
65
|
+
'Nat64',
|
66
|
+
'Float',
|
67
|
+
'Char',
|
68
|
+
'Text',
|
69
|
+
'Blob',
|
70
|
+
'Error',
|
71
|
+
'Principal',
|
72
|
+
];
|