motoko 3.0.0-beta6 → 3.0.0-beta7

Sign up to get free protection for your applications and to get access to all the features.
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
  }