Skip to content

Commit

Permalink
fix(parser): parse global properties (K objects)
Browse files Browse the repository at this point in the history
fixes the pin label color issue: #2 (comment)
  • Loading branch information
urish committed Mar 14, 2024
1 parent b0eeac0 commit 0b68cc8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ export class SVGRenderer extends EventTarget {
break;
}

case 'GlobalProperties':
Object.assign(properties, item.properties);
break;

case 'Version':
case 'Netlisting':
case 'Verilog':
case 'Spice':
case 'VHDL':
Expand Down
6 changes: 3 additions & 3 deletions src/xschem-parser.peg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Object
/ Verilog
/ VHDL
/ TEDAx
/ Netlisting
/ GlobalProperties
/ EmbeddedSymbol

Spice
Expand All @@ -56,8 +56,8 @@ VHDL
TEDAx
= "E" _ content:CurlyBracedString { return { type: "TEDAx", content }; }

Netlisting
= "K" _ content:CurlyBracedString { return { type: "Netlisting", content }; }
GlobalProperties
= "K" _ properties:Properties { return { type: "GlobalProperties", properties }; }

CurlyBracedString
= "{" _ content:(Escape / NotEscape)* "}" {
Expand Down
17 changes: 10 additions & 7 deletions src/xschem-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ const peggyParser: { parse: any; SyntaxError: any; DefaultTracer?: any } = // Ge
return { type: 'TEDAx', content };
}; // @ts-ignore

var peg$f10 = function (content) {
var peg$f10 = function (properties) {
// @ts-ignore
return { type: 'Netlisting', content };
return { type: 'GlobalProperties', properties };
}; // @ts-ignore

var peg$f11 = function (content) {
Expand Down Expand Up @@ -1419,7 +1419,7 @@ const peggyParser: { parse: any; SyntaxError: any; DefaultTracer?: any } = // Ge
// @ts-ignore
if (s0 === peg$FAILED) {
// @ts-ignore
s0 = peg$parseNetlisting();
s0 = peg$parseGlobalProperties();
// @ts-ignore
if (s0 === peg$FAILED) {
// @ts-ignore
Expand Down Expand Up @@ -1659,7 +1659,7 @@ const peggyParser: { parse: any; SyntaxError: any; DefaultTracer?: any } = // Ge

// @ts-ignore
function // @ts-ignore
peg$parseNetlisting() {
peg$parseGlobalProperties() {
// @ts-ignore
var s0, s1, s2, s3;

Expand All @@ -1685,7 +1685,7 @@ const peggyParser: { parse: any; SyntaxError: any; DefaultTracer?: any } = // Ge
// @ts-ignore
s2 = peg$parse_();
// @ts-ignore
s3 = peg$parseCurlyBracedString();
s3 = peg$parseProperties();
// @ts-ignore
if (s3 !== peg$FAILED) {
// @ts-ignore
Expand Down Expand Up @@ -4149,13 +4149,16 @@ export type Object_1 =
| Verilog
| VHDL
| TEDAx
| Netlisting
| GlobalProperties
| EmbeddedSymbol;
export type Spice = { type: 'Spice'; content: CurlyBracedString };
export type Verilog = { type: 'Verilog'; content: CurlyBracedString };
export type VHDL = { type: 'VHDL'; content: CurlyBracedString };
export type TEDAx = { type: 'TEDAx'; content: CurlyBracedString };
export type Netlisting = { type: 'Netlisting'; content: CurlyBracedString };
export type GlobalProperties = {
type: 'GlobalProperties';
properties: Properties;
};
export type CurlyBracedString = string;
export type Escape = '\\' | '{' | '}';
export type NotEscape = string;
Expand Down

0 comments on commit 0b68cc8

Please sign in to comment.