circuitscript 0.0.24 → 0.0.25
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/dist/cjs/BaseVisitor.js +487 -0
- package/dist/cjs/SemanticTokenVisitor.js +218 -0
- package/dist/cjs/SymbolValidatorVisitor.js +233 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +209 -195
- package/dist/cjs/antlr/CircuitScriptParser.js +2310 -2087
- package/dist/cjs/antlr/CircuitScriptVisitor.js +4 -3
- package/dist/cjs/draw_symbols.js +67 -22
- package/dist/cjs/execute.js +51 -53
- package/dist/cjs/geometry.js +28 -8
- package/dist/cjs/helpers.js +175 -5
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/layout.js +8 -0
- package/dist/cjs/lexer.js +19 -22
- package/dist/cjs/main.js +6 -11
- package/dist/cjs/objects/ClassComponent.js +3 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/objects/types.js +7 -1
- package/dist/cjs/parser.js +29 -258
- package/dist/cjs/validate.js +81 -0
- package/dist/cjs/visitor.js +529 -820
- package/dist/esm/BaseVisitor.mjs +488 -0
- package/dist/esm/SemanticTokenVisitor.mjs +215 -0
- package/dist/esm/SymbolValidatorVisitor.mjs +222 -0
- package/dist/esm/antlr/CircuitScriptLexer.mjs +184 -194
- package/dist/esm/antlr/CircuitScriptParser.mjs +2279 -2084
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +8 -3
- package/dist/esm/draw_symbols.mjs +67 -22
- package/dist/esm/execute.mjs +50 -52
- package/dist/esm/geometry.mjs +28 -8
- package/dist/esm/helpers.mjs +165 -6
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/layout.mjs +8 -0
- package/dist/esm/lexer.mjs +10 -10
- package/dist/esm/main.mjs +7 -12
- package/dist/esm/objects/ClassComponent.mjs +3 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -0
- package/dist/esm/objects/types.mjs +6 -0
- package/dist/esm/parser.mjs +25 -230
- package/dist/esm/validate.mjs +74 -0
- package/dist/esm/visitor.mjs +343 -640
- package/dist/types/BaseVisitor.d.ts +69 -0
- package/dist/types/SemanticTokenVisitor.d.ts +36 -0
- package/dist/types/SymbolValidatorVisitor.d.ts +61 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +8 -7
- package/dist/types/antlr/CircuitScriptParser.d.ts +513 -469
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +69 -59
- package/dist/types/draw_symbols.d.ts +9 -0
- package/dist/types/execute.d.ts +5 -8
- package/dist/types/geometry.d.ts +4 -0
- package/dist/types/helpers.d.ts +32 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lexer.d.ts +2 -2
- package/dist/types/objects/ExecutionScope.d.ts +4 -1
- package/dist/types/objects/types.d.ts +5 -0
- package/dist/types/parser.d.ts +15 -28
- package/dist/types/validate.d.ts +2 -0
- package/dist/types/visitor.d.ts +40 -95
- package/fonts/Inter-Bold.ttf +0 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/OpenSans-Regular.ttf +0 -0
- package/fonts/Roboto-Regular.ttf +0 -0
- package/libs/lib.cst +183 -0
- package/package.json +11 -6
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import figlet from 'figlet';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { prepareSVGEnvironment } from './sizing.mjs';
|
|
7
|
+
import { getCurrentPath, getScriptText, getSemanticTokens, validateScript } from './helpers.mjs';
|
|
8
|
+
export async function validate() {
|
|
9
|
+
const { filePath } = getCurrentPath();
|
|
10
|
+
const toolSrcPath = filePath;
|
|
11
|
+
const toolDirectory = path.dirname(toolSrcPath) + '/../../';
|
|
12
|
+
const fontsPath = toolDirectory + '/fonts';
|
|
13
|
+
const defaultLibsPath = toolDirectory + '/libs';
|
|
14
|
+
const packageJson = JSON.parse(readFileSync(toolDirectory + 'package.json').toString());
|
|
15
|
+
;
|
|
16
|
+
const { version } = packageJson;
|
|
17
|
+
program
|
|
18
|
+
.description('generate graphical output from circuitscript files')
|
|
19
|
+
.version(version)
|
|
20
|
+
.option('-i, --input text <input text>', 'Input text directly')
|
|
21
|
+
.option('-f, --input-file <path>', 'Input file')
|
|
22
|
+
.option('-o, --output <path>', 'Output path')
|
|
23
|
+
.option('-c, --current-directory <path>', 'Set current directory')
|
|
24
|
+
.option('-k, --kicad-netlist <filename>', 'Create KiCad netlist')
|
|
25
|
+
.option('-w, --watch', 'Watch for file changes')
|
|
26
|
+
.option('-n, --dump-nets', 'Dump out net information')
|
|
27
|
+
.option('-d, --dump-data', 'Dump data during parsing')
|
|
28
|
+
.option('-s, --stats', 'Show stats during generation');
|
|
29
|
+
program.addHelpText('before', figlet.textSync('circuitscript', {
|
|
30
|
+
font: 'Small Slant'
|
|
31
|
+
}));
|
|
32
|
+
if (process.argv.length < 3) {
|
|
33
|
+
program.help();
|
|
34
|
+
}
|
|
35
|
+
program.parse();
|
|
36
|
+
const options = program.opts();
|
|
37
|
+
const watchFileChanges = options.watch;
|
|
38
|
+
const outputPath = options.output ?? null;
|
|
39
|
+
const dumpNets = options.dumpNets;
|
|
40
|
+
const dumpData = options.dumpData;
|
|
41
|
+
const kicadNetlist = options.kicadNetlist;
|
|
42
|
+
let currentDirectory = options.currentDirectory ?? null;
|
|
43
|
+
if (watchFileChanges) {
|
|
44
|
+
console.log('watching for file changes...');
|
|
45
|
+
}
|
|
46
|
+
await prepareSVGEnvironment(fontsPath);
|
|
47
|
+
let inputFilePath = null;
|
|
48
|
+
let scriptData;
|
|
49
|
+
if (options.input) {
|
|
50
|
+
scriptData = options.input;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
inputFilePath = options.inputFile;
|
|
54
|
+
const tmpScriptData = getScriptText(inputFilePath);
|
|
55
|
+
if (tmpScriptData === null) {
|
|
56
|
+
throw "File does not exists";
|
|
57
|
+
}
|
|
58
|
+
scriptData = tmpScriptData;
|
|
59
|
+
if (currentDirectory === null) {
|
|
60
|
+
currentDirectory = path.dirname(inputFilePath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const scriptOptions = {
|
|
64
|
+
currentDirectory,
|
|
65
|
+
defaultLibsPath,
|
|
66
|
+
dumpNets,
|
|
67
|
+
dumpData,
|
|
68
|
+
kicadNetlistPath: kicadNetlist,
|
|
69
|
+
showStats: options.stats,
|
|
70
|
+
};
|
|
71
|
+
const visitor = validateScript(scriptData, scriptOptions);
|
|
72
|
+
const semanticTokensVisitor = getSemanticTokens(scriptData, scriptOptions);
|
|
73
|
+
}
|
|
74
|
+
validate();
|