Skip to content

Commit 543e8a2

Browse files
Update types, use default constant for variables
1 parent 2c8ac74 commit 543e8a2

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

libs/parsing/syntax-tree/src/lib/parsed.interface.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import { IFoundTokens } from '@idl/tokenizer';
22
import { GlobalTokens, ICompileOptions } from '@idl/types/core';
33
import { IDisabledProblems, SyntaxProblems } from '@idl/types/problem-codes';
44
import { PositionArray } from '@idl/types/tokenizer';
5+
import copy from 'fast-copy';
56
import { DocumentSymbol, SemanticTokens } from 'vscode-languageserver';
67

78
import { SyntaxTree } from './branches.interface';
89
import {
910
DEFAULT_USES_THESE_GLOBAL_TOKEN,
1011
UsesTheseGlobalTokens,
1112
} from './build-syntax-tree.interface';
12-
import { ILocalTokens } from './populators/populate-local.interface';
13+
import {
14+
DEFAULT_LOCAL_TOKENS,
15+
ILocalTokens,
16+
} from './populators/populate-local.interface';
1317

1418
/**
1519
* Type of parsed item that we have
@@ -90,11 +94,7 @@ export const DEFAULT_PARSED: IParsed = {
9094
postProcessProblems: [],
9195
tree: [],
9296
global: [],
93-
local: {
94-
func: {},
95-
pro: {},
96-
main: {},
97-
},
97+
local: copy(DEFAULT_LOCAL_TOKENS),
9898
compile: {
9999
func: {},
100100
pro: {},

libs/parsing/syntax-tree/src/lib/populators/populate-local.interface.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,15 @@ export interface ILocalIndexedToken<T extends LocalTokenTypes>
6464
meta: LocalTokenMetadata<T>;
6565
}
6666

67-
/**
68-
* Local tokens that we extract from a routine or main level program
69-
*/
70-
export type LocalTokens = ILocalIndexedToken<LocalTokenTypes>[];
67+
/** Single local token (i.e. variable in IDL code) */
68+
export type LocalToken = ILocalIndexedToken<LocalTokenTypes>;
7169

7270
/**
7371
* Lookup for tokens defined locally within a routine or main level program
7472
*/
7573
export interface ILocalTokenLookup {
7674
/** Key should be lower-case variable name */
77-
[key: string]: ILocalIndexedToken<LocalTokenTypes>;
75+
[key: string]: LocalToken;
7876
}
7977

8078
/**
@@ -94,3 +92,12 @@ export interface ILocalTokens {
9492
*/
9593
main: ILocalTokenLookup;
9694
}
95+
96+
/**
97+
* Default tokens for local
98+
*/
99+
export const DEFAULT_LOCAL_TOKENS: ILocalTokens = {
100+
pro: {},
101+
func: {},
102+
main: {},
103+
};

0 commit comments

Comments
 (0)