circuitscript 0.2.0 → 0.3.1

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.
@@ -4,7 +4,7 @@ import { ExecutionContext } from "./execute.js";
4
4
  import { Logger } from "./logger.js";
5
5
  import { ClassComponent } from "./objects/ClassComponent.js";
6
6
  import { Net } from "./objects/Net.js";
7
- import { CallableParameter, ComplexType, Direction, FunctionDefinedParameter, AnyReference, ImportedModule, NewContextOptions, ImportFunctionHandling as ImportFunctionHandling } from "./objects/types.js";
7
+ import { CallableParameter, ComplexType, Direction, FunctionDefinedParameter, AnyReference, ImportedLibrary, NewContextOptions, ImportFunctionHandling as ImportFunctionHandling } from "./objects/types.js";
8
8
  import { CommonTokenStream, ParserRuleContext } from 'antlr4ng';
9
9
  import { ExecutionWarning } from "./utils.js";
10
10
  import { BaseError } from './utils.js';
@@ -26,7 +26,7 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
26
26
  pinTypesList: string[];
27
27
  onErrorHandler: OnErrorHandler | null;
28
28
  environment: NodeScriptEnvironment;
29
- protected importedFiles: ImportFile[];
29
+ protected importedFiles: ImportLibraryFile[];
30
30
  protected warnings: ExecutionWarning[];
31
31
  onImportFile: (visitor: BaseVisitor, filePath: string, fileData: string, onErrorHandler: OnErrorHandler) => Promise<ImportFileResult>;
32
32
  refdesFileAnnotations: Map<string, string>;
@@ -73,8 +73,8 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
73
73
  protected linkComponentToCtx(ctx: ParserRuleContext, instance: ClassComponent, creationFlag?: boolean): void;
74
74
  getComponentCtxLinks(): Map<ParserRuleContext, ClassComponent>;
75
75
  visitResult(ctx: ParserRuleContext): any;
76
- protected handleImportFile(name: string, importHandling: ImportFunctionHandling, throwErrors?: boolean, ctx?: ParserRuleContext | null, specificImports?: string[]): Promise<ImportFile>;
77
- checkModuleHasRefdesFile(filePath: string): Promise<void>;
76
+ protected handleImportFile(name: string, importHandling: ImportFunctionHandling, throwErrors?: boolean, ctx?: ParserRuleContext | null, specificImports?: string[]): Promise<ImportLibraryFile>;
77
+ checkLibraryHasRefdesFile(filePath: string): Promise<void>;
78
78
  getRefdesFileAnnotation(filePath: string, startLine: number, startColumn: number, stopLine: number, stopColumn: number): string;
79
79
  visitRoundedBracketsExpr: (ctx: RoundedBracketsExprContext) => void;
80
80
  protected setupDefinedParameters(funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[], executor: ExecutionContext): void;
@@ -94,12 +94,12 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
94
94
  getCurrentFile(): string;
95
95
  }
96
96
  export type OnErrorHandler = (message: string, context: ParserRuleContext, e?: any) => void;
