motoko 3.0.0-beta5 → 3.0.0-beta7

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/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 Node {
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 [type, subAst] = ast.args as [CompilerNode, CompilerAST];
55
- // console.log(subAst); ////
61
+ const [typeAst, type] = ast.args as [CompilerAST, CompilerNode];
62
+ // console.log(typeAst); ////
56
63
  return {
57
- ...(typeof subAst === 'string'
58
- ? { name: subAst }
59
- : simplifyAST(subAst)),
64
+ ...(typeof typeAst === 'string'
65
+ ? { name: typeAst }
66
+ : simplifyAST(typeAst)),
60
67
  type: simplifyAST(type),
61
68
  };
62
69
  }
@@ -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
+ ];