Skip to content

Commit

Permalink
fix: Fixed parser problem where the name clause of a part property ov…
Browse files Browse the repository at this point in the history
…er-wrote part names and caused errors in the generated SKiDL code.
  • Loading branch information
devbisme committed Mar 23, 2022
1 parent e252a68 commit af0f985
Show file tree
Hide file tree
Showing 6 changed files with 855 additions and 73 deletions.
2 changes: 1 addition & 1 deletion kinparse/kinparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _paren_clause(keyword, subclause):
datasheet = _paren_clause('datasheet', anystring('datasheet'))
field = Group(_paren_clause('field', name & anystring('value')))
fields = _paren_clause('fields', ZeroOrMore(field)('fields'))
property = _paren_clause('property', name & value)
property = Group(_paren_clause('property', name & value))
properties = OneOrMore(property)('properties')
lib = _paren_clause('lib', anystring('lib'))
part = _paren_clause('part', anystring('name'))
Expand Down
98 changes: 98 additions & 0 deletions tests/data/kicad5_test.net
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
(export (version D)
(design
(source /home/devb/tech_stuff/KiCad/tools/kinparse/tests/data/kicad5_test.sch)
(date "Tue 22 Mar 2022 05:12:36 PM EDT")
(tool "Eeschema 5.1.12-84ad8e8a86~92~ubuntu20.04.1")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title "title")
(company "company")
(rev "1.0")
(date "03/23/2022")
(source kicad5_test.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref Q1)
(value Q_NPN_CBE)
(datasheet ~)
(libsource (lib Device) (part Q_NPN_CBE) (description "NPN transistor, collector/base/emitter"))
(sheetpath (names /) (tstamps /))
(tstamp 623A135E))
(comp (ref R4)
(value R_US)
(datasheet ~)
(libsource (lib Device) (part R_US) (description "Resistor, US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 623A1A21))
(comp (ref R5)
(value R_US)
(datasheet ~)
(libsource (lib Device) (part R_US) (description "Resistor, US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 623A2D4A))
(comp (ref R2)
(value R_US)
(datasheet ~)
(libsource (lib Device) (part R_US) (description "Resistor, US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 623A35E2))
(comp (ref R3)
(value R_US)
(datasheet ~)
(libsource (lib Device) (part R_US) (description "Resistor, US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 623A42C8))
(comp (ref R1)
(value R_US)
(datasheet ~)
(libsource (lib Device) (part R_US) (description "Resistor, US symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 623A4BDC)))
(libparts
(libpart (lib Device) (part Q_NPN_CBE)
(description "NPN transistor, collector/base/emitter")
(docs ~)
(fields
(field (name Reference) Q)
(field (name Value) Q_NPN_CBE))
(pins
(pin (num 1) (name C) (type passive))
(pin (num 2) (name B) (type input))
(pin (num 3) (name E) (type passive))))
(libpart (lib Device) (part R_US)
(description "Resistor, US symbol")
(docs ~)
(footprints
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R_US))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive)))))
(libraries
(library (logical Device)
(uri /usr/share/kicad/library/Device.lib)))
(nets
(net (code 1) (name "Net-(Q1-Pad2)")
(node (ref R1) (pin 1))
(node (ref R3) (pin 1))
(node (ref R2) (pin 2))
(node (ref Q1) (pin 2)))
(net (code 2) (name "Net-(Q1-Pad3)")
(node (ref R5) (pin 1))
(node (ref Q1) (pin 3)))
(net (code 3) (name GND)
(node (ref R3) (pin 2))
(node (ref R5) (pin 2)))
(net (code 4) (name OUT)
(node (ref Q1) (pin 1))
(node (ref R4) (pin 2)))
(net (code 5) (name IN)
(node (ref R1) (pin 2)))
(net (code 6) (name +5V)
(node (ref R4) (pin 1))
(node (ref R2) (pin 1)))))
142 changes: 142 additions & 0 deletions tests/data/kicad5_test.sch
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L Device:Q_NPN_CBE Q1
U 1 1 623A135E
P 5500 3575
F 0 "Q1" H 5691 3621 50 0000 L CNN
F 1 "Q_NPN_CBE" H 5691 3530 50 0000 L CNN
F 2 "" H 5700 3675 50 0001 C CNN
F 3 "~" H 5500 3575 50 0001 C CNN
1 5500 3575
1 0 0 -1
$EndComp
$Comp
L Device:R_US R4
U 1 1 623A1A21
P 5600 3100
F 0 "R4" H 5668 3146 50 0000 L CNN
F 1 "R_US" H 5668 3055 50 0000 L CNN
F 2 "" V 5640 3090 50 0001 C CNN
F 3 "~" H 5600 3100 50 0001 C CNN
1 5600 3100
1 0 0 -1
$EndComp
$Comp
L Device:R_US R5
U 1 1 623A2D4A
P 5600 4075
F 0 "R5" H 5668 4121 50 0000 L CNN
F 1 "R_US" H 5668 4030 50 0000 L CNN
F 2 "" V 5640 4065 50 0001 C CNN
F 3 "~" H 5600 4075 50 0001 C CNN
1 5600 4075
1 0 0 -1
$EndComp
$Comp
L Device:R_US R2
U 1 1 623A35E2
P 5300 3100
F 0 "R2" H 5368 3146 50 0000 L CNN
F 1 "R_US" H 5368 3055 50 0000 L CNN
F 2 "" V 5340 3090 50 0001 C CNN
F 3 "~" H 5300 3100 50 0001 C CNN
1 5300 3100
1 0 0 -1
$EndComp
$Comp
L Device:R_US R3
U 1 1 623A42C8
P 5300 4075
F 0 "R3" H 5368 4121 50 0000 L CNN
F 1 "R_US" H 5368 4030 50 0000 L CNN
F 2 "" V 5340 4065 50 0001 C CNN
F 3 "~" H 5300 4075 50 0001 C CNN
1 5300 4075
1 0 0 -1
$EndComp
$Comp
L Device:R_US R1
U 1 1 623A4BDC
P 4950 3575
F 0 "R1" V 4745 3575 50 0000 C CNN
F 1 "R_US" V 4836 3575 50 0000 C CNN
F 2 "" V 4990 3565 50 0001 C CNN
F 3 "~" H 4950 3575 50 0001 C CNN
1 4950 3575
0 1 1 0
$EndComp
$Comp
L power:+5V #PWR0101
U 1 1 623A5A79
P 5600 2775
F 0 "#PWR0101" H 5600 2625 50 0001 C CNN
F 1 "+5V" H 5615 2948 50 0000 C CNN
F 2 "" H 5600 2775 50 0001 C CNN
F 3 "" H 5600 2775 50 0001 C CNN
1 5600 2775
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR0102
U 1 1 623A63AA
P 5600 4450
F 0 "#PWR0102" H 5600 4200 50 0001 C CNN
F 1 "GND" H 5605 4277 50 0000 C CNN
F 2 "" H 5600 4450 50 0001 C CNN
F 3 "" H 5600 4450 50 0001 C CNN
1 5600 4450
1 0 0 -1
$EndComp
Wire Wire Line
5600 2775 5600 2850
Wire Wire Line
5600 3250 5600 3325
Wire Wire Line
5600 4225 5600 4325
Wire Wire Line
5600 3775 5600 3925
Wire Wire Line
5100 3575 5300 3575
Wire Wire Line
5600 2850 5300 2850
Wire Wire Line
5300 2850 5300 2950
Wire Wire Line
5300 4325 5600 4325
Wire Wire Line
5300 3250 5300 3575
Wire Wire Line
5300 4225 5300 4325
Connection ~ 5600 2850
Wire Wire Line
5600 2850 5600 2950
Connection ~ 5300 3575
Wire Wire Line
5300 3575 5300 3925
Connection ~ 5600 4325
Wire Wire Line
5600 4325 5600 4450
Text GLabel 4800 3575 0 50 Input ~ 0
IN
Wire Wire Line
5600 3325 5875 3325
Connection ~ 5600 3325
Wire Wire Line
5600 3325 5600 3375
Text GLabel 5875 3325 2 50 Output ~ 0
OUT
$EndSCHEMATC
Loading

0 comments on commit af0f985

Please sign in to comment.