97
- type ImportFile = {
97
+ type ImportLibraryFile = {
98
98
  id: string;
99
99
  hasError: boolean;
100
100
  hasParseError: boolean;
101
101
  pathExists: boolean;
102
- importedModule: ImportedModule;
102
+ importedLibrary: ImportedLibrary;
103
103
  };
104
104
  export type ImportFileResult = {
105
105
  hasError: boolean;
@@ -895,7 +895,7 @@ export declare class Import_exprContext extends antlr.ParserRuleContext {
895
895
  copyFrom(ctx: Import_exprContext): void;
896
896
  }
897
897
  export declare class Import_specificContext extends Import_exprContext {
898
- _moduleName?: Token | null;
898
+ _libraryName?: Token | null;
899
899
  _ID?: Token | null;
900
900
  _funcNames: antlr.Token[];
901
901
  constructor(ctx: Import_exprContext);
@@ -907,7 +907,7 @@ export declare class Import_specificContext extends Import_exprContext {
907
907
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
908
908
  }
909
909
  export declare class Import_all_simpleContext extends Import_exprContext {
910
- _moduleName?: Token | null;
910
+ _libraryName?: Token | null;
911
911
  constructor(ctx: Import_exprContext);
912
912
  From(): antlr.TerminalNode;
913
913
  Import(): antlr.TerminalNode;
@@ -917,7 +917,7 @@ export declare class Import_all_simpleContext extends Import_exprContext {
917
917
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
918
918
  }
919
919
  export declare class Import_simpleContext extends Import_exprContext {
920
- _moduleName?: Token | null;
920
+ _libraryName?: Token | null;
921
921
  constructor(ctx: Import_exprContext);
922
922
  Import(): antlr.TerminalNode;
923
923
  ID(): antlr.TerminalNode;
@@ -76,7 +76,8 @@ export declare enum ComponentTypes {
76
76
  net = "net",
77
77
  graphic = "graphic",
78
78
  port = "port",
79
- module = "module"
79
+ module = "module",
80
+ resistor = "res"
80
81
  }
81
82
  export declare enum ReferenceTypes {
82
83
  function = "function",
@@ -84,7 +85,7 @@ export declare enum ReferenceTypes {
84
85
  variable = "variable",
85
86
  instance = "instance",
86
87
  pinType = "pinType",
87
- module = "module",
88
+ library = "library",
88
89
  unknown = "unknown"
89
90
  }
90
91
  export declare enum BlockTypes {
@@ -11,7 +11,7 @@ export type SVGWindow = any;
11
11
  import { NumericValue } from "./objects/ParamDefinition.js";
12
12
  import { NodeScriptEnvironment } from "./environment.js";
13
13
  import { ClassComponent } from "./objects/ClassComponent.js";
14
- import { ImportedModule } from "./objects/types.js";
14
+ import { ImportedLibrary } from "./objects/types.js";
15
15
  export declare enum JSModuleType {
16
16
  CommonJs = "cjs",
17
17
  ESM = "mjs"
@@ -47,7 +47,7 @@ type RenderScriptReturn = {
47
47
  errors: BaseError[];
48
48
  };
49
49
  export declare function renderScript(scriptData: string, outputPath: string | null, options: ScriptOptions): Promise<RenderScriptReturn>;
50
- export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[], postAnnotationCallbacks: ((options: ScriptOptions, scriptData: string, tree: ScriptContext, tokens: CommonTokenStream, componentLinks: Map<ParserRuleContext, ClassComponent>, importedModule: ImportedModule[], environment: NodeScriptEnvironment) => void)[]): Promise<RenderScriptReturn>;
50
+ export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[], postAnnotationCallbacks: ((options: ScriptOptions, scriptData: string, tree: ScriptContext, tokens: CommonTokenStream, componentLinks: Map<ParserRuleContext, ClassComponent>, importedLibraries: ImportedLibrary[], environment: NodeScriptEnvironment) => void)[]): Promise<RenderScriptReturn>;
51
51
  export declare abstract class ParseOutputHandler {
52
52
  beforeRender: boolean;
53
53
  afterRender: boolean;
@@ -1,6 +1,6 @@
1
1
  import { ClassComponent } from './ClassComponent.js';
2
2
  import { Net } from './Net.js';
3
- import { CFunction, CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ImportedModule, ParseSymbolType, ValueType } from './types.js';
3
+ import { CFunction, CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ImportedLibrary, ParseSymbolType, ValueType } from './types.js';
4
4
  import { BlockTypes, LayoutDirection } from '../globals.js';
5
5
  import { Wire, WireSegment } from './Wire.js';
6
6
  import { Frame } from './Frame.js';
@@ -19,7 +19,7 @@ export declare class ExecutionScope {
19
19
  symbols: Map<string, {
20
20
  type: ParseSymbolType;
21
21
  }>;
22
- modules: Map<string, ImportedModule>;
22
+ libraries: Map<string, ImportedLibrary>;
23
23
  blockStack: Map<number, BlockStackEntry>;
24
24
  contextStack: ParserRuleContext[];
25
25
  onPropertyHandler: OnPropertyHandler[];
@@ -108,32 +108,22 @@ export declare enum Direction {
108
108
  Down = "down",
109
109
  Up = "up"
110
110
  }
111
- export declare enum TypeProps {
112
- Net = "net",
113
- Port = "port",
114
- Graphic = "graphic",
115
- Module = "module",
116
- Resistor = "res",
117
- Capacitor = "cap",
118
- Inductor = "ind",
119
- Diode = "diode"
120
- }
121
111
  export declare enum NetTypes {
122
112
  Any = "any",
123
113
  Source = "source"
124
114
  }
125
- export declare class ImportedModule {
126
- moduleName: string;
115
+ export declare class ImportedLibrary {
116
+ libraryName: string;
127
117
  context: ExecutionContext;
128
118
  importHandlingFlag: ImportFunctionHandling;
129
119
  specifiedImports: string[];
130
- moduleNamespace: string;
131
- moduleFilePath: string;
120
+ libraryNamespace: string;
121
+ libraryFilePath: string;
132
122
  enableRefdesAnnotation: boolean;
133
123
  enableRefdesAnnotationFile: boolean;
134
124
  tree: ScriptContext;
135
125
  tokens: CommonTokenStream;
136
- constructor(moduleName: string, moduleNamespace: string, moduleFilePath: string, tree: ScriptContext, tokens: CommonTokenStream, context: ExecutionContext, flag: ImportFunctionHandling, specifiedImports: string[]);
126
+ constructor(libraryName: string, libraryNamespace: string, libraryFilePath: string, tree: ScriptContext, tokens: CommonTokenStream, context: ExecutionContext, flag: ImportFunctionHandling, specifiedImports: string[]);
137
127
  }
138
128
  export declare enum ImportFunctionHandling {
139
129
  AllWithNamespace = "all-with-namespace",
@@ -16,7 +16,7 @@ export declare class SymbolValidatorVisitor extends BaseVisitor {
16
16
  visitImport_simple: (ctx: Import_simpleContext) => Promise<void>;
17
17
  visitImport_all_simple: (ctx: Import_all_simpleContext) => Promise<void>;
18
18
  visitImport_specific: (ctx: Import_specificContext) => Promise<void>;
19
- private applyModuleImports;
19
+ private applyLibraryImports;
20
20
  visitAssignment_expr: (ctx: Assignment_exprContext) => ComplexType;
21
21
  visitAtom_expr: (ctx: Atom_exprContext) => void;
22
22
  visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
@@ -75,7 +75,7 @@ export declare class ParserVisitor extends BaseVisitor {
75
75
  visitPart_value_expr: (ctx: Part_value_exprContext) => void;
76
76
  visitPart_condition_expr: (ctx: Part_condition_exprContext) => void;
77
77
  visitPart_condition_key_only_expr: (ctx: Part_condition_key_only_exprContext) => void;
78
- checkModuleHasRefdesFile(filePath: string): Promise<void>;
78
+ checkLibraryHasRefdesFile(filePath: string): Promise<void>;
79
79
  private resolveDataExpr;
80
80
  private resolveDataValue;
81
81
  pinTypes: PinTypes[];
package/libs/std.cst CHANGED
@@ -428,4 +428,5 @@ def sheet_A6(revision="V1"):
428
428
  return tmp_sheet
429
429
 
430
430
  document.sheet_type = sheet_A4()
431
- document.bom.columns = ["refdes", "mpn", "manufacturer", "footprint"]
431
+ document.bom.columns = ["refdes", "mpn", "manufacturer", "footprint"]
432
+ document.bom.group_by = ["mpn", "manufacturer"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "circuitscript",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Interpreter for the circuitscript language",
5
5
  "homepage": "https://circuitscript.net",
6
6
  "engines": {