M lib/connectiongraph.ml => lib/connectiongraph.ml +1 -1
@@ 74,7 74,7 @@ module Netlist = struct
| Item.Pin (comp, pin) ->
if pin.name <> "~"
then comp.ref ^ "_pad_" ^ pin.name
- else comp.ref ^ "_" ^ (string_of_int pin.number)
+ else comp.ref ^ "_" ^ pin.number
| _ -> failwith "invalid driver"
let drivers nl net_name =
M lib/dune => lib/dune +1 -0
@@ 5,6 5,7 @@
(preprocess (pps ppx_deriving.show ppx_compare))
)
(menhir
+ (flags --trace)
(modules sch_legacy parse_lib parse_sexp))
(ocamllex lex_sch_legacy)
(ocamllex lex_tokenize)
M lib/lex_lib.mll => lib/lex_lib.mll +1 -0
@@ 19,6 19,7 @@ rule read =
| "$ENDFPLIST" { if is_at_bol lexbuf then FPLIST_END else STRING (lexeme lexbuf) }
| "DRAW" { if is_at_bol lexbuf then DRAW_START else STRING (lexeme lexbuf) }
| "ENDDRAW" { if is_at_bol lexbuf then DRAW_END else STRING (lexeme lexbuf) }
+ | "ALIAS" { if is_at_bol lexbuf then ALIAS else STRING (lexeme lexbuf) }
| 'F' (_ # space) ' ' { FIELD (lexeme lexbuf) }
| '\n' { new_line lexbuf; NEWLINE }
| space { read lexbuf }
M lib/parse_lib.mly => lib/parse_lib.mly +14 -5
@@ 5,6 5,7 @@
%token FPLIST_END
%token DRAW_START
%token DRAW_END
+%token ALIAS
%token <string> STRING
%token <string> FIELD
%token NEWLINE
@@ 48,18 49,24 @@ draw_line:
if typ = "X"
then
let name = List.nth args 0 in
- let number = int_of_string (List.nth args 1) in
+ let number = List.nth args 1 in
let posx = int_of_string (List.nth args 2) in
let posy = int_of_string (List.nth args 3) in
(*Printf.eprintf "PIN: %s @ %d x %d\n" (String.concat " " args) posx posy;*)
- Some {Pin.
+ let p = {Pin.
name;
number;
pos={x=posx; y=posy};
- }
- else None
+ } in
+ Printf.eprintf "pin: %s\n" (Pin.show p);
+ Some p
+ else (Printf.eprintf "no pin: %s: %s\n" typ (String.concat " " args); None)
}
+aliasline:
+ | {[]}
+ | ALIAS; aliases=list(STRING); NEWLINE; {aliases}
+
component:
| COMPDEF_START;
name=STRING;
@@ 73,6 80,7 @@ component:
option_flag=STRING;
NEWLINE;
list(field);
+ aliases=aliasline;
option(fplist);
DRAW_START; NEWLINE;
draw_pins=list(draw_line);
@@ 83,6 91,7 @@ component:
name;
pins = collect_some draw_pins;
power = String.uppercase_ascii option_flag = "P";
+ aliases;
}
}
@@ 95,5 104,5 @@ main:
}
| error {
Printf.printf "error j:%d\n" $startpos.pos_lnum;
- []
+ invalid_arg "error parsing partslib"
}
M lib/parser.ml => lib/parser.ml +1 -1
@@ 33,7 33,7 @@ let process p l printer filename =
ret
let format_compdeflist outch cd =
- Printf.fprintf outch "%s"
+ Printf.fprintf outch "COMPDEFS: %s"
(String.concat "\n---\n" (List.map Schematic.CompDef.show cd))
let ignore2 _ _ = ()
M lib/schematic.ml => lib/schematic.ml +2 -1
@@ 11,7 11,7 @@ end
module Pin = struct
type t = {
name : string;
- number : int;
+ number : string;
pos : point2i;
}
[@@deriving show]
@@ 22,6 22,7 @@ module CompDef = struct
name : string;
pins : Pin.t list;
power : bool;
+ aliases : string list;
}
[@@deriving show]
end
A test/data/parts_lib/small-cache.lib => test/data/parts_lib/small-cache.lib +249 -0
@@ 0,0 1,249 @@
+EESchema-LIBRARY Version 2.4
+#encoding utf-8
+#
+# Transistor_BJT_BC547
+#
+DEF Transistor_BJT_BC547 Q 0 0 Y N 1 F N
+F0 "Q" 200 75 50 H V L CNN
+F1 "Transistor_BJT_BC547" 200 0 50 H V L CNN
+F2 "Package_TO_SOT_THT:TO-92_Inline" 200 -75 50 H I L CIN
+F3 "" 0 0 50 H I L CNN
+ALIAS BC546 BC548 BC549 BC550 BC337 BC338
+$FPLIST
+ TO?92*
+$ENDFPLIST
+DRAW
+C 50 0 111 0 1 10 N
+P 2 0 1 0 0 0 25 0 N
+P 2 0 1 0 25 25 100 100 N
+P 3 0 1 0 25 -25 100 -100 100 -100 N
+P 3 0 1 20 25 75 25 -75 25 -75 N
+P 5 0 1 0 50 -70 70 -50 90 -90 50 -70 50 -70 F
+X C 1 100 200 100 D 50 50 1 1 P
+X B 2 -200 0 200 R 50 50 1 1 I
+X E 3 100 -200 100 U 50 50 1 1 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_1N4148DO35-7
+#
+DEF WasserMarschV2-eagle-import_1N4148DO35-7 D 0 40 Y Y 1 L N
+F0 "D" 100 19 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_1N4148DO35-7" 100 -91 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+T 0 -100 0 13 0 1 0 "SpiceOrder 1" Normal 0 C C
+T 0 100 0 13 0 1 0 "SpiceOrder 2" Normal 0 C C
+P 2 1 0 0 -50 -50 50 0 N
+P 2 1 0 0 -50 50 -50 -50 N
+P 2 1 0 0 50 0 -50 50 N
+P 2 1 0 0 50 0 50 -50 N
+P 2 1 0 0 50 50 50 0 N
+X A A -100 0 100 R 0 0 1 0 P
+X C C 100 0 100 L 0 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_78T
+#
+DEF WasserMarschV2-eagle-import_78T IC 0 40 Y Y 1 L N
+F0 "IC" -300 225 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_78T" -300 125 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+T 0 -80 -170 51 0 1 0 GND Normal 0 L B
+P 2 1 0 0 -300 -200 300 -200 N
+P 2 1 0 0 -300 100 -300 -200 N
+P 2 1 0 0 300 -200 300 100 N
+P 2 1 0 0 300 100 -300 100 N
+X VI 1 -400 0 100 R 50 50 1 0 I
+X GND 2 0 -300 100 U 50 0 1 0 P
+X VO 3 400 0 100 L 50 50 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_BC557
+#
+DEF WasserMarschV2-eagle-import_BC557 Q 0 40 Y Y 1 L N
+F0 "Q" -400 300 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_BC557" -400 200 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+S -10 -100 20 100 1 0 0 F
+P 2 1 0 0 20 58 82 66 N
+P 2 1 0 0 30 65 70 70 N
+P 2 1 0 0 45 75 60 75 N
+P 2 1 0 0 60 85 45 75 N
+P 2 1 0 0 60 95 30 65 N
+P 2 1 0 0 62 102 20 58 N
+P 2 1 0 0 70 70 60 85 N
+P 2 1 0 0 75 70 60 95 N
+P 2 1 0 0 82 66 62 102 N
+P 2 1 0 0 100 -100 20 -60 N
+P 2 1 0 0 100 100 71 83 N
+X B B -100 0 100 R 0 0 1 0 P
+X C C 100 -200 100 U 0 0 1 0 P
+X E E 100 200 100 D 0 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_BS170
+#
+DEF WasserMarschV2-eagle-import_BS170 Q 0 40 Y Y 1 L N
+F0 "Q" 200 100 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_BS170" 200 0 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+C 100 -75 10 1 0 16 N
+T 0 50 95 27 0 1 0 D Normal 0 L B
+T 0 -95 15 27 0 1 0 G Normal 0 L B
+T 0 45 -125 27 0 1 0 S Normal 0 L B
+S -10 -100 20 -50 1 0 0 F
+S -10 -35 20 35 1 0 0 F
+S -10 50 20 100 1 0 0 F
+P 2 1 0 0 -44 0 -100 0 N
+P 2 1 0 0 -44 0 -44 -100 N
+P 2 1 0 0 -44 95 -44 0 N
+P 2 1 0 0 20 -75 100 -75 N
+P 2 1 0 0 20 0 45 0 N
+P 2 1 0 0 20 0 70 15 N
+P 2 1 0 0 45 0 65 -5 N
+P 2 1 0 0 45 0 100 0 N
+P 2 1 0 0 65 5 45 0 N
+P 2 1 0 0 70 -15 20 0 N
+P 2 1 0 0 70 15 70 -15 N
+P 2 1 0 0 100 -75 100 -100 N
+P 2 1 0 0 100 0 100 -75 N
+P 2 1 0 0 100 75 21 75 N
+P 2 1 0 0 100 100 100 75 N
+X D D 100 200 100 D 0 0 1 0 P
+X G G -200 0 100 R 0 0 1 0 P
+X S S 100 -200 100 U 0 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_C-EU025-024X044
+#
+DEF WasserMarschV2-eagle-import_C-EU025-024X044 C 0 40 Y Y 1 L N
+F0 "C" 60 15 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_C-EU025-024X044" 60 -185 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+S -80 -80 80 -60 1 0 0 F
+S -80 -40 80 -20 1 0 0 F
+P 2 1 0 0 0 -100 0 -80 N
+P 2 1 0 0 0 0 0 -20 N
+X 1 1 0 100 100 D 0 0 1 0 P
+X 2 2 0 -200 100 U 0 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_DCJ0202
+#
+DEF WasserMarschV2-eagle-import_DCJ0202 J 0 40 Y Y 1 L N
+F0 "J" -100 150 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_DCJ0202" -100 -250 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+S -130 -100 -70 50 1 0 0 F
+P 2 1 0 0 -100 100 -100 50 N
+P 2 1 0 0 0 -40 -30 -100 N
+P 2 1 0 0 30 -100 0 -40 N
+P 2 1 0 0 100 -100 30 -100 N
+P 2 1 0 0 100 0 100 -100 N
+P 2 1 0 0 200 -100 100 -100 N
+P 2 1 0 0 200 0 100 0 N
+P 2 1 0 0 200 100 -100 100 N
+P 3 1 0 0 100 -100 80 -50 120 -50 F
+X 1 1 300 100 100 L 50 0 1 0 P
+X 2 2 300 0 100 L 50 0 1 0 P
+X 3 3 300 -100 100 L 50 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_PINHD-1X2
+#
+DEF WasserMarschV2-eagle-import_PINHD-1X2 JP 0 40 Y Y 1 L N
+F0 "JP" -250 225 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_PINHD-1X2" -250 -200 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+P 2 1 0 0 -250 -100 50 -100 N
+P 2 1 0 0 -250 200 -250 -100 N
+P 2 1 0 0 50 -100 50 200 N
+P 2 1 0 0 50 200 -250 200 N
+X 1 1 -100 100 100 R 50 0 1 0 P I
+X 2 2 -100 0 100 R 50 0 1 0 P I
+ENDDRAW
+ENDDEF
+#
+# WasserMarschV2-eagle-import_R-EU_0309_12
+#
+DEF WasserMarschV2-eagle-import_R-EU_0309_12 R 0 40 Y Y 1 L N
+F0 "R" -150 59 59 H V L BNN
+F1 "WasserMarschV2-eagle-import_R-EU_0309_12" -150 -130 59 H V L BNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+P 2 1 0 0 -100 -35 -100 35 N
+P 2 1 0 0 -100 -35 100 -35 N
+P 2 1 0 0 100 -35 100 35 N
+P 2 1 0 0 100 35 -100 35 N
+X 1 1 -200 0 100 R 0 0 1 0 P
+X 2 2 200 0 100 L 0 0 1 0 P
+ENDDRAW
+ENDDEF
+#
+# power_+12V
+#
+DEF power_+12V #PWR 0 0 Y Y 1 F P
+F0 "#PWR" 0 -150 50 H I C CNN
+F1 "power_+12V" 0 140 50 H V C CNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+P 2 0 1 0 -30 50 0 100 N
+P 2 0 1 0 0 0 0 100 N
+P 2 0 1 0 0 100 30 50 N
+X +12V 1 0 0 0 U 50 50 1 1 W N
+ENDDRAW
+ENDDEF
+#
+# power_GND
+#
+DEF power_GND #PWR 0 0 Y Y 1 F P
+F0 "#PWR" 0 -250 50 H I C CNN
+F1 "power_GND" 0 -150 50 H V C CNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
+X GND 1 0 0 0 D 50 50 1 1 W N
+ENDDRAW
+ENDDEF
+#
+# pspice_VSOURCE
+#
+DEF pspice_VSOURCE V 0 40 Y Y 1 F N
+F0 "V" -250 300 50 H V C CNN
+F1 "pspice_VSOURCE" 0 0 50 H V C CNN
+F2 "" 0 0 50 H I C CNN
+F3 "" 0 0 50 H I C CNN
+DRAW
+C 0 0 200 0 1 0 N
+T 0 -320 -10 50 0 0 1 V Normal 0 C C
+P 2 0 1 0 -250 -250 -250 150 F
+P 3 0 1 0 -300 150 -250 250 -200 150 F
+X E1 1 0 300 100 D 50 50 1 1 I
+X E2 2 0 -300 100 U 50 50 1 1 I
+ENDDRAW
+ENDDEF
+#
+#End Library
M test/dune => test/dune +6 -0
@@ 5,6 5,12 @@
)
(test
+ (name test_parts_lib)
+ (modules test_parts_lib)
+ (libraries eeschema alcotest)
+ )
+
+(test
(name test_sexp)
(modules test_sexp)
(libraries eeschema alcotest)
A test/test_parts_lib.ml => test/test_parts_lib.ml +18 -0
@@ 0,0 1,18 @@
+open Eeschema
+
+let parse_lib filename =
+ let inch = open_in filename in
+ let lexbuf = Lexing.from_channel inch in
+ lexbuf.lex_curr_p <- { lexbuf.lex_curr_p with pos_fname = filename };
+ let ret = Parse_lib.main Lex_lib.read lexbuf in
+ ret
+
+let test () =
+ let lib = parse_lib "../../../test/data/parts_lib/small-cache.lib" in
+ Parser.format_compdeflist stdout lib
+
+
+let () =
+ Alcotest.run "parse_parts_lib" [
+ "all", ["small parts_lib", `Quick, test]
+ ]
M test/test_sexp.ml => test/test_sexp.ml +1 -1
@@ 11,7 11,7 @@ let pp_sexp fmt e =
let sexp = Alcotest.testable pp_sexp (fun a b -> a = b)
-let test () = let parsed = parse_sexp "test/data/sexp/sym-lib-table" in
+let test () = let parsed = parse_sexp "../../../test/data/sexp/sym-lib-table" in
let expected = (
Sexp.Sexp (Sexp.Atom "sym_lib_table", [
Sexp.Sexp (Sexp.Atom "lib", [