circuitscript 0.1.4 → 0.1.7

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.
Files changed (102) hide show
  1. package/dist/cjs/BaseVisitor.js +149 -80
  2. package/dist/cjs/SemanticTokenVisitor.js +19 -13
  3. package/dist/cjs/antlr/CircuitScriptParser.js +711 -671
  4. package/dist/cjs/builtinMethods.js +48 -22
  5. package/dist/cjs/draw_symbols.js +4 -1
  6. package/dist/cjs/environment.js +118 -0
  7. package/dist/cjs/execute.js +98 -46
  8. package/dist/cjs/geometry.js +1 -0
  9. package/dist/cjs/globals.js +14 -7
  10. package/dist/cjs/helpers.js +142 -150
  11. package/dist/cjs/index.js +5 -0
  12. package/dist/cjs/layout.js +39 -14
  13. package/dist/cjs/main.js +34 -21
  14. package/dist/cjs/objects/ClassComponent.js +4 -1
  15. package/dist/cjs/objects/ExecutionScope.js +40 -2
  16. package/dist/cjs/objects/ParamDefinition.js +15 -15
  17. package/dist/cjs/parser.js +27 -21
  18. package/dist/cjs/regenerate-tests.js +9 -6
  19. package/dist/cjs/render.js +3 -1
  20. package/dist/cjs/sizing.js +10 -60
  21. package/dist/cjs/utils.js +148 -17
  22. package/dist/cjs/validate/SymbolTable.js +96 -0
  23. package/dist/cjs/validate/SymbolValidatorResolveVisitor.js +14 -0
  24. package/dist/cjs/validate/SymbolValidatorVisitor.js +170 -0
  25. package/dist/cjs/validate.js +52 -44
  26. package/dist/cjs/visitor.js +149 -31
  27. package/dist/esm/{BaseVisitor.mjs → BaseVisitor.js} +124 -56
  28. package/dist/esm/{SemanticTokenVisitor.mjs → SemanticTokenVisitor.js} +17 -11
  29. package/dist/esm/antlr/{CircuitScriptParser.mjs → CircuitScriptParser.js} +711 -671
  30. package/dist/esm/{builtinMethods.mjs → builtinMethods.js} +40 -14
  31. package/dist/esm/{draw_symbols.mjs → draw_symbols.js} +11 -8
  32. package/dist/esm/environment.js +110 -0
  33. package/dist/esm/{execute.mjs → execute.js} +111 -58
  34. package/dist/esm/{export.mjs → export.js} +2 -2
  35. package/dist/esm/{geometry.mjs → geometry.js} +6 -5
  36. package/dist/esm/{globals.mjs → globals.js} +9 -2
  37. package/dist/esm/helpers.js +377 -0
  38. package/dist/esm/index.js +20 -0
  39. package/dist/esm/{layout.mjs → layout.js} +44 -22
  40. package/dist/esm/{lexer.mjs → lexer.js} +2 -2
  41. package/dist/esm/{main.mjs → main.js} +36 -23
  42. package/dist/esm/objects/{ClassComponent.mjs → ClassComponent.js} +9 -5
  43. package/dist/esm/objects/{ExecutionScope.mjs → ExecutionScope.js} +40 -2
  44. package/dist/esm/objects/{Frame.mjs → Frame.js} +1 -1
  45. package/dist/esm/objects/{ParamDefinition.mjs → ParamDefinition.js} +1 -1
  46. package/dist/esm/objects/{PinDefinition.mjs → PinDefinition.js} +1 -1
  47. package/dist/esm/parser.js +71 -0
  48. package/dist/esm/{regenerate-tests.mjs → regenerate-tests.js} +10 -7
  49. package/dist/esm/{render.mjs → render.js} +11 -9
  50. package/dist/esm/{sizing.mjs → sizing.js} +11 -36
  51. package/dist/esm/utils.js +286 -0
  52. package/dist/esm/validate/SymbolTable.js +90 -0
  53. package/dist/esm/validate/SymbolValidatorResolveVisitor.js +10 -0
  54. package/dist/esm/validate/SymbolValidatorVisitor.js +163 -0
  55. package/dist/esm/validate.js +86 -0
  56. package/dist/esm/{visitor.mjs → visitor.js} +160 -42
  57. package/dist/fonts/Arial.ttf +0 -0
  58. package/dist/fonts/Inter-Bold.ttf +0 -0
  59. package/dist/fonts/Inter-Regular.ttf +0 -0
  60. package/dist/fonts/OpenSans-Regular.ttf +0 -0
  61. package/dist/fonts/Roboto-Regular.ttf +0 -0
  62. package/dist/libs/lib.cst +423 -0
  63. package/dist/types/BaseVisitor.d.ts +36 -22
  64. package/dist/types/SemanticTokenVisitor.d.ts +6 -5
  65. package/dist/types/antlr/CircuitScriptParser.d.ts +4 -2
  66. package/dist/types/builtinMethods.d.ts +3 -2
  67. package/dist/types/draw_symbols.d.ts +2 -6
  68. package/dist/types/environment.d.ts +31 -0
  69. package/dist/types/execute.d.ts +2 -3
  70. package/dist/types/globals.d.ts +7 -2
  71. package/dist/types/helpers.d.ts +12 -14
  72. package/dist/types/index.d.ts +5 -0
  73. package/dist/types/objects/ClassComponent.d.ts +2 -3
  74. package/dist/types/objects/ExecutionScope.d.ts +20 -6
  75. package/dist/types/objects/types.d.ts +6 -1
  76. package/dist/types/parser.d.ts +7 -11
  77. package/dist/types/sizing.d.ts +0 -3
  78. package/dist/types/utils.d.ts +33 -4
  79. package/dist/types/validate/SymbolTable.d.ts +40 -0
  80. package/dist/types/validate/SymbolValidatorResolveVisitor.d.ts +7 -0
  81. package/dist/types/validate/SymbolValidatorVisitor.d.ts +32 -0
  82. package/dist/types/validate.d.ts +1 -1
  83. package/libs/lib.cst +12 -22
  84. package/package.json +14 -13
  85. package/dist/cjs/SymbolValidatorVisitor.js +0 -233
  86. package/dist/esm/SymbolValidatorVisitor.mjs +0 -222
  87. package/dist/esm/helpers.mjs +0 -380
  88. package/dist/esm/index.mjs +0 -15
  89. package/dist/esm/parser.mjs +0 -64
  90. package/dist/esm/utils.mjs +0 -169
  91. package/dist/esm/validate.mjs +0 -74
  92. package/dist/types/SymbolValidatorVisitor.d.ts +0 -61
  93. package/dist/types/layout.d.ts +0 -148
  94. /package/dist/esm/antlr/{CircuitScriptLexer.mjs → CircuitScriptLexer.js} +0 -0
  95. /package/dist/esm/antlr/{CircuitScriptVisitor.mjs → CircuitScriptVisitor.js} +0 -0
  96. /package/dist/esm/{fonts.mjs → fonts.js} +0 -0
  97. /package/dist/esm/{logger.mjs → logger.js} +0 -0
  98. /package/dist/esm/objects/{Net.mjs → Net.js} +0 -0
  99. /package/dist/esm/objects/{PinTypes.mjs → PinTypes.js} +0 -0
  100. /package/dist/esm/objects/{Wire.mjs → Wire.js} +0 -0
  101. /package/dist/esm/objects/{types.mjs → types.js} +0 -0
  102. /package/dist/esm/{server.mjs → server.js} +0 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SymbolTable = void 0;
4
+ const types_js_1 = require("../objects/types.js");
5
+ class SymbolTable {
6
+ constructor() {
7
+ this.symbols = new Map();
8
+ this.executonContextsNamespaces = [];
9
+ }
10
+ getSymbols() {
11
+ return this.symbols;
12
+ }
13
+ addFunction(token, fileName, executionContext, id, funcDefinedParameters) {
14
+ return this.add(fileName, executionContext, id, types_js_1.ParseSymbolType.Function, {
15
+ funcDefinedParameters
16
+ }, token);
17
+ }
18
+ addVariable(token, fileName, executionContext, id, variableValue) {
19
+ return this.add(fileName, executionContext, id, types_js_1.ParseSymbolType.Variable, {
20
+ variableValue
21
+ }, token);
22
+ }
23
+ addUndefined(filePath, executionContext, id, token) {
24
+ return this.add(filePath, executionContext, id, types_js_1.ParseSymbolType.Undefined, {}, token);
25
+ }
26
+ add(fileName, executionContext, id, type, extra, token) {
27
+ if (this.executonContextsNamespaces.indexOf(executionContext.namespace) === -1) {
28
+ this.executonContextsNamespaces.push(executionContext.namespace);
29
+ }
30
+ const item = {
31
+ id,
32
+ type,
33
+ context: executionContext,
34
+ fileName,
35
+ extra,
36
+ token,
37
+ instances: [],
38
+ };
39
+ if (token !== null) {
40
+ item.instances.push(token);
41
+ }
42
+ this.symbols.set(this.idName(executionContext, id), item);
43
+ return item;
44
+ }
45
+ idName(executionContext, id) {
46
+ return executionContext.namespace + id;
47
+ }
48
+ dumpSymbols() {
49
+ for (const [key, value] of this.symbols) {
50
+ console.log(value.type.padEnd(10, " "), key);
51
+ }
52
+ }
53
+ exists(executionContext, id) {
54
+ const name = this.idName(executionContext, id);
55
+ return this.symbols.has(name);
56
+ }
57
+ existsAny(executionContext, id) {
58
+ if (this.exists(executionContext, id)) {
59
+ return true;
60
+ }
61
+ else {
62
+ return this.searchParentContext(executionContext, id) !== null;
63
+ }
64
+ }
65
+ get(executionContext, id) {
66
+ const name = this.idName(executionContext, id);
67
+ return this.symbols.get(name);
68
+ }
69
+ getParentContexts(executionContext, contextsNamespace) {
70
+ if (executionContext.parentContext !== null) {
71
+ contextsNamespace.push(executionContext.parentContext.namespace);
72
+ this.getParentContexts(executionContext.parentContext, contextsNamespace);
73
+ }
74
+ return contextsNamespace;
75
+ }
76
+ searchParentContext(executionContext, id) {
77
+ const contextNames = this.getParentContexts(executionContext, []);
78
+ for (const [key,] of this.symbols) {
79
+ if (key.endsWith(`.${id}`)) {
80
+ const { context } = this.symbols.get(key);
81
+ if (contextNames.indexOf(context.namespace) !== -1) {
82
+ return context;
83
+ }
84
+ }
85
+ }
86
+ return null;
87
+ }
88
+ clearUndefined() {
89
+ for (const [key, value] of this.symbols) {
90
+ if (value.type === types_js_1.ParseSymbolType.Undefined) {
91
+ this.symbols.delete(key);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ exports.SymbolTable = SymbolTable;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SymbolValidatorResolveVisitor = void 0;
4
+ const SymbolValidatorVisitor_js_1 = require("./SymbolValidatorVisitor.js");
5
+ class SymbolValidatorResolveVisitor extends SymbolValidatorVisitor_js_1.SymbolValidatorVisitor {
6
+ addSymbolVariable(token, name, value) {
7
+ }
8
+ addSymbolFunction(token, functionName, funcDefinedParameters) {
9
+ if (this.symbolTable.exists(this.getExecutor(), functionName)) {
10
+ this.symbolTable.addFunction(token, this.getCurrentFile(), this.getExecutor(), functionName, funcDefinedParameters);
11
+ }
12
+ }
13
+ }
14
+ exports.SymbolValidatorResolveVisitor = SymbolValidatorResolveVisitor;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SymbolValidatorVisitor = void 0;
4
+ const builtinMethods_js_1 = require("../builtinMethods.js");
5
+ const types_js_1 = require("../objects/types.js");
6
+ const SymbolTable_js_1 = require("./SymbolTable.js");
7
+ const BaseVisitor_js_1 = require("../BaseVisitor.js");
8
+ const globals_js_1 = require("../globals.js");
9
+ class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.symbolTable = new SymbolTable_js_1.SymbolTable();
13
+ this.filePathStack = [];
14
+ this.visitImport_expr = (ctx) => {
15
+ const ID = ctx.ID().toString();
16
+ const { pathExists } = this.handleImportFile(ID, false, ctx);
17
+ if (!pathExists) {
18
+ this.symbolTable.addUndefined(this.getCurrentFile(), this.getExecutor(), ID, ctx.ID().getSymbol());
19
+ }
20
+ };
21
+ this.visitAssignment_expr = (ctx) => {
22
+ const ctxDataExpr = ctx.data_expr();
23
+ this.visit(ctxDataExpr);
24
+ const value = this.getResult(ctxDataExpr);
25
+ const atomId = ctx.atom_expr().ID(0);
26
+ const atomText = atomId.getText();
27
+ const executor = this.getExecutor();
28
+ if (!this.symbolTable.exists(executor, atomText)) {
29
+ this.addSymbolVariable(atomId.getSymbol(), atomId.getText(), value);
30
+ }
31
+ else {
32
+ const tmpSymbol = this.symbolTable.get(executor, atomText);
33
+ this.addSymbolInstance(tmpSymbol, atomId.getSymbol());
34
+ }
35
+ return null;
36
+ };
37
+ this.visitAtom_expr = (ctx) => {
38
+ const tmpSymbol = this.handleAtomSymbol(ctx.ID(0));
39
+ this.setResult(ctx, tmpSymbol);
40
+ };
41
+ this.visitFunction_call_expr = (ctx) => {
42
+ this.handleAtomSymbol(ctx.ID());
43
+ if (ctx.trailer_expr().length > 0) {
44
+ ctx.trailer_expr().forEach(item => {
45
+ if (item.OPEN_PAREN() && item.CLOSE_PAREN()) {
46
+ const params = item.parameters();
47
+ if (params) {
48
+ this.visit(params);
49
+ }
50
+ }
51
+ });
52
+ }
53
+ };
54
+ this.visitValueAtomExpr = (ctx) => {
55
+ let value = null;
56
+ const ctxValueExpr = ctx.value_expr();
57
+ const cxtAtomExpr = ctx.atom_expr();
58
+ if (ctxValueExpr) {
59
+ this.visit(ctxValueExpr);
60
+ value = this.getResult(ctxValueExpr);
61
+ }
62
+ else if (cxtAtomExpr) {
63
+ this.visit(cxtAtomExpr);
64
+ value = this.getResult(cxtAtomExpr);
65
+ }
66
+ this.setResult(ctx, value);
67
+ };
68
+ this.visitUnaryOperatorExpr = (ctx) => {
69
+ this.visit(ctx.data_expr());
70
+ };
71
+ this.visitMultiplyExpr = (ctx) => {
72
+ this.visit(ctx.data_expr(0));
73
+ this.visit(ctx.data_expr(1));
74
+ };
75
+ this.visitAdditionExpr = (ctx) => {
76
+ this.visit(ctx.data_expr(0));
77
+ this.visit(ctx.data_expr(1));
78
+ };
79
+ this.visitBinaryOperatorExpr = (ctx) => {
80
+ this.visit(ctx.data_expr(0));
81
+ this.visit(ctx.data_expr(1));
82
+ };
83
+ this.visitDataExpr = (ctx) => {
84
+ return;
85
+ };
86
+ this.visitFunction_def_expr = (ctx) => {
87
+ const functionName = ctx.ID().getText();
88
+ let funcDefinedParameters = [];
89
+ const ctxFunctionArgsExpr = ctx.function_args_expr();
90
+ if (ctxFunctionArgsExpr) {
91
+ this.visit(ctxFunctionArgsExpr);
92
+ funcDefinedParameters = this.getResult(ctxFunctionArgsExpr);
93
+ }
94
+ this.addSymbolFunction(ctx.ID().getSymbol(), functionName, funcDefinedParameters);
95
+ const executionContextName = functionName + globals_js_1.SymbolValidatorContext;
96
+ const passedInParamsNull = funcDefinedParameters.map((param, index) => {
97
+ return ['position', index, null];
98
+ });
99
+ const newExecutor = this.enterNewChildContext(this.executionStack, this.getExecutor(), executionContextName, { netNamespace: "" }, funcDefinedParameters, passedInParamsNull);
100
+ funcDefinedParameters.forEach(param => {
101
+ this.addSymbolVariable(param[1], param[0], null, newExecutor);
102
+ });
103
+ this.runExpressions(newExecutor, ctx.function_expr());
104
+ this.executionStack.pop();
105
+ };
106
+ }
107
+ enterFile(filePath) {
108
+ this.filePathStack.push(filePath);
109
+ }
110
+ exitFile() {
111
+ this.filePathStack.pop();
112
+ }
113
+ getCurrentFile() {
114
+ return this.filePathStack[this.filePathStack.length - 1];
115
+ }
116
+ addSymbolVariable(token, name, value, executor = null) {
117
+ const useExecutor = executor === null ? this.getExecutor() : executor;
118
+ this.symbolTable.addVariable(token, this.getCurrentFile(), useExecutor, name, value);
119
+ this.log2('add symbol variable: ' + name);
120
+ }
121
+ addSymbolFunction(token, functionName, funcDefinedParameters) {
122
+ if (!this.symbolTable.exists(this.getExecutor(), functionName)) {
123
+ this.symbolTable.addFunction(token, this.getCurrentFile(), this.getExecutor(), functionName, funcDefinedParameters);
124
+ this.log2('add symbol function: ' + functionName);
125
+ }
126
+ }
127
+ handleAtomSymbol(atom) {
128
+ const atomId = atom.getText();
129
+ const executor = this.getExecutor();
130
+ let tmpSymbol;
131
+ if (this.symbolTable.exists(executor, atomId)) {
132
+ tmpSymbol = this.symbolTable.get(executor, atomId);
133
+ }
134
+ else {
135
+ if (builtinMethods_js_1.buildInMethodNamesList.indexOf(atomId) !== -1) {
136
+ tmpSymbol = this.symbolTable.addFunction(null, "<builtIn>", this.getRootExecutor(), atomId, {});
137
+ }
138
+ else {
139
+ const foundContext = this.symbolTable.searchParentContext(executor, atomId);
140
+ if (foundContext === null) {
141
+ tmpSymbol = this.symbolTable.addUndefined(this.getCurrentFile(), executor, atomId, atom.getSymbol());
142
+ this.log2('symbol not found: ' + atomId);
143
+ }
144
+ else {
145
+ tmpSymbol = this.symbolTable.get(foundContext, atomId);
146
+ }
147
+ }
148
+ }
149
+ if (tmpSymbol.type !== types_js_1.ParseSymbolType.Undefined) {
150
+ this.addSymbolInstance(tmpSymbol, atom.getSymbol());
151
+ }
152
+ return tmpSymbol;
153
+ }
154
+ addSymbolInstance(symbol, token) {
155
+ symbol = symbol;
156
+ if (symbol.instances.indexOf(token) == -1) {
157
+ symbol.instances.push(token);
158
+ }
159
+ }
160
+ setSymbols(symbolTable) {
161
+ this.symbolTable = symbolTable;
162
+ }
163
+ getSymbols() {
164
+ return this.symbolTable;
165
+ }
166
+ dumpSymbols() {
167
+ this.symbolTable.dumpSymbols();
168
+ }
169
+ }
170
+ exports.SymbolValidatorVisitor = SymbolValidatorVisitor;
@@ -1,81 +1,89 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.validate = void 0;
8
4
  const commander_1 = require("commander");
9
- const figlet_1 = __importDefault(require("figlet"));
10
- const path_1 = __importDefault(require("path"));
11
5
  const fs_1 = require("fs");
12
- const sizing_js_1 = require("./sizing.js");
13
6
  const helpers_js_1 = require("./helpers.js");
7
+ const environment_js_1 = require("./environment.js");
8
+ const types_js_1 = require("./objects/types.js");
14
9
  async function validate() {
15
- const { filePath } = (0, helpers_js_1.getCurrentPath)();
16
- const toolSrcPath = filePath;
17
- const toolDirectory = path_1.default.dirname(toolSrcPath) + '/../../';
18
- const fontsPath = toolDirectory + '/fonts';
19
- const defaultLibsPath = toolDirectory + '/libs';
20
- const packageJson = JSON.parse((0, fs_1.readFileSync)(toolDirectory + 'package.json').toString());
21
- ;
22
- const { version } = packageJson;
10
+ const env = new environment_js_1.NodeScriptEnvironment();
11
+ environment_js_1.NodeScriptEnvironment.setInstance(env);
12
+ const version = env.getPackageVersion();
23
13
  commander_1.program
24
- .description('generate graphical output from circuitscript files')
14
+ .description('generate validation output circuitscript files')
25
15
  .version(version)
16
+ .argument('[input path]', 'Input path')
17
+ .argument('[output path]', 'Output path')
26
18
  .option('-i, --input text <input text>', 'Input text directly')
27
- .option('-f, --input-file <path>', 'Input file')
28
- .option('-o, --output <path>', 'Output path')
29
19
  .option('-c, --current-directory <path>', 'Set current directory')
30
- .option('-k, --kicad-netlist <filename>', 'Create KiCad netlist')
31
20
  .option('-w, --watch', 'Watch for file changes')
32
21
  .option('-n, --dump-nets', 'Dump out net information')
33
22
  .option('-d, --dump-data', 'Dump data during parsing')
34
- .option('-s, --stats', 'Show stats during generation');
35
- commander_1.program.addHelpText('before', figlet_1.default.textSync('circuitscript', {
36
- font: 'Small Slant'
37
- }));
23
+ .option('-s, --stats', 'Show stats during generation')
24
+ .option('-x, --skip-output', 'Skip output generation');
38
25
  if (process.argv.length < 3) {
39
26
  commander_1.program.help();
40
27
  }
41
28
  commander_1.program.parse();
42
29
  const options = commander_1.program.opts();
30
+ const args = commander_1.program.args;
43
31
  const watchFileChanges = options.watch;
44
- const outputPath = options.output ?? null;
45
32
  const dumpNets = options.dumpNets;
46
33
  const dumpData = options.dumpData;
47
- const kicadNetlist = options.kicadNetlist;
48
- let currentDirectory = options.currentDirectory ?? null;
34
+ if (options.currentDirectory) {
35
+ env.setModuleDirectory(options.currentDirectory);
36
+ }
49
37
  if (watchFileChanges) {
50
38
  console.log('watching for file changes...');
51
39
  }
52
- await (0, sizing_js_1.prepareSVGEnvironment)(fontsPath);
53
- let inputFilePath = null;
40
+ await env.prepareSVGEnvironment();
41
+ let inputFilePath = "";
42
+ if (args.length > 2) {
43
+ console.log("Error: Extra arguments passed");
44
+ return;
45
+ }
54
46
  let scriptData;
55
- if (options.input) {
47
+ if (args.length > 0 && args[0]) {
48
+ inputFilePath = args[0];
49
+ if ((0, fs_1.existsSync)(inputFilePath)) {
50
+ scriptData = (0, fs_1.readFileSync)(inputFilePath, { encoding: 'utf-8' });
51
+ }
52
+ else {
53
+ console.error("Error: File could not be found");
54
+ return;
55
+ }
56
+ }
57
+ else if (options.input) {
56
58
  scriptData = options.input;
57
59
  }
58
60
  else {
59
- inputFilePath = options.inputFile;
60
- const tmpScriptData = (0, helpers_js_1.getScriptText)(inputFilePath);
61
- if (tmpScriptData === null) {
62
- throw "File does not exists";
63
- }
64
- scriptData = tmpScriptData;
65
- if (currentDirectory === null) {
66
- currentDirectory = path_1.default.dirname(inputFilePath);
67
- }
61
+ console.error("Error: No input provided");
62
+ return;
68
63
  }
69
64
  const scriptOptions = {
70
- currentDirectory,
71
- defaultLibsPath,
72
65
  dumpNets,
73
66
  dumpData,
74
- kicadNetlistPath: kicadNetlist,
75
67
  showStats: options.stats,
68
+ environment: env,
76
69
  };
77
- const visitor = (0, helpers_js_1.validateScript)(scriptData, scriptOptions);
78
- const semanticTokensVisitor = (0, helpers_js_1.getSemanticTokens)(scriptData, scriptOptions);
70
+ const visitor = await (0, helpers_js_1.validateScript)(inputFilePath, scriptData, scriptOptions);
71
+ const symbols = visitor.getSymbols().getSymbols();
72
+ symbols.forEach((value, key) => {
73
+ if (value.type !== types_js_1.ParseSymbolType.Undefined) {
74
+ value = value;
75
+ const token = value.token;
76
+ console.log(key, value.fileName, token !== null ? (token.line + ":" + token.column) : "");
77
+ value.instances.forEach(instance => {
78
+ console.log(" " + instance.line + ":" + instance.column + " " + instance.start);
79
+ });
80
+ }
81
+ });
82
+ const { parsedTokens } = await (0, helpers_js_1.getSemanticTokens)(scriptData, scriptOptions);
83
+ parsedTokens.forEach(item => {
84
+ const { line, column, tokenType, tokenModifiers, textValue } = item;
85
+ console.log(`${line}:${column} - ${textValue} - ${tokenType} | ${tokenModifiers.join(',')}`);
86
+ });
79
87
  }
80
- exports.validate = validate;
88
+ exports.default = validate;
81
89
  validate();