|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,147 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the Kicad Tools Software | |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | const char* add_net_c = "(add_net"; | |
|
23 | const char* area_c = "(area"; | |
|
24 | const char* at_c = "(at"; | |
|
25 | const char* attr_c = "(attr"; | |
|
26 | const char* center_c = "(center"; | |
|
27 | const char* clearance_c = "(clearance"; | |
|
28 | const char* code_c = "(code"; | |
|
29 | const char* component_c = "(component"; | |
|
30 | const char* components_c = "(components"; | |
|
31 | const char* date_c = "(date"; | |
|
32 | const char* design_c = "(design"; | |
|
33 | const char* drawings_c = "(drawings"; | |
|
34 | const char* drillshape_c = "(drillshape"; | |
|
35 | const char* edge_width_c = "(edge_width"; | |
|
36 | const char* effects_c = "(effects"; | |
|
37 | const char* end_c = "(end"; | |
|
38 | const char* excludeedgelayer_c = "(excludeedgelayer"; | |
|
39 | const char* export_c = "(export"; | |
|
40 | const char* field_c = "(field"; | |
|
41 | const char* fields_c = "(fields"; | |
|
42 | const char* font_c = "(font"; | |
|
43 | const char* fp_circle_c = "(fp_circle"; | |
|
44 | const char* fp_line_c = "(fp_line"; | |
|
45 | const char* fp_text_c = "(fp_text"; | |
|
46 | const char* general_c = "(general"; | |
|
47 | const char* host_c = "(host"; | |
|
48 | const char* hpglpendiameter_c = "(hpglpendiameter"; | |
|
49 | const char* hpglpennumber_c = "(hpglpennumber"; | |
|
50 | const char* hpglpenoverlay_c = "(hpglpenoverlay"; | |
|
51 | const char* hpglpenspeed_c = "(hpglpenspeed"; | |
|
52 | const char* last_trace_width_c = "(last_trace_width"; | |
|
53 | const char* layers_c = "(layers"; | |
|
54 | const char* layerselection_c = "(layerselection"; | |
|
55 | const char* lib_c = "(lib"; | |
|
56 | const char* libpart_c = "(libpart"; | |
|
57 | const char* libparts_c = "(libparts"; | |
|
58 | const char* libraries_c = "(libraries"; | |
|
59 | const char* library_c = "(library"; | |
|
60 | const char* libsource_c = "(libsource"; | |
|
61 | const char* linewidth_c = "(linewidth"; | |
|
62 | const char* links_c = "(links"; | |
|
63 | const char* logical_c = "(logical"; | |
|
64 | const char* mirror_c = "(mirror"; | |
|
65 | const char* mod_edge_width_c = "(mod_edge_width"; | |
|
66 | const char* mod_text_size_c = "(mod_text_size"; | |
|
67 | const char* mode_c = "(mode"; | |
|
68 | const char* model_c = "(model"; | |
|
69 | const char* module_c = "(module"; | |
|
70 | const char* modules_c = "(modules"; | |
|
71 | const char* name_c = "(name"; | |
|
72 | const char* names_c = "(names"; | |
|
73 | const char* net_c = "(net"; | |
|
74 | const char* net_class_c = "(net_class"; | |
|
75 | const char* nets_c = "(nets"; | |
|
76 | const char* no_connect_c = "(no_connect"; | |
|
77 | const char* node_c = "(node"; | |
|
78 | const char* num_c = "(num"; | |
|
79 | const char* outputdirectory_c = "(outputdirectory"; | |
|
80 | const char* outputformat_c = "(outputformat"; | |
|
81 | const char* pad_c = "(pad"; | |
|
82 | const char* pad_drill_c = "(pad_drill"; | |
|
83 | const char* pad_size_c = "(pad_size"; | |
|
84 | const char* pad_to_mask_clearance_c = "(pad_to_mask_clearance"; | |
|
85 | const char* padsonsilk_c = "(padsonsilk"; | |
|
86 | const char* page_c = "(page"; | |
|
87 | const char* part_c = "(part"; | |
|
88 | const char* path_c = "(path"; | |
|
89 | const char* pcb_text_size_c = "(pcb_text_size"; | |
|
90 | const char* pcb_text_width_c = "(pcb_text_width"; | |
|
91 | const char* pcbplotparams_c = "(pcbplotparams"; | |
|
92 | const char* pin_c = "(pin"; | |
|
93 | const char* pins_c = "(pins"; | |
|
94 | const char* plotframeref_c = "(plotframeref"; | |
|
95 | const char* plotinvisibletext_c = "(plotinvisibletext"; | |
|
96 | const char* plotothertext_c = "(plotothertext"; | |
|
97 | const char* plotreference_c = "(plotreference"; | |
|
98 | const char* plotvalue_c = "(plotvalue"; | |
|
99 | const char* psa4output_c = "(psa4output"; | |
|
100 | const char* psnegative_c = "(psnegative"; | |
|
101 | const char* ref_c = "(ref"; | |
|
102 | const char* rotate = "(rota"; | |
|
103 | const char* scale_c = "(scale"; | |
|
104 | const char* scaleselection_c = "(scaleselection"; | |
|
105 | const char* segment_width_c = "(segment_width"; | |
|
106 | const char* setup_c = "(setup"; | |
|
107 | const char* sheetpath_c = "(sheetpath"; | |
|
108 | const char* source_c = "(source"; | |
|
109 | const char* start_c = "(start"; | |
|
110 | const char* subtractmaskfromsilk_c = "(subtractmaskfromsilk"; | |
|
111 | const char* tags_c = "(tags"; | |
|
112 | const char* tedit_c = "(tedit"; | |
|
113 | const char* thickness_c = "(thickness"; | |
|
114 | const char* tool_c = "(tool"; | |
|
115 | const char* trace_clearance_c = "(trace_clearance"; | |
|
116 | const char* trace_min_c = "(trace_min"; | |
|
117 | const char* trace_width_c = "(trace_width"; | |
|
118 | const char* tracks_c = "(tracks"; | |
|
119 | const char* tstamp_c = "(tstamp"; | |
|
120 | const char* tstamps_c = "(tstamps"; | |
|
121 | const char* type_c = "(type"; | |
|
122 | const char* uri_c = "(uri"; | |
|
123 | const char* useauxorigin_c = "(useauxorigin"; | |
|
124 | const char* usegerberextensions_c = "(usegerberextensions"; | |
|
125 | const char* uvia_dia_c = "(uvia_dia"; | |
|
126 | const char* uvia_drill_c = "(uvia_drill"; | |
|
127 | const char* uvia_min_drill_c = "(uvia_min_drill"; | |
|
128 | const char* uvia_min_size_c = "(uvia_min_size"; | |
|
129 | const char* uvia_size_c = "(uvia_size"; | |
|
130 | const char* uvias_allowed_c = "(uvias_allowed"; | |
|
131 | const char* value_c = "(value"; | |
|
132 | const char* version_c = "(version"; | |
|
133 | const char* via_dia_c = "(via_dia"; | |
|
134 | const char* via_drill_c = "(via_drill"; | |
|
135 | const char* via_min_drill_c = "(via_min_drill"; | |
|
136 | const char* via_min_size_c = "(via_min_size"; | |
|
137 | const char* via_size_c = "(via_size"; | |
|
138 | const char* viasonmask_c = "(viasonmask"; | |
|
139 | const char* visible_elements_c = "(visible_elements"; | |
|
140 | const char* width_c = "(width"; | |
|
141 | const char* xyz = "(x"; | |
|
142 | const char* zone_45_only_c = "(zone_45_only"; | |
|
143 | const char* zone_clearance_c = "(zone_clearance"; | |
|
144 | const char* zones_c = "(zones"; | |
|
145 | ||
|
146 | ||
|
147 |
@@ -0,0 +1,158 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the Kicad Tools Software | |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | /* | |
|
23 | * Have a look to LispLikeLexique.ods | |
|
24 | */ | |
|
25 | #ifndef LEXIQUE_H | |
|
26 | #define LEXIQUE_H | |
|
27 | ||
|
28 | namespace QIlib{ | |
|
29 | ||
|
30 | namespace Lexique | |
|
31 | { | |
|
32 | extern "C" const char* add_net_c; | |
|
33 | extern "C" const char* area_c; | |
|
34 | extern "C" const char* at_c; | |
|
35 | extern "C" const char* attr_c; | |
|
36 | extern "C" const char* center_c; | |
|
37 | extern "C" const char* clearance_c; | |
|
38 | extern "C" const char* code_c; | |
|
39 | extern "C" const char* component_c; | |
|
40 | extern "C" const char* components_c; | |
|
41 | extern "C" const char* date_c; | |
|
42 | extern "C" const char* design_c; | |
|
43 | extern "C" const char* drawings_c; | |
|
44 | extern "C" const char* drillshape_c; | |
|
45 | extern "C" const char* edge_width_c; | |
|
46 | extern "C" const char* effects_c; | |
|
47 | extern "C" const char* end_c; | |
|
48 | extern "C" const char* excludeedgelayer_c; | |
|
49 | extern "C" const char* export_c; | |
|
50 | extern "C" const char* field_c; | |
|
51 | extern "C" const char* fields_c; | |
|
52 | extern "C" const char* font_c; | |
|
53 | extern "C" const char* fp_circle_c; | |
|
54 | extern "C" const char* fp_line_c; | |
|
55 | extern "C" const char* fp_text_c; | |
|
56 | extern "C" const char* general_c; | |
|
57 | extern "C" const char* host_c; | |
|
58 | extern "C" const char* hpglpendiameter_c; | |
|
59 | extern "C" const char* hpglpennumber_c; | |
|
60 | extern "C" const char* hpglpenoverlay_c; | |
|
61 | extern "C" const char* hpglpenspeed_c; | |
|
62 | extern "C" const char* last_trace_width_c; | |
|
63 | extern "C" const char* layers_c; | |
|
64 | extern "C" const char* layerselection_c; | |
|
65 | extern "C" const char* lib_c; | |
|
66 | extern "C" const char* libpart_c; | |
|
67 | extern "C" const char* libparts_c; | |
|
68 | extern "C" const char* libraries_c; | |
|
69 | extern "C" const char* library_c; | |
|
70 | extern "C" const char* libsource_c; | |
|
71 | extern "C" const char* linewidth_c; | |
|
72 | extern "C" const char* links_c; | |
|
73 | extern "C" const char* logical_c; | |
|
74 | extern "C" const char* mirror_c; | |
|
75 | extern "C" const char* mod_edge_width_c; | |
|
76 | extern "C" const char* mod_text_size_c; | |
|
77 | extern "C" const char* mode_c; | |
|
78 | extern "C" const char* model_c; | |
|
79 | extern "C" const char* module_c; | |
|
80 | extern "C" const char* modules_c; | |
|
81 | extern "C" const char* name_c; | |
|
82 | extern "C" const char* names_c; | |
|
83 | extern "C" const char* net_c; | |
|
84 | extern "C" const char* net_class_c; | |
|
85 | extern "C" const char* nets_c; | |
|
86 | extern "C" const char* no_connect_c; | |
|
87 | extern "C" const char* node_c; | |
|
88 | extern "C" const char* num_c; | |
|
89 | extern "C" const char* outputdirectory_c; | |
|
90 | extern "C" const char* outputformat_c; | |
|
91 | extern "C" const char* pad_c; | |
|
92 | extern "C" const char* pad_drill_c; | |
|
93 | extern "C" const char* pad_size_c; | |
|
94 | extern "C" const char* pad_to_mask_clearance_c; | |
|
95 | extern "C" const char* padsonsilk_c; | |
|
96 | extern "C" const char* page_c; | |
|
97 | extern "C" const char* part_c; | |
|
98 | extern "C" const char* path_c; | |
|
99 | extern "C" const char* pcb_text_size_c; | |
|
100 | extern "C" const char* pcb_text_width_c; | |
|
101 | extern "C" const char* pcbplotparams_c; | |
|
102 | extern "C" const char* pin_c; | |
|
103 | extern "C" const char* pins_c; | |
|
104 | extern "C" const char* plotframeref_c; | |
|
105 | extern "C" const char* plotinvisibletext_c; | |
|
106 | extern "C" const char* plotothertext_c; | |
|
107 | extern "C" const char* plotreference_c; | |
|
108 | extern "C" const char* plotvalue_c; | |
|
109 | extern "C" const char* psa4output_c; | |
|
110 | extern "C" const char* psnegative_c; | |
|
111 | extern "C" const char* ref_c; | |
|
112 | extern "C" const char* rotate; | |
|
113 | extern "C" const char* scale_c; | |
|
114 | extern "C" const char* scaleselection_c; | |
|
115 | extern "C" const char* segment_width_c; | |
|
116 | extern "C" const char* setup_c; | |
|
117 | extern "C" const char* sheetpath_c; | |
|
118 | extern "C" const char* source_c; | |
|
119 | extern "C" const char* start_c; | |
|
120 | extern "C" const char* subtractmaskfromsilk_c; | |
|
121 | extern "C" const char* tags_c; | |
|
122 | extern "C" const char* tedit_c; | |
|
123 | extern "C" const char* thickness_c; | |
|
124 | extern "C" const char* tool_c; | |
|
125 | extern "C" const char* trace_clearance_c; | |
|
126 | extern "C" const char* trace_min_c; | |
|
127 | extern "C" const char* trace_width_c; | |
|
128 | extern "C" const char* tracks_c; | |
|
129 | extern "C" const char* tstamp_c; | |
|
130 | extern "C" const char* tstamps_c; | |
|
131 | extern "C" const char* type_c; | |
|
132 | extern "C" const char* uri_c; | |
|
133 | extern "C" const char* useauxorigin_c; | |
|
134 | extern "C" const char* usegerberextensions_c; | |
|
135 | extern "C" const char* uvia_dia_c; | |
|
136 | extern "C" const char* uvia_drill_c; | |
|
137 | extern "C" const char* uvia_min_drill_c; | |
|
138 | extern "C" const char* uvia_min_size_c; | |
|
139 | extern "C" const char* uvia_size_c; | |
|
140 | extern "C" const char* uvias_allowed_c; | |
|
141 | extern "C" const char* value_c; | |
|
142 | extern "C" const char* version_c; | |
|
143 | extern "C" const char* via_dia_c; | |
|
144 | extern "C" const char* via_drill_c; | |
|
145 | extern "C" const char* via_min_drill_c; | |
|
146 | extern "C" const char* via_min_size_c; | |
|
147 | extern "C" const char* via_size_c; | |
|
148 | extern "C" const char* viasonmask_c; | |
|
149 | extern "C" const char* visible_elements_c; | |
|
150 | extern "C" const char* width_c; | |
|
151 | extern "C" const char* xyz; | |
|
152 | extern "C" const char* zone_45_only_c; | |
|
153 | extern "C" const char* zone_clearance_c; | |
|
154 | extern "C" const char* zones_c; | |
|
155 | } | |
|
156 | } | |
|
157 | ||
|
158 | #endif // LEXIQUE_H |
@@ -0,0 +1,39 | |||
|
1 | #include "qicadpcb.h" | |
|
2 | ||
|
3 | ||
|
4 | QIlib::QIcadPcb::QIcadPcb() | |
|
5 | { | |
|
6 | ||
|
7 | } | |
|
8 | ||
|
9 | bool QIlib::QIcadPcb::parsePcb(const QString &pcb) | |
|
10 | { | |
|
11 | parse(pcb.toStdString().c_str()); | |
|
12 | updateConcreteTree(); | |
|
13 | return false; | |
|
14 | } | |
|
15 | ||
|
16 | QString QIlib::QIcadPcb::toString() | |
|
17 | { | |
|
18 | ||
|
19 | } | |
|
20 | ||
|
21 | QString QIlib::QIcadPcb::print() | |
|
22 | { | |
|
23 | return rootNode.print(); | |
|
24 | } | |
|
25 | ||
|
26 | ||
|
27 | void QIlib::QIcadPcb::updateConcreteTree() | |
|
28 | { | |
|
29 | // if(this->rootNode.nodes.count()) | |
|
30 | // { | |
|
31 | // if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::root_c) | |
|
32 | // { | |
|
33 | // if(this->netlistRoot==NULL) | |
|
34 | // { | |
|
35 | // this->netlistRoot = new QIcadNetListRoot(this->rootNode.nodes.at(0)); | |
|
36 | // } | |
|
37 | // } | |
|
38 | // } | |
|
39 | } |
@@ -0,0 +1,56 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the Kicad Tools Software | |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef QICADPCB_H | |
|
23 | #define QICADPCB_H | |
|
24 | #include <QString> | |
|
25 | #include <QStringList> | |
|
26 | #include <QList> | |
|
27 | #include <QFile> | |
|
28 | #include <parsers/lispLike_driver.h> | |
|
29 | #include <qicadlisplikelexique.h> | |
|
30 | ||
|
31 | namespace QIlib{ | |
|
32 | ||
|
33 | class QIcadPcbRoot : public QIcadAbstractNodeWrapper | |
|
34 | { | |
|
35 | public: | |
|
36 | QIcadPcbRoot(QIlib::AbstractNode* node); | |
|
37 | QIcadAbstractNodeWrapper version; | |
|
38 | QIcadAbstractNodeWrapper host; | |
|
39 | void setNode(QIlib::AbstractNode* node); | |
|
40 | }; | |
|
41 | ||
|
42 | class QIcadPcb : private lispLike_Driver | |
|
43 | { | |
|
44 | public: | |
|
45 | QIcadPcb(); | |
|
46 | bool parsePcb(const QString& pcb); | |
|
47 | QString toString(); | |
|
48 | QString fileName; | |
|
49 | QString print(); | |
|
50 | private: | |
|
51 | void updateConcreteTree(); | |
|
52 | }; | |
|
53 | ||
|
54 | ||
|
55 | } | |
|
56 | #endif // QICADPCB_H |
@@ -1,75 +1,75 | |||
|
1 | 1 | %{ |
|
2 | 2 | /* C++ string header, for string ops below */ |
|
3 | 3 | #include <string> |
|
4 | 4 | #include <QString> |
|
5 | 5 | /* Implementation of yyFlexScanner */ |
|
6 | 6 | #include "lispLike_scanner.h" |
|
7 | 7 | #include "lispLike.hpp" |
|
8 | 8 | |
|
9 | 9 | /* typedef to make the returns for the tokens shorter */ |
|
10 | 10 | typedef QIlib::lispLike_Parser::token token; |
|
11 | 11 | |
|
12 | 12 | /* define to keep from re-typing the same code over and over */ |
|
13 | 13 | #define STOKEN( x ) ( new QString( x ) ) |
|
14 | 14 | |
|
15 | 15 | /* define yyterminate as this instead of NULL */ |
|
16 | 16 | //#define yyterminate() return( token::END ) |
|
17 | 17 | |
|
18 | 18 | /* msvc2010 requires that we exclude this header file. */ |
|
19 | 19 | #define YY_NO_UNISTD_H |
|
20 | 20 | %} |
|
21 | 21 | |
|
22 | 22 | %option debug |
|
23 | 23 | %option nodefault |
|
24 | 24 | %option yyclass="lispLike_Scanner" |
|
25 | 25 | %option noyywrap |
|
26 | 26 | %option c++ |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | /* . { return yytext[0]; }*/ |
|
30 | 30 | |
|
31 | 31 | %% |
|
32 | 32 | |
|
33 | 33 | [ \t\n]+ { } |
|
34 | 34 | |
|
35 | 35 | |
|
36 | 36 | \"[a-zA-Z0-9\-\/\(\)\. \:]+\" { |
|
37 | 37 | yylval->sval = STOKEN( yytext ); |
|
38 | 38 | return( token::VALUE ); |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | \([a-zA-Z0-9]+ { | |
|
41 | \([a-zA-Z0-9\_]+ { | |
|
42 | 42 | yylval->sval = STOKEN( yytext ); |
|
43 | 43 | return( token::NODE ); |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | \) { |
|
48 | 48 | return( token::CLOSENODE ); |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | [a-zA-Z0-9\-\/\.\_\~\?\*]+ { |
|
53 | 53 | yylval->sval = STOKEN( yytext ); |
|
54 | 54 | return( token::VALUE ); |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | |
|
58 | 58 | |
|
59 | 59 | \"\" { |
|
60 | 60 | yylval->sval = STOKEN( yytext ); |
|
61 | 61 | return( token::VALUE ); |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | |
|
65 | 65 | .|\n {} |
|
66 | 66 | |
|
67 | 67 | |
|
68 | 68 | %% |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | |
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | |
|
75 | 75 |
@@ -1,154 +1,202 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the Kicad Tools Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/ |
|
23 | 23 | #include "lispLike_driver.h" |
|
24 | 24 | #include<assert.h> |
|
25 | 25 | |
|
26 | ||
|
27 | QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node) | |
|
28 | { | |
|
29 | this->p_node = node; | |
|
30 | } | |
|
31 | ||
|
32 | QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper() | |
|
33 | { | |
|
34 | /*First delete all the childs*/ | |
|
35 | for(int i=0;i<this->childs.count();i++) | |
|
36 | { | |
|
37 | if(this->childs.at(i)) | |
|
38 | delete this->childs.at(i); | |
|
39 | } | |
|
40 | } | |
|
41 | ||
|
42 | QString QIlib::QIcadAbstractNodeWrapper::value() | |
|
43 | { | |
|
44 | if((p_node->Values.count()>0) && p_node) | |
|
45 | return p_node->Values.at(0); | |
|
46 | return QString(""); | |
|
47 | } | |
|
48 | ||
|
49 | QString QIlib::QIcadAbstractNodeWrapper::value(int index) | |
|
50 | { | |
|
51 | if((p_node->Values.count()>index) && p_node) | |
|
52 | return p_node->Values.at(index); | |
|
53 | return QString(""); | |
|
54 | } | |
|
55 | ||
|
56 | QString QIlib::QIcadAbstractNodeWrapper::catValues() | |
|
57 | { | |
|
58 | if(p_node) | |
|
59 | { | |
|
60 | QString result(""); | |
|
61 | for(int i=0;i<p_node->Values.count();i++) | |
|
62 | { | |
|
63 | result.append(p_node->Values.at(i)); | |
|
64 | } | |
|
65 | return result; | |
|
66 | } | |
|
67 | } | |
|
68 | ||
|
69 | void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node) | |
|
70 | { | |
|
71 | this->p_node = node; | |
|
72 | } | |
|
73 | ||
|
26 | 74 | QIlib::lispLike_Driver::lispLike_Driver() |
|
27 | 75 | :parser( NULL ),scanner( NULL ) |
|
28 | 76 | { |
|
29 | 77 | currentNode = &rootNode; |
|
30 | 78 | } |
|
31 | 79 | |
|
32 | 80 | QIlib::lispLike_Driver::~lispLike_Driver() |
|
33 | 81 | { |
|
34 | 82 | delete(scanner); |
|
35 | 83 | scanner = NULL; |
|
36 | 84 | delete(parser); |
|
37 | 85 | parser = NULL; |
|
38 | 86 | } |
|
39 | 87 | |
|
40 | 88 | bool QIlib::lispLike_Driver::parse(const char *filename) |
|
41 | 89 | { |
|
42 | 90 | if(filename!=NULL) |
|
43 | 91 | { |
|
44 | 92 | std::ifstream in_file( filename ); |
|
45 | 93 | if( ! in_file.good() ) return false; |
|
46 | 94 | |
|
47 | 95 | delete(scanner); |
|
48 | 96 | try |
|
49 | 97 | { |
|
50 | 98 | scanner = new QIlib::lispLike_Scanner( &in_file ); |
|
51 | 99 | } |
|
52 | 100 | catch( std::bad_alloc &ba ) |
|
53 | 101 | { |
|
54 | 102 | std::cerr << "Failed to allocate scanner: (" << |
|
55 | 103 | ba.what() << ")\n"; |
|
56 | 104 | return false; |
|
57 | 105 | } |
|
58 | 106 | |
|
59 | 107 | delete(parser); |
|
60 | 108 | try |
|
61 | 109 | { |
|
62 | 110 | parser = new QIlib::lispLike_Parser( (*scanner) /* scanner */, |
|
63 | 111 | (*this) /* driver */ ); |
|
64 | 112 | } |
|
65 | 113 | catch( std::bad_alloc &ba ) |
|
66 | 114 | { |
|
67 | 115 | std::cerr << "Failed to allocate parser: (" << |
|
68 | 116 | ba.what() << ")\n"; |
|
69 | 117 | return false; |
|
70 | 118 | } |
|
71 | 119 | const int accept( 0 ); |
|
72 | 120 | if( parser->parse() != accept ) |
|
73 | 121 | { |
|
74 | 122 | std::cerr << "Parse failed!!\n"; |
|
75 | 123 | return false; |
|
76 | 124 | } |
|
77 | 125 | return true; |
|
78 | 126 | } |
|
79 | 127 | return false; |
|
80 | 128 | } |
|
81 | 129 | |
|
82 | 130 | void QIlib::lispLike_Driver::add_node(const QString &node) |
|
83 | 131 | { |
|
84 | 132 | QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,currentNode); |
|
85 | 133 | currentNode = newNode; |
|
86 | 134 | } |
|
87 | 135 | |
|
88 | 136 | void QIlib::lispLike_Driver::add_node(const QString &node, const QString &value) |
|
89 | 137 | { |
|
90 | 138 | QIlib::AbstractNode* newNode = new QIlib::AbstractNode(node,value,currentNode); |
|
91 | 139 | currentNode = newNode; |
|
92 | 140 | } |
|
93 | 141 | |
|
94 | 142 | void QIlib::lispLike_Driver::add_value(const QString &value) |
|
95 | 143 | { |
|
96 | 144 | currentNode->Values.append(value); |
|
97 | 145 | } |
|
98 | 146 | |
|
99 | 147 | void QIlib::lispLike_Driver::close_node() |
|
100 | 148 | { |
|
101 | 149 | if(currentNode->parent) |
|
102 | 150 | currentNode = currentNode->parent; |
|
103 | 151 | } |
|
104 | 152 | |
|
105 | 153 | |
|
106 | 154 | |
|
107 | 155 | |
|
108 | 156 | |
|
109 | 157 | |
|
110 | 158 | |
|
111 | 159 | |
|
112 | 160 | |
|
113 | 161 | |
|
114 | 162 | QIlib::AbstractNode::AbstractNode(QIlib::AbstractNode *parent) |
|
115 | 163 | { |
|
116 | 164 | this->parent =parent; |
|
117 | 165 | if(parent) |
|
118 | 166 | parent->nodes.append(this); |
|
119 | 167 | } |
|
120 | 168 | |
|
121 | 169 | |
|
122 | 170 | QIlib::AbstractNode::AbstractNode(const QString &Name, QIlib::AbstractNode *parent) |
|
123 | 171 | :name(Name) |
|
124 | 172 | { |
|
125 | 173 | this->parent = parent; |
|
126 | 174 | if(parent) |
|
127 | 175 | parent->nodes.append(this); |
|
128 | 176 | } |
|
129 | 177 | |
|
130 | 178 | |
|
131 | 179 | QIlib::AbstractNode::AbstractNode(const QString &Name, const QString &Value, QIlib::AbstractNode *parent) |
|
132 | 180 | :name(Name) |
|
133 | 181 | { |
|
134 | 182 | this->parent = parent; |
|
135 | 183 | if(parent) |
|
136 | 184 | parent->nodes.append(this); |
|
137 | 185 | Values.append(Value); |
|
138 | 186 | } |
|
139 | 187 | |
|
140 | 188 | QString QIlib::AbstractNode::print() |
|
141 | 189 | { |
|
142 | 190 | QString result; |
|
143 | 191 | result.append(this->name+" "); |
|
144 | 192 | for(int i=0;i<this->nodes.count();i++) |
|
145 | 193 | { |
|
146 | 194 | result.append(this->nodes.at(i)->print()); |
|
147 | 195 | } |
|
148 | 196 | for(int i=0;i<this->Values.count();i++) |
|
149 | 197 | { |
|
150 | 198 | result.append(Values.at(i)+" "); |
|
151 | 199 | } |
|
152 | 200 | result.append(")"); |
|
153 | 201 | return result; |
|
154 | 202 | } |
@@ -1,70 +1,86 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the Kicad Tools Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef LISPLIKE_DRIVER_H |
|
23 | 23 | #define LISPLIKE_DRIVER_H |
|
24 | 24 | #include <string> |
|
25 | 25 | #include "lispLike_scanner.h" |
|
26 | 26 | #include <lispLike/lispLike.hpp> |
|
27 | 27 | #include <QString> |
|
28 | 28 | #include <QList> |
|
29 | 29 | #include <QStringList> |
|
30 | 30 | #include <iostream> |
|
31 | 31 | #include <cstdlib> |
|
32 | 32 | #include <fstream> |
|
33 | 33 | |
|
34 | 34 | namespace QIlib{ |
|
35 | 35 | |
|
36 | 36 | class AbstractNode |
|
37 | 37 | { |
|
38 | 38 | public: |
|
39 | 39 | AbstractNode( QIlib::AbstractNode* parent=NULL); |
|
40 | 40 | AbstractNode(const QString& Name, QIlib::AbstractNode* parent=NULL); |
|
41 | 41 | AbstractNode(const QString& Name,const QString& Value, QIlib::AbstractNode* parent=NULL); |
|
42 | 42 | QString print(); |
|
43 | 43 | QList<QIlib::AbstractNode*> nodes; |
|
44 | 44 | QString name; |
|
45 | 45 | QStringList Values; |
|
46 | 46 | QIlib::AbstractNode* parent; |
|
47 | 47 | }; |
|
48 | 48 | |
|
49 | class QIcadAbstractNodeWrapper | |
|
50 | { | |
|
51 | public: | |
|
52 | QIcadAbstractNodeWrapper(QIlib::AbstractNode* node); | |
|
53 | QIcadAbstractNodeWrapper(){} | |
|
54 | ~QIcadAbstractNodeWrapper(); | |
|
55 | QString value(); | |
|
56 | QString value(int index); | |
|
57 | QString catValues(); | |
|
58 | QList<QIcadAbstractNodeWrapper*> childs; | |
|
59 | QIcadAbstractNodeWrapper* parent; | |
|
60 | virtual void setNode(QIlib::AbstractNode* node); | |
|
61 | ||
|
62 | QIlib::AbstractNode* p_node; | |
|
63 | }; | |
|
64 | ||
|
49 | 65 | class lispLike_Driver |
|
50 | 66 | { |
|
51 | 67 | public: |
|
52 | 68 | lispLike_Driver(); |
|
53 | 69 | |
|
54 | 70 | virtual ~lispLike_Driver(); |
|
55 | 71 | bool parse( const char *filename ); |
|
56 | 72 | void add_node( const QString &node ); |
|
57 | 73 | void add_node( const QString &node , const QString &value); |
|
58 | 74 | void add_value( const QString &value ); |
|
59 | 75 | void close_node(); |
|
60 | 76 | |
|
61 | 77 | |
|
62 | 78 | protected: |
|
63 | 79 | |
|
64 | 80 | QIlib::lispLike_Parser *parser; |
|
65 | 81 | QIlib::lispLike_Scanner *scanner; |
|
66 | 82 | QIlib::AbstractNode rootNode; |
|
67 | 83 | QIlib::AbstractNode* currentNode; |
|
68 | 84 | }; |
|
69 | 85 | } |
|
70 | 86 | #endif // LISPLIKE_DRIVER_H |
@@ -1,698 +1,617 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the Kicad Tools Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "qicadnetlist.h" |
|
23 | 23 | #include <QRegularExpression> |
|
24 | 24 | |
|
25 | 25 | |
|
26 | const char* root_c ="(export"; | |
|
27 | const char* version_c ="(version"; | |
|
28 | const char* design_c ="(design"; | |
|
29 | const char* source_c ="(source"; | |
|
30 | const char* date_c ="(date"; | |
|
31 | const char* tool_c ="(tool"; | |
|
32 | const char* components_c ="(components"; | |
|
33 | const char* component_c ="(comp"; | |
|
34 | const char* ref_c ="(ref"; | |
|
35 | const char* value_c ="(value"; | |
|
36 | const char* libsource_c ="(libsource"; | |
|
37 | const char* lib_c ="(lib"; | |
|
38 | const char* part_c ="(part"; | |
|
39 | const char* sheetpath_c ="(sheetpath"; | |
|
40 | const char* names_c ="(names"; | |
|
41 | const char* tstamps_c ="(tstamps"; | |
|
42 | const char* tstamp_c ="(tstamp"; | |
|
43 | const char* libparts_c ="(libparts"; | |
|
44 | const char* libpart_c ="(libpart"; | |
|
45 | const char* fields_c ="(fields"; | |
|
46 | const char* field_c ="(field"; | |
|
47 | const char* name_c ="(name"; | |
|
48 | const char* pins_c ="(pins"; | |
|
49 | const char* pin_c ="(pin"; | |
|
50 | const char* num_c ="(num"; | |
|
51 | const char* type_c ="(type"; | |
|
52 | const char* libraries_c ="(libraries"; | |
|
53 | const char* library_c ="(library"; | |
|
54 | const char* logical_c ="(logical"; | |
|
55 | const char* uri_c ="(uri"; | |
|
56 | const char* nets_c ="(nets"; | |
|
57 | const char* net_c ="(net"; | |
|
58 | const char* code_c ="(code"; | |
|
59 | const char* node_c ="(node"; | |
|
60 | ||
|
61 | 26 | |
|
62 | 27 | QIlib::QIcadNetList::QIcadNetList() |
|
63 | 28 | :netlistRoot(NULL) |
|
64 | 29 | { |
|
65 | 30 | |
|
66 | 31 | } |
|
67 | 32 | |
|
68 | 33 | |
|
69 | 34 | bool QIlib::QIcadNetList::parseNetList(const QString &netlist) |
|
70 | 35 | { |
|
71 | 36 | |
|
72 | 37 | parse(netlist.toStdString().c_str()); |
|
73 | 38 | updateConcreteTree(); |
|
74 | 39 | return false; |
|
75 | 40 | } |
|
76 | 41 | |
|
77 | 42 | QString QIlib::QIcadNetList::print() |
|
78 | 43 | { |
|
79 | 44 | return rootNode.print(); |
|
80 | 45 | } |
|
81 | 46 | |
|
82 | 47 | QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(const QString &node, int index) |
|
83 | 48 | { |
|
84 | 49 | return getAbstractNode(&rootNode,node,&index); |
|
85 | 50 | } |
|
86 | 51 | |
|
87 | 52 | QIlib::AbstractNode *QIlib::QIcadNetList::getAbstractNode(QIlib::AbstractNode *rootNode, const QString &node, int* index) |
|
88 | 53 | { |
|
89 | 54 | for(int i=0;i<rootNode->nodes.count();i++) |
|
90 | 55 | { |
|
91 | 56 | if(rootNode->nodes.at(i)->name==node) |
|
92 | 57 | { |
|
93 | 58 | if((*index)==0) |
|
94 | 59 | { |
|
95 | 60 | return rootNode->nodes.at(i); |
|
96 | 61 | } |
|
97 | 62 | (*index)-=1; |
|
98 | 63 | } |
|
99 | 64 | else |
|
100 | 65 | { |
|
101 | 66 | if(0<rootNode->nodes.at(i)->nodes.count()) |
|
102 | 67 | { |
|
103 | 68 | QIlib::AbstractNode *result=getAbstractNode(rootNode->nodes.at(i),node,index); |
|
104 | 69 | if(NULL!=result)return result; |
|
105 | 70 | } |
|
106 | 71 | } |
|
107 | 72 | } |
|
108 | 73 | return NULL; |
|
109 | 74 | } |
|
110 | 75 | |
|
111 | 76 | |
|
112 | 77 | void QIlib::QIcadNetList::updateConcreteTree() |
|
113 | 78 | { |
|
114 | 79 | if(this->rootNode.nodes.count()) |
|
115 | 80 | { |
|
116 |
if(this->rootNode.nodes.at(0)->name==QIlib::Lexique:: |
|
|
81 | if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::export_c) | |
|
117 | 82 | { |
|
118 | 83 | if(this->netlistRoot==NULL) |
|
119 | 84 | { |
|
120 | 85 | this->netlistRoot = new QIcadNetListRoot(this->rootNode.nodes.at(0)); |
|
121 | 86 | } |
|
122 | 87 | } |
|
123 | 88 | } |
|
124 | 89 | } |
|
125 | 90 | |
|
126 | 91 | |
|
127 | 92 | |
|
128 | QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node) | |
|
129 | { | |
|
130 | this->p_node = node; | |
|
131 | } | |
|
132 | ||
|
133 | QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper() | |
|
134 | { | |
|
135 | /*First delete all the childs*/ | |
|
136 | for(int i=0;i<this->childs.count();i++) | |
|
137 | { | |
|
138 | if(this->childs.at(i)) | |
|
139 | delete this->childs.at(i); | |
|
140 | } | |
|
141 | } | |
|
142 | ||
|
143 | QString QIlib::QIcadAbstractNodeWrapper::value() | |
|
144 | { | |
|
145 | if((p_node->Values.count()>0) && p_node) | |
|
146 | return p_node->Values.at(0); | |
|
147 | return QString(""); | |
|
148 | } | |
|
149 | ||
|
150 | QString QIlib::QIcadAbstractNodeWrapper::value(int index) | |
|
151 | { | |
|
152 | if((p_node->Values.count()>index) && p_node) | |
|
153 | return p_node->Values.at(index); | |
|
154 | return QString(""); | |
|
155 | } | |
|
156 | ||
|
157 | QString QIlib::QIcadAbstractNodeWrapper::catValues() | |
|
158 | { | |
|
159 | if(p_node) | |
|
160 | { | |
|
161 | QString result(""); | |
|
162 | for(int i=0;i<p_node->Values.count();i++) | |
|
163 | { | |
|
164 | result.append(p_node->Values.at(i)); | |
|
165 | } | |
|
166 | return result; | |
|
167 | } | |
|
168 | } | |
|
169 | ||
|
170 | void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node) | |
|
171 | { | |
|
172 | this->p_node = node; | |
|
173 | } | |
|
174 | 93 | |
|
175 | 94 | |
|
176 | 95 | |
|
177 | 96 | QIlib::QIcadNetListRoot::QIcadNetListRoot(QIlib::AbstractNode *node) |
|
178 | 97 | :QIcadAbstractNodeWrapper(node) |
|
179 | 98 | { |
|
180 | 99 | this->setNode(node); |
|
181 | 100 | } |
|
182 | 101 | |
|
183 | 102 | void QIlib::QIcadNetListRoot::setNode(QIlib::AbstractNode *node) |
|
184 | 103 | { |
|
185 | 104 | this->p_node = node; |
|
186 |
if(node->name==QIlib::Lexique:: |
|
|
105 | if(node->name==QIlib::Lexique::export_c) | |
|
187 | 106 | { |
|
188 | 107 | for(int i=0;i<node->nodes.count();i++) |
|
189 | 108 | { |
|
190 | 109 | if(node->nodes.at(i)->name==QIlib::Lexique::design_c) |
|
191 | 110 | { |
|
192 | 111 | this->design.setNode(node->nodes.at(i)); |
|
193 | 112 | } |
|
194 | 113 | if(node->nodes.at(i)->name==QIlib::Lexique::components_c) |
|
195 | 114 | { |
|
196 | 115 | this->setComponents(node->nodes.at(i)); |
|
197 | 116 | } |
|
198 | 117 | if(node->nodes.at(i)->name==QIlib::Lexique::libparts_c) |
|
199 | 118 | { |
|
200 | 119 | this->setLibParts(node->nodes.at(i)); |
|
201 | 120 | } |
|
202 | 121 | if(node->nodes.at(i)->name==QIlib::Lexique::libraries_c) |
|
203 | 122 | { |
|
204 | 123 | this->setLibraries(node->nodes.at(i)); |
|
205 | 124 | } |
|
206 | 125 | if(node->nodes.at(i)->name==QIlib::Lexique::nets_c) |
|
207 | 126 | { |
|
208 | 127 | this->setNets(node->nodes.at(i)); |
|
209 | 128 | } |
|
210 | 129 | } |
|
211 | 130 | } |
|
212 | 131 | } |
|
213 | 132 | |
|
214 | 133 | void QIlib::QIcadNetListRoot::setComponents(QIlib::AbstractNode *node) |
|
215 | 134 | { |
|
216 | 135 | while(components.count()) |
|
217 | 136 | { |
|
218 | 137 | QIcadNetListComponent* component; |
|
219 | 138 | component = components.last(); |
|
220 | 139 | components.removeLast(); |
|
221 | 140 | delete component; |
|
222 | 141 | } |
|
223 | 142 | apendComponents(node); |
|
224 | 143 | } |
|
225 | 144 | |
|
226 | 145 | void QIlib::QIcadNetListRoot::apendComponents(QIlib::AbstractNode *node) |
|
227 | 146 | { |
|
228 | 147 | if(node->name==QIlib::Lexique::components_c) |
|
229 | 148 | { |
|
230 | 149 | for(int i=0;i<node->nodes.count();i++) |
|
231 | 150 | { |
|
232 | 151 | if(node->nodes.at(i)->name==QIlib::Lexique::component_c) |
|
233 | 152 | { |
|
234 | 153 | this->components.append(new QIcadNetListComponent(node->nodes.at(i))); |
|
235 | 154 | } |
|
236 | 155 | } |
|
237 | 156 | } |
|
238 | 157 | } |
|
239 | 158 | |
|
240 | 159 | void QIlib::QIcadNetListRoot::setLibParts(QIlib::AbstractNode *node) |
|
241 | 160 | { |
|
242 | 161 | while(libparts.count()) |
|
243 | 162 | { |
|
244 | 163 | QIcadNetListLibPart* libpart; |
|
245 | 164 | libpart = libparts.last(); |
|
246 | 165 | libparts.removeLast(); |
|
247 | 166 | delete libpart; |
|
248 | 167 | } |
|
249 | 168 | apendLibParts(node); |
|
250 | 169 | } |
|
251 | 170 | |
|
252 | 171 | void QIlib::QIcadNetListRoot::apendLibParts(QIlib::AbstractNode *node) |
|
253 | 172 | { |
|
254 | 173 | if(node->name==QIlib::Lexique::libparts_c) |
|
255 | 174 | { |
|
256 | 175 | for(int i=0;i<node->nodes.count();i++) |
|
257 | 176 | { |
|
258 | 177 | if(node->nodes.at(i)->name==QIlib::Lexique::libpart_c) |
|
259 | 178 | { |
|
260 | 179 | this->libparts.append(new QIcadNetListLibPart(node->nodes.at(i))); |
|
261 | 180 | } |
|
262 | 181 | } |
|
263 | 182 | } |
|
264 | 183 | } |
|
265 | 184 | |
|
266 | 185 | void QIlib::QIcadNetListRoot::setLibraries(QIlib::AbstractNode *node) |
|
267 | 186 | { |
|
268 | 187 | while(libraries.count()) |
|
269 | 188 | { |
|
270 | 189 | QIcadNetListLibrary* lib; |
|
271 | 190 | lib = libraries.last(); |
|
272 | 191 | libraries.removeLast(); |
|
273 | 192 | delete lib; |
|
274 | 193 | } |
|
275 | 194 | apendLibraries(node); |
|
276 | 195 | } |
|
277 | 196 | |
|
278 | 197 | void QIlib::QIcadNetListRoot::apendLibraries(QIlib::AbstractNode *node) |
|
279 | 198 | { |
|
280 | 199 | if(node->name==QIlib::Lexique::libraries_c) |
|
281 | 200 | { |
|
282 | 201 | for(int i=0;i<node->nodes.count();i++) |
|
283 | 202 | { |
|
284 | 203 | if(node->nodes.at(i)->name==QIlib::Lexique::library_c) |
|
285 | 204 | { |
|
286 | 205 | this->libraries.append(new QIcadNetListLibrary(node->nodes.at(i))); |
|
287 | 206 | } |
|
288 | 207 | } |
|
289 | 208 | } |
|
290 | 209 | } |
|
291 | 210 | |
|
292 | 211 | void QIlib::QIcadNetListRoot::setNets(QIlib::AbstractNode *node) |
|
293 | 212 | { |
|
294 | 213 | while(nets.count()) |
|
295 | 214 | { |
|
296 | 215 | QIcadNetListNet* net; |
|
297 | 216 | net = nets.last(); |
|
298 | 217 | nets.removeLast(); |
|
299 | 218 | delete net; |
|
300 | 219 | } |
|
301 | 220 | apendNets(node); |
|
302 | 221 | } |
|
303 | 222 | |
|
304 | 223 | void QIlib::QIcadNetListRoot::apendNets(QIlib::AbstractNode *node) |
|
305 | 224 | { |
|
306 | 225 | if(node->name==QIlib::Lexique::nets_c) |
|
307 | 226 | { |
|
308 | 227 | for(int i=0;i<node->nodes.count();i++) |
|
309 | 228 | { |
|
310 | 229 | if(node->nodes.at(i)->name==QIlib::Lexique::net_c) |
|
311 | 230 | { |
|
312 | 231 | this->nets.append(new QIcadNetListNet(node->nodes.at(i))); |
|
313 | 232 | } |
|
314 | 233 | } |
|
315 | 234 | } |
|
316 | 235 | } |
|
317 | 236 | |
|
318 | 237 | |
|
319 | 238 | QIlib::QIcadNetListComponent::QIcadNetListComponent(QIlib::AbstractNode *node) |
|
320 | 239 | :QIcadAbstractNodeWrapper(node) |
|
321 | 240 | { |
|
322 | 241 | setNode(node); |
|
323 | 242 | } |
|
324 | 243 | |
|
325 | 244 | void QIlib::QIcadNetListComponent::setNode(QIlib::AbstractNode *node) |
|
326 | 245 | { |
|
327 | 246 | if(node->name==QIlib::Lexique::component_c) |
|
328 | 247 | { |
|
329 | 248 | for(int i=0;i<node->nodes.count();i++) |
|
330 | 249 | { |
|
331 | 250 | if(node->nodes.at(i)->name==QIlib::Lexique::ref_c) |
|
332 | 251 | { |
|
333 | 252 | this->ref.setNode(node->nodes.at(i)); |
|
334 | 253 | } |
|
335 | 254 | if(node->nodes.at(i)->name==QIlib::Lexique::value_c) |
|
336 | 255 | { |
|
337 | 256 | this->value.setNode(node->nodes.at(i)); |
|
338 | 257 | } |
|
339 | 258 | if(node->nodes.at(i)->name==QIlib::Lexique::libsource_c) |
|
340 | 259 | { |
|
341 | 260 | this->libsource.setNode(node->nodes.at(i)); |
|
342 | 261 | } |
|
343 | 262 | if(node->nodes.at(i)->name==QIlib::Lexique::sheetpath_c) |
|
344 | 263 | { |
|
345 | 264 | this->sheetpath.setNode(node->nodes.at(i)); |
|
346 | 265 | } |
|
347 | 266 | if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c) |
|
348 | 267 | { |
|
349 | 268 | this->tstamp.setNode(node->nodes.at(i)); |
|
350 | 269 | } |
|
351 | 270 | } |
|
352 | 271 | } |
|
353 | 272 | } |
|
354 | 273 | |
|
355 | 274 | |
|
356 | 275 | QIlib::QIcadNetListDesign::QIcadNetListDesign(QIlib::AbstractNode *node) |
|
357 | 276 | :QIcadAbstractNodeWrapper(node) |
|
358 | 277 | { |
|
359 | 278 | this->setNode(node); |
|
360 | 279 | } |
|
361 | 280 | |
|
362 | 281 | void QIlib::QIcadNetListDesign::setNode(QIlib::AbstractNode *node) |
|
363 | 282 | { |
|
364 | 283 | if(node->name==QIlib::Lexique::design_c) |
|
365 | 284 | { |
|
366 | 285 | this->p_node = node; |
|
367 | 286 | for(int i=0;i<node->nodes.count();i++) |
|
368 | 287 | { |
|
369 | 288 | if(node->nodes.at(i)->name==QIlib::Lexique::source_c) |
|
370 | 289 | { |
|
371 | 290 | this->source.setNode(node->nodes.at(i)); |
|
372 | 291 | } |
|
373 | 292 | if(node->nodes.at(i)->name==QIlib::Lexique::date_c) |
|
374 | 293 | { |
|
375 | 294 | this->date.setNode(node->nodes.at(i)); |
|
376 | 295 | } |
|
377 | 296 | if(node->nodes.at(i)->name==QIlib::Lexique::tool_c) |
|
378 | 297 | { |
|
379 | 298 | this->tool.setNode(node->nodes.at(i)); |
|
380 | 299 | } |
|
381 | 300 | } |
|
382 | 301 | } |
|
383 | 302 | } |
|
384 | 303 | |
|
385 | 304 | QIlib::QIcadNetListLibPart::QIcadNetListLibPart(QIlib::AbstractNode *node) |
|
386 | 305 | { |
|
387 | 306 | setNode(node); |
|
388 | 307 | } |
|
389 | 308 | /* |
|
390 | 309 | (libparts |
|
391 | 310 | (libpart (lib guan) (part 24L-MOD-8) |
|
392 | 311 | (fields |
|
393 | 312 | (field (name Reference) IC) |
|
394 | 313 | (field (name Value) 24L-MOD-8)) |
|
395 | 314 | (pins |
|
396 | 315 | (pin (num 1) (name GND) (type power_in)) |
|
397 | 316 | (pin (num 2) (name VCC) (type power_in)) |
|
398 | 317 | */ |
|
399 | 318 | void QIlib::QIcadNetListLibPart::setNode(QIlib::AbstractNode *node) |
|
400 | 319 | { |
|
401 | 320 | if(node->name==QIlib::Lexique::libpart_c) |
|
402 | 321 | { |
|
403 | 322 | this->p_node = node; |
|
404 | 323 | for(int i=0;i<node->nodes.count();i++) |
|
405 | 324 | { |
|
406 | 325 | if(node->nodes.at(i)->name==QIlib::Lexique::lib_c) |
|
407 | 326 | { |
|
408 | 327 | this->lib.setNode(node->nodes.at(i)); |
|
409 | 328 | } |
|
410 | 329 | if(node->nodes.at(i)->name==QIlib::Lexique::part_c) |
|
411 | 330 | { |
|
412 | 331 | this->part.setNode(node->nodes.at(i)); |
|
413 | 332 | } |
|
414 | 333 | if(node->nodes.at(i)->name==QIlib::Lexique::fields_c) |
|
415 | 334 | { |
|
416 | 335 | setFields(node->nodes.at(i)); |
|
417 | 336 | } |
|
418 | 337 | if(node->nodes.at(i)->name==QIlib::Lexique::pins_c) |
|
419 | 338 | { |
|
420 | 339 | setPins(node->nodes.at(i)); |
|
421 | 340 | } |
|
422 | 341 | } |
|
423 | 342 | } |
|
424 | 343 | } |
|
425 | 344 | |
|
426 | 345 | void QIlib::QIcadNetListLibPart::setFields(QIlib::AbstractNode *node) |
|
427 | 346 | { |
|
428 | 347 | while(fields.count()) |
|
429 | 348 | { |
|
430 | 349 | QIcadNetListField* field; |
|
431 | 350 | field = fields.last(); |
|
432 | 351 | fields.removeLast(); |
|
433 | 352 | delete field; |
|
434 | 353 | } |
|
435 | 354 | apendFields(node); |
|
436 | 355 | } |
|
437 | 356 | |
|
438 | 357 | void QIlib::QIcadNetListLibPart::apendFields(QIlib::AbstractNode *node) |
|
439 | 358 | { |
|
440 | 359 | if(node->name==QIlib::Lexique::fields_c) |
|
441 | 360 | { |
|
442 | 361 | for(int i=0;i<node->nodes.count();i++) |
|
443 | 362 | { |
|
444 | 363 | if(node->nodes.at(i)->name==QIlib::Lexique::field_c) |
|
445 | 364 | { |
|
446 | 365 | this->fields.append(new QIcadNetListField(node->nodes.at(i))); |
|
447 | 366 | } |
|
448 | 367 | } |
|
449 | 368 | } |
|
450 | 369 | } |
|
451 | 370 | |
|
452 | 371 | void QIlib::QIcadNetListLibPart::setPins(QIlib::AbstractNode *node) |
|
453 | 372 | { |
|
454 | 373 | while(pins.count()) |
|
455 | 374 | { |
|
456 | 375 | QIcadNetListPin* pin; |
|
457 | 376 | pin = pins.last(); |
|
458 | 377 | pins.removeLast(); |
|
459 | 378 | delete pin; |
|
460 | 379 | } |
|
461 | 380 | apendPins(node); |
|
462 | 381 | } |
|
463 | 382 | |
|
464 | 383 | void QIlib::QIcadNetListLibPart::apendPins(QIlib::AbstractNode *node) |
|
465 | 384 | { |
|
466 | 385 | if(node->name==QIlib::Lexique::pins_c) |
|
467 | 386 | { |
|
468 | 387 | for(int i=0;i<node->nodes.count();i++) |
|
469 | 388 | { |
|
470 | 389 | if(node->nodes.at(i)->name==QIlib::Lexique::pin_c) |
|
471 | 390 | { |
|
472 | 391 | this->pins.append(new QIcadNetListPin(node->nodes.at(i))); |
|
473 | 392 | } |
|
474 | 393 | } |
|
475 | 394 | } |
|
476 | 395 | } |
|
477 | 396 | |
|
478 | 397 | |
|
479 | 398 | QIlib::QIcadNetListLibrary::QIcadNetListLibrary(QIlib::AbstractNode *node) |
|
480 | 399 | { |
|
481 | 400 | setNode(node); |
|
482 | 401 | } |
|
483 | 402 | |
|
484 | 403 | void QIlib::QIcadNetListLibrary::setNode(QIlib::AbstractNode *node) |
|
485 | 404 | { |
|
486 | 405 | /* |
|
487 | 406 | (library (logical guan) |
|
488 | 407 | (uri /home/guan/boards/guan.lib)) |
|
489 | 408 | */ |
|
490 | 409 | if(node->name==QIlib::Lexique::library_c) |
|
491 | 410 | { |
|
492 | 411 | this->p_node = node; |
|
493 | 412 | for(int i=0;i<node->nodes.count();i++) |
|
494 | 413 | { |
|
495 | 414 | if(node->nodes.at(i)->name==QIlib::Lexique::logical_c) |
|
496 | 415 | { |
|
497 | 416 | this->logical.setNode(node->nodes.at(i)); |
|
498 | 417 | } |
|
499 | 418 | if(node->nodes.at(i)->name==QIlib::Lexique::uri_c) |
|
500 | 419 | { |
|
501 | 420 | this->uri.setNode(node->nodes.at(i)); |
|
502 | 421 | } |
|
503 | 422 | } |
|
504 | 423 | } |
|
505 | 424 | } |
|
506 | 425 | |
|
507 | 426 | |
|
508 | 427 | |
|
509 | 428 | QIlib::QIcadNetListField::QIcadNetListField(QIlib::AbstractNode *node) |
|
510 | 429 | { |
|
511 | 430 | setNode(node); |
|
512 | 431 | } |
|
513 | 432 | |
|
514 | 433 | void QIlib::QIcadNetListField::setNode(QIlib::AbstractNode *node) |
|
515 | 434 | { |
|
516 | 435 | if(node->name==QIlib::Lexique::field_c) |
|
517 | 436 | { |
|
518 | 437 | this->p_node = node; |
|
519 | 438 | for(int i=0;i<node->nodes.count();i++) |
|
520 | 439 | { |
|
521 | 440 | if(node->nodes.at(i)->name==QIlib::Lexique::name_c) |
|
522 | 441 | { |
|
523 | 442 | this->name.setNode(node->nodes.at(i)); |
|
524 | 443 | } |
|
525 | 444 | } |
|
526 | 445 | } |
|
527 | 446 | } |
|
528 | 447 | |
|
529 | 448 | |
|
530 | 449 | QIlib::QIcadNetListLibPart::QIcadNetListPin::QIcadNetListPin(QIlib::AbstractNode *node) |
|
531 | 450 | { |
|
532 | 451 | setNode(node); |
|
533 | 452 | } |
|
534 | 453 | |
|
535 | 454 | void QIlib::QIcadNetListLibPart::QIcadNetListPin::setNode(QIlib::AbstractNode *node) |
|
536 | 455 | { |
|
537 | 456 | //(pin (num 1) (name GND) (type power_in)) |
|
538 | 457 | if(node->name==QIlib::Lexique::pin_c) |
|
539 | 458 | { |
|
540 | 459 | this->p_node = node; |
|
541 | 460 | for(int i=0;i<node->nodes.count();i++) |
|
542 | 461 | { |
|
543 | 462 | if(node->nodes.at(i)->name==QIlib::Lexique::name_c) |
|
544 | 463 | { |
|
545 | 464 | this->name.setNode(node->nodes.at(i)); |
|
546 | 465 | } |
|
547 | 466 | if(node->nodes.at(i)->name==QIlib::Lexique::num_c) |
|
548 | 467 | { |
|
549 | 468 | this->num.setNode(node->nodes.at(i)); |
|
550 | 469 | } |
|
551 | 470 | if(node->nodes.at(i)->name==QIlib::Lexique::type_c) |
|
552 | 471 | { |
|
553 | 472 | this->type.setNode(node->nodes.at(i)); |
|
554 | 473 | } |
|
555 | 474 | } |
|
556 | 475 | } |
|
557 | 476 | } |
|
558 | 477 | |
|
559 | 478 | QIlib::QIcadNetListComponent::QIcadNetListLibSource::QIcadNetListLibSource(QIlib::AbstractNode *node) |
|
560 | 479 | { |
|
561 | 480 | setNode(node); |
|
562 | 481 | } |
|
563 | 482 | |
|
564 | 483 | void QIlib::QIcadNetListComponent::QIcadNetListLibSource::setNode(QIlib::AbstractNode *node) |
|
565 | 484 | { |
|
566 | 485 | //(libsource (lib guan) (part 24L-MOD-8)) |
|
567 | 486 | if(node->name==QIlib::Lexique::libsource_c) |
|
568 | 487 | { |
|
569 | 488 | this->p_node = node; |
|
570 | 489 | for(int i=0;i<node->nodes.count();i++) |
|
571 | 490 | { |
|
572 | 491 | if(node->nodes.at(i)->name==QIlib::Lexique::lib_c) |
|
573 | 492 | { |
|
574 | 493 | this->lib.setNode(node->nodes.at(i)); |
|
575 | 494 | } |
|
576 | 495 | if(node->nodes.at(i)->name==QIlib::Lexique::part_c) |
|
577 | 496 | { |
|
578 | 497 | this->part.setNode(node->nodes.at(i)); |
|
579 | 498 | } |
|
580 | 499 | } |
|
581 | 500 | } |
|
582 | 501 | } |
|
583 | 502 | |
|
584 | 503 | QIlib::QIcadNetListComponent::QIcadNetListSheetPath::QIcadNetListSheetPath(QIlib::AbstractNode *node) |
|
585 | 504 | { |
|
586 | 505 | setNode(node); |
|
587 | 506 | } |
|
588 | 507 | |
|
589 | 508 | void QIlib::QIcadNetListComponent::QIcadNetListSheetPath::setNode(QIlib::AbstractNode *node) |
|
590 | 509 | { |
|
591 | 510 | //(sheetpath (names /) (tstamps /)) |
|
592 | 511 | if(node->name==QIlib::Lexique::sheetpath_c) |
|
593 | 512 | { |
|
594 | 513 | this->p_node = node; |
|
595 | 514 | for(int i=0;i<node->nodes.count();i++) |
|
596 | 515 | { |
|
597 | 516 | if(node->nodes.at(i)->name==QIlib::Lexique::names_c) |
|
598 | 517 | { |
|
599 | 518 | this->names.setNode(node->nodes.at(i)); |
|
600 | 519 | } |
|
601 | 520 | if(node->nodes.at(i)->name==QIlib::Lexique::tstamps_c) |
|
602 | 521 | { |
|
603 | 522 | this->tstamps.setNode(node->nodes.at(i)); |
|
604 | 523 | } |
|
605 | 524 | } |
|
606 | 525 | } |
|
607 | 526 | } |
|
608 | 527 | |
|
609 | 528 | QIlib::QIcadNetListNet::QIcadNetListNet(QIlib::AbstractNode *node) |
|
610 | 529 | { |
|
611 | 530 | setNode(node); |
|
612 | 531 | } |
|
613 | 532 | |
|
614 | 533 | void QIlib::QIcadNetListNet::setNode(QIlib::AbstractNode *node) |
|
615 | 534 | { |
|
616 | 535 | /* |
|
617 | 536 | (nets |
|
618 | 537 | (net (code 15) (name "") |
|
619 | 538 | (node (ref C4) (pin 1)) |
|
620 | 539 | (node (ref U2) (pin 4))) |
|
621 | 540 | (net (code 16) (name GND) |
|
622 | 541 | (node (ref D1) (pin 2)) |
|
623 | 542 | (node (ref C1) (pin 2)) |
|
624 | 543 | (node (ref IC1) (pin 1)) |
|
625 | 544 | */ |
|
626 | 545 | if(node->name==QIlib::Lexique::net_c) |
|
627 | 546 | { |
|
628 | 547 | this->p_node = node; |
|
629 | 548 | while(NetNodes.count()) |
|
630 | 549 | { |
|
631 | 550 | QIcadNetListNetNode* net; |
|
632 | 551 | net = NetNodes.last(); |
|
633 | 552 | NetNodes.removeLast(); |
|
634 | 553 | delete net; |
|
635 | 554 | } |
|
636 | 555 | for(int i=0;i<node->nodes.count();i++) |
|
637 | 556 | { |
|
638 | 557 | if(node->nodes.at(i)->name==QIlib::Lexique::name_c) |
|
639 | 558 | { |
|
640 | 559 | this->name.setNode(node->nodes.at(i)); |
|
641 | 560 | } |
|
642 | 561 | if(node->nodes.at(i)->name==QIlib::Lexique::code_c) |
|
643 | 562 | { |
|
644 | 563 | this->code.setNode(node->nodes.at(i)); |
|
645 | 564 | } |
|
646 | 565 | if(node->nodes.at(i)->name==QIlib::Lexique::node_c) |
|
647 | 566 | { |
|
648 | 567 | NetNodes.append(new QIcadNetListNetNode(node->nodes.at(i))); |
|
649 | 568 | } |
|
650 | 569 | } |
|
651 | 570 | } |
|
652 | 571 | } |
|
653 | 572 | |
|
654 | 573 | QIlib::QIcadNetListNet::QIcadNetListNetNode::QIcadNetListNetNode(QIlib::AbstractNode *node) |
|
655 | 574 | { |
|
656 | 575 | setNode(node); |
|
657 | 576 | } |
|
658 | 577 | |
|
659 | 578 | void QIlib::QIcadNetListNet::QIcadNetListNetNode::setNode(QIlib::AbstractNode *node) |
|
660 | 579 | { |
|
661 | 580 | //(node (ref D1) (pin 2)) |
|
662 | 581 | if(node->name==QIlib::Lexique::node_c) |
|
663 | 582 | { |
|
664 | 583 | this->p_node = node; |
|
665 | 584 | for(int i=0;i<node->nodes.count();i++) |
|
666 | 585 | { |
|
667 | 586 | if(node->nodes.at(i)->name==QIlib::Lexique::ref_c) |
|
668 | 587 | { |
|
669 | 588 | this->ref.setNode(node->nodes.at(i)); |
|
670 | 589 | } |
|
671 | 590 | if(node->nodes.at(i)->name==QIlib::Lexique::pin_c) |
|
672 | 591 | { |
|
673 | 592 | this->pin.setNode(node->nodes.at(i)); |
|
674 | 593 | } |
|
675 | 594 | } |
|
676 | 595 | } |
|
677 | 596 | } |
|
678 | 597 | |
|
679 | 598 | |
|
680 | 599 | |
|
681 | 600 | |
|
682 | 601 | |
|
683 | 602 | |
|
684 | 603 | |
|
685 | 604 | |
|
686 | 605 | |
|
687 | 606 | |
|
688 | 607 | |
|
689 | 608 | |
|
690 | 609 | |
|
691 | 610 | |
|
692 | 611 | |
|
693 | 612 | |
|
694 | 613 | |
|
695 | 614 | |
|
696 | 615 | |
|
697 | 616 | |
|
698 | 617 |
@@ -1,268 +1,213 | |||
|
1 | #ifndef QICADNETLIST_H | |
|
2 | #define QICADNETLIST_H | |
|
3 | #include <QString> | |
|
4 | #include <QStringList> | |
|
5 | 1 |
|
|
6 | 2 | -- This file is a part of the Kicad Tools Software |
|
7 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
8 | 4 | -- |
|
9 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
10 | 6 | -- it under the terms of the GNU General Public License as published by |
|
11 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
12 | 8 | -- (at your option) any later version. |
|
13 | 9 | -- |
|
14 | 10 | -- This program is distributed in the hope that it will be useful, |
|
15 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 | 13 | -- GNU General Public License for more details. |
|
18 | 14 | -- |
|
19 | 15 | -- You should have received a copy of the GNU General Public License |
|
20 | 16 | -- along with this program; if not, write to the Free Software |
|
21 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
22 | 18 | -------------------------------------------------------------------------------*/ |
|
23 | 19 | /*-- Author : Alexis Jeandet |
|
24 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
25 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | #ifndef QICADNETLIST_H | |
|
23 | #define QICADNETLIST_H | |
|
24 | #include <QString> | |
|
25 | #include <QStringList> | |
|
26 | 26 | #include <QList> |
|
27 | 27 | #include <QFile> |
|
28 | 28 | #include <parsers/lispLike_driver.h> |
|
29 |
#include <qicad |
|
|
29 | #include <qicadlisplikelexique.h> | |
|
30 | 30 | |
|
31 | 31 | namespace QIlib{ |
|
32 | 32 | |
|
33 | namespace Lexique | |
|
34 | { | |
|
35 | extern "C" const char* root_c ; | |
|
36 | extern "C" const char* version_c ; | |
|
37 | extern "C" const char* design_c ; | |
|
38 | extern "C" const char* source_c ; | |
|
39 | extern "C" const char* date_c ; | |
|
40 | extern "C" const char* tool_c ; | |
|
41 | extern "C" const char* components_c ; | |
|
42 | extern "C" const char* component_c ; | |
|
43 | extern "C" const char* ref_c ; | |
|
44 | extern "C" const char* value_c ; | |
|
45 | extern "C" const char* libsource_c ; | |
|
46 | extern "C" const char* lib_c ; | |
|
47 | extern "C" const char* part_c ; | |
|
48 | extern "C" const char* sheetpath_c ; | |
|
49 | extern "C" const char* names_c ; | |
|
50 | extern "C" const char* tstamps_c ; | |
|
51 | extern "C" const char* tstamp_c ; | |
|
52 | extern "C" const char* libparts_c ; | |
|
53 | extern "C" const char* libpart_c ; | |
|
54 | extern "C" const char* fields_c ; | |
|
55 | extern "C" const char* field_c ; | |
|
56 | extern "C" const char* name_c ; | |
|
57 | extern "C" const char* pins_c ; | |
|
58 | extern "C" const char* pin_c ; | |
|
59 | extern "C" const char* num_c ; | |
|
60 | extern "C" const char* type_c ; | |
|
61 | extern "C" const char* libraries_c ; | |
|
62 | extern "C" const char* library_c ; | |
|
63 | extern "C" const char* logical_c ; | |
|
64 | extern "C" const char* uri_c ; | |
|
65 | extern "C" const char* nets_c ; | |
|
66 | extern "C" const char* net_c ; | |
|
67 | extern "C" const char* code_c ; | |
|
68 | extern "C" const char* node_c ; | |
|
69 | 33 | |
|
70 | } | |
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | class QIcadAbstractNodeWrapper | |
|
75 | { | |
|
76 | public: | |
|
77 | QIcadAbstractNodeWrapper(QIlib::AbstractNode* node); | |
|
78 | QIcadAbstractNodeWrapper(){} | |
|
79 | ~QIcadAbstractNodeWrapper(); | |
|
80 | QString value(); | |
|
81 | QString value(int index); | |
|
82 | QString catValues(); | |
|
83 | QList<QIcadAbstractNodeWrapper*> childs; | |
|
84 | QIcadAbstractNodeWrapper* parent; | |
|
85 | virtual void setNode(QIlib::AbstractNode* node); | |
|
86 | ||
|
87 | QIlib::AbstractNode* p_node; | |
|
88 | }; | |
|
89 | 34 | |
|
90 | 35 | class QIcadNetListDesign : public QIcadAbstractNodeWrapper |
|
91 | 36 | { |
|
92 | 37 | public: |
|
93 | 38 | QIcadNetListDesign(QIlib::AbstractNode* node); |
|
94 | 39 | QIcadNetListDesign(){} |
|
95 | 40 | QIcadAbstractNodeWrapper source; |
|
96 | 41 | QIcadAbstractNodeWrapper date; |
|
97 | 42 | QIcadAbstractNodeWrapper tool; |
|
98 | 43 | void setNode(QIlib::AbstractNode* node); |
|
99 | 44 | }; |
|
100 | 45 | |
|
101 | 46 | |
|
102 | 47 | |
|
103 | 48 | /* |
|
104 | 49 | * (comp (ref IC1) |
|
105 | 50 | (value 24L-MOD-8) |
|
106 | 51 | (libsource (lib guan) (part 24L-MOD-8)) |
|
107 | 52 | (sheetpath (names /) (tstamps /)) |
|
108 | 53 | (tstamp 52533BBE)) |
|
109 | 54 | */ |
|
110 | 55 | class QIcadNetListComponent:public QIcadAbstractNodeWrapper |
|
111 | 56 | { |
|
112 | 57 | class QIcadNetListLibSource : QIcadAbstractNodeWrapper |
|
113 | 58 | { |
|
114 | 59 | public: |
|
115 | 60 | QIcadNetListLibSource(AbstractNode* node); |
|
116 | 61 | QIcadNetListLibSource(){} |
|
117 | 62 | QIcadAbstractNodeWrapper lib; |
|
118 | 63 | QIcadAbstractNodeWrapper part; |
|
119 | 64 | void setNode(AbstractNode* node); |
|
120 | 65 | }; |
|
121 | 66 | class QIcadNetListSheetPath : QIcadAbstractNodeWrapper |
|
122 | 67 | { |
|
123 | 68 | public: |
|
124 | 69 | QIcadNetListSheetPath(AbstractNode* node); |
|
125 | 70 | QIcadNetListSheetPath(){} |
|
126 | 71 | QIcadAbstractNodeWrapper names; |
|
127 | 72 | QIcadAbstractNodeWrapper tstamps; |
|
128 | 73 | void setNode(AbstractNode* node); |
|
129 | 74 | }; |
|
130 | 75 | public: |
|
131 | 76 | QIcadNetListComponent(AbstractNode* node); |
|
132 | 77 | QIcadAbstractNodeWrapper ref; |
|
133 | 78 | QIcadAbstractNodeWrapper value; |
|
134 | 79 | QIcadNetListLibSource libsource; |
|
135 | 80 | QIcadNetListSheetPath sheetpath; |
|
136 | 81 | QIcadAbstractNodeWrapper tstamp; |
|
137 | 82 | void setNode(QIlib::AbstractNode* node); |
|
138 | 83 | }; |
|
139 | 84 | |
|
140 | 85 | |
|
141 | 86 | /* |
|
142 | 87 | (libparts |
|
143 | 88 | (libpart (lib guan) (part 24L-MOD-8) |
|
144 | 89 | (fields |
|
145 | 90 | (field (name Reference) IC) |
|
146 | 91 | (field (name Value) 24L-MOD-8)) |
|
147 | 92 | (pins |
|
148 | 93 | (pin (num 1) (name GND) (type power_in)) |
|
149 | 94 | (pin (num 2) (name VCC) (type power_in)) |
|
150 | 95 | */ |
|
151 | 96 | class QIcadNetListField : QIcadAbstractNodeWrapper |
|
152 | 97 | { |
|
153 | 98 | public: |
|
154 | 99 | QIcadNetListField(AbstractNode* node); |
|
155 | 100 | QIcadAbstractNodeWrapper name; |
|
156 | 101 | void setNode(AbstractNode* node); |
|
157 | 102 | }; |
|
158 | 103 | |
|
159 | 104 | |
|
160 | 105 | class QIcadNetListLibPart : QIcadAbstractNodeWrapper |
|
161 | 106 | { |
|
162 | 107 | class QIcadNetListPin : QIcadAbstractNodeWrapper |
|
163 | 108 | { |
|
164 | 109 | public: |
|
165 | 110 | QIcadNetListPin(AbstractNode* node); |
|
166 | 111 | QIcadAbstractNodeWrapper type; |
|
167 | 112 | QIcadAbstractNodeWrapper num; |
|
168 | 113 | QIcadAbstractNodeWrapper name; |
|
169 | 114 | void setNode(AbstractNode* node); |
|
170 | 115 | }; |
|
171 | 116 | public: |
|
172 | 117 | QIcadNetListLibPart(AbstractNode* node); |
|
173 | 118 | QIcadAbstractNodeWrapper lib; |
|
174 | 119 | QIcadAbstractNodeWrapper part; |
|
175 | 120 | QList<QIcadNetListField*> fields; |
|
176 | 121 | QList<QIcadNetListPin*> pins; |
|
177 | 122 | void setNode(AbstractNode* node); |
|
178 | 123 | void setFields(QIlib::AbstractNode* node); |
|
179 | 124 | void apendFields(QIlib::AbstractNode* node); |
|
180 | 125 | void setPins(QIlib::AbstractNode* node); |
|
181 | 126 | void apendPins(QIlib::AbstractNode* node); |
|
182 | 127 | }; |
|
183 | 128 | |
|
184 | 129 | /* |
|
185 | 130 | (libraries |
|
186 | 131 | (library (logical guan) |
|
187 | 132 | (uri /home/guan/boards/guan.lib)) |
|
188 | 133 | (library (logical device) |
|
189 | 134 | (uri /usr/share/kicad/library/device.lib)) |
|
190 | 135 | (library (logical conn) |
|
191 | 136 | (uri /usr/share/kicad/library/conn.lib))) |
|
192 | 137 | */ |
|
193 | 138 | |
|
194 | 139 | class QIcadNetListLibrary : QIcadAbstractNodeWrapper |
|
195 | 140 | { |
|
196 | 141 | public: |
|
197 | 142 | QIcadNetListLibrary(AbstractNode* node); |
|
198 | 143 | QIcadAbstractNodeWrapper uri; |
|
199 | 144 | QIcadAbstractNodeWrapper logical; |
|
200 | 145 | void setNode(AbstractNode* node); |
|
201 | 146 | }; |
|
202 | 147 | /* |
|
203 | 148 | (nets |
|
204 | 149 | (net (code 15) (name "") |
|
205 | 150 | (node (ref C4) (pin 1)) |
|
206 | 151 | (node (ref U2) (pin 4))) |
|
207 | 152 | (net (code 16) (name GND) |
|
208 | 153 | (node (ref D1) (pin 2)) |
|
209 | 154 | (node (ref C1) (pin 2)) |
|
210 | 155 | (node (ref IC1) (pin 1)) |
|
211 | 156 | */ |
|
212 | 157 | |
|
213 | 158 | class QIcadNetListNet : QIcadAbstractNodeWrapper |
|
214 | 159 | { |
|
215 | 160 | class QIcadNetListNetNode: QIcadAbstractNodeWrapper |
|
216 | 161 | { |
|
217 | 162 | public: |
|
218 | 163 | QIcadNetListNetNode(AbstractNode* node); |
|
219 | 164 | QIcadAbstractNodeWrapper ref; |
|
220 | 165 | QIcadAbstractNodeWrapper pin; |
|
221 | 166 | void setNode(AbstractNode* node); |
|
222 | 167 | }; |
|
223 | 168 | public: |
|
224 | 169 | QIcadNetListNet(AbstractNode* node); |
|
225 | 170 | QList<QIcadNetListNetNode*> NetNodes; |
|
226 | 171 | QIcadAbstractNodeWrapper code; |
|
227 | 172 | QIcadAbstractNodeWrapper name; |
|
228 | 173 | void setNode(AbstractNode* node); |
|
229 | 174 | |
|
230 | 175 | }; |
|
231 | 176 | |
|
232 | 177 | class QIcadNetListRoot : public QIcadAbstractNodeWrapper |
|
233 | 178 | { |
|
234 | 179 | public: |
|
235 | 180 | QIcadNetListRoot(QIlib::AbstractNode* node); |
|
236 | 181 | QIcadNetListDesign design; |
|
237 | 182 | QList<QIcadNetListComponent*> components; |
|
238 | 183 | QList<QIcadNetListLibPart*> libparts; |
|
239 | 184 | QList<QIcadNetListLibrary*> libraries; |
|
240 | 185 | QList<QIcadNetListNet*> nets; |
|
241 | 186 | void setNode(QIlib::AbstractNode* node); |
|
242 | 187 | void setComponents(QIlib::AbstractNode* node); |
|
243 | 188 | void apendComponents(QIlib::AbstractNode* node); |
|
244 | 189 | void setLibParts(QIlib::AbstractNode* node); |
|
245 | 190 | void apendLibParts(QIlib::AbstractNode* node); |
|
246 | 191 | void setLibraries(QIlib::AbstractNode* node); |
|
247 | 192 | void apendLibraries(QIlib::AbstractNode* node); |
|
248 | 193 | void setNets(QIlib::AbstractNode* node); |
|
249 | 194 | void apendNets(QIlib::AbstractNode* node); |
|
250 | 195 | }; |
|
251 | 196 | |
|
252 | 197 | |
|
253 | 198 | class QIcadNetList : private lispLike_Driver |
|
254 | 199 | { |
|
255 | 200 | public: |
|
256 | 201 | QIcadNetList(); |
|
257 | 202 | bool parseNetList(const QString& netlist); |
|
258 | QString toString(); | |
|
203 | // QString toString(); | |
|
259 | 204 | QString fileName; |
|
260 | 205 | QString print(); |
|
261 | 206 | QIcadNetListRoot* netlistRoot; |
|
262 | 207 | private: |
|
263 | 208 | QIlib::AbstractNode* getAbstractNode(const QString& node,int index); |
|
264 | 209 | QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index); |
|
265 | 210 | void updateConcreteTree(); |
|
266 | 211 | }; |
|
267 | 212 | } |
|
268 | 213 | #endif // QICADNETLIST_H |
@@ -1,64 +1,67 | |||
|
1 | 1 | #================================================== |
|
2 | 2 | # |
|
3 | 3 | # _|_| _|_|_| _| _| _| |
|
4 | 4 | # _| _| _| _| _|_|_| |
|
5 | 5 | # _| _|_| _| _| _| _| _| |
|
6 | 6 | # _| _| _| _| _| _| _| |
|
7 | 7 | # _|_| _| _|_|_| _| _| _|_|_| |
|
8 | 8 | # |
|
9 | 9 | #================================================== |
|
10 | 10 | # |
|
11 | 11 | # |
|
12 | 12 | |
|
13 | 13 | QT += core gui |
|
14 | 14 | |
|
15 | 15 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
|
16 | 16 | |
|
17 | 17 | TARGET = QIlib |
|
18 | 18 | TEMPLATE = lib |
|
19 | 19 | |
|
20 | 20 | LIBS += -lfl |
|
21 | 21 | |
|
22 | 22 | MOC_DIR = moc |
|
23 | 23 | RCC_DIR = resources |
|
24 | 24 | OBJECTS_DIR = obj |
|
25 | 25 | DESTDIR = lib |
|
26 | 26 | |
|
27 | 27 | include ( ./parsers/Flex_Bison_FIles/Flex_Bison_FIles.pri ) |
|
28 | 28 | |
|
29 | 29 | qilibcfg.path = $$[QT_INSTALL_PREFIX]/mkspecs/features |
|
30 | 30 | qilibcfg.files = \ |
|
31 | 31 | qilib.prf |
|
32 | 32 | |
|
33 | 33 | target.path = $$[QT_INSTALL_LIBS] |
|
34 | 34 | |
|
35 | 35 | qilibHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib |
|
36 | 36 | qilibHeaders.files = \ |
|
37 | 37 | qicadnetlist.h \ |
|
38 |
qicad |
|
|
38 | qicadpcb.h \ | |
|
39 | qicadlisplikelexique.h | |
|
39 | 40 | |
|
40 | 41 | qilibParsersHeaders.path = $$[QT_INSTALL_HEADERS]/QIlib/parsers |
|
41 | 42 | qilibParsersHeaders.files = \ |
|
42 | 43 | parsers/lispLike_driver.h \ |
|
43 | 44 | parsers/lispLike_scanner.h |
|
44 | 45 | |
|
45 | 46 | |
|
46 | 47 | INSTALLS += target qilibHeaders qilibParsersHeaders qilibcfg |
|
47 | 48 | |
|
48 | 49 | INCLUDEPATH += ./parsers |
|
49 | 50 | |
|
50 | 51 | SOURCES += \ |
|
51 | 52 | qicadnetlist.cpp \ |
|
52 | qicadnet.cpp \ | |
|
53 | 53 | parsers/lispLike_driver.cpp \ |
|
54 | parsers/lispLike_scanner.cpp | |
|
54 | parsers/lispLike_scanner.cpp \ | |
|
55 | qicadpcb.cpp \ | |
|
56 | qicadlisplikelexique.cpp | |
|
55 | 57 | |
|
56 | 58 | |
|
57 | 59 | HEADERS += \ |
|
58 | 60 | qicadnetlist.h \ |
|
59 | qicadnet.h \ | |
|
60 | 61 | parsers/lispLike_driver.h \ |
|
61 | parsers/lispLike_scanner.h | |
|
62 | parsers/lispLike_scanner.h \ | |
|
63 | qicadpcb.h \ | |
|
64 | qicadlisplikelexique.h | |
|
62 | 65 | |
|
63 | 66 | OTHER_FILES += qilib.prf |
|
64 | 67 |
@@ -1,59 +1,81 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the Kicad Tools Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include <QDir> |
|
23 | 23 | #include <QFile> |
|
24 | 24 | #include <QApplication> |
|
25 | 25 | #include <qicadnetlist.h> |
|
26 | #include <qicadpcb.h> | |
|
26 | 27 | #include <QDebug> |
|
27 | 28 | #include <QTime> |
|
28 | 29 | /* |
|
29 | 30 | #include <lispLike_driver.h> |
|
30 | 31 | */ |
|
31 | 32 | |
|
32 | 33 | int main(int argc, char *argv[]) |
|
33 | 34 | { |
|
34 | 35 | QApplication ap(argc,argv); |
|
35 | QIlib::QIcadNetList NetListdriver; | |
|
36 | 36 | if(argc>1) |
|
37 | 37 | { |
|
38 | 38 | if(QFile::exists(argv[1])) |
|
39 | 39 | { |
|
40 | 40 | QTime tm; |
|
41 | tm.start(); | |
|
42 | NetListdriver.parseNetList(argv[1]); | |
|
43 | qDebug()<<"File parsed in "<<tm.elapsed()<<"ms"; | |
|
44 | if(ap.arguments().contains("--print")) | |
|
41 | if(ap.arguments().contains("--netList")) | |
|
45 | 42 | { |
|
46 | std::cout<<NetListdriver.print().toStdString(); | |
|
43 | QIlib::QIcadNetList NetListdriver; | |
|
44 | tm.start(); | |
|
45 | NetListdriver.parseNetList(argv[1]); | |
|
46 | qDebug()<<"File parsed in "<<tm.elapsed()<<"ms"; | |
|
47 | if(ap.arguments().contains("--print")) | |
|
48 | { | |
|
49 | std::cout<<NetListdriver.print().toStdString(); | |
|
50 | } | |
|
51 | else | |
|
52 | { | |
|
53 | for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++) | |
|
54 | { | |
|
55 | std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n"; | |
|
56 | } | |
|
57 | } | |
|
47 | 58 | } |
|
48 | 59 | else |
|
49 | 60 | { |
|
50 | for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++) | |
|
61 | QIlib::QIcadPcb pcbDriver; | |
|
62 | tm.start(); | |
|
63 | pcbDriver.parsePcb(argv[1]); | |
|
64 | qDebug()<<"File parsed in "<<tm.elapsed()<<"ms"; | |
|
65 | if(ap.arguments().contains("--print")) | |
|
51 | 66 | { |
|
52 | std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n"; | |
|
67 | std::cout<<pcbDriver.print().toStdString(); | |
|
68 | } | |
|
69 | else | |
|
70 | { | |
|
71 | // for(int i=0;i<NetListdriver.netlistRoot->nets.count();i++) | |
|
72 | // { | |
|
73 | // std::cout<<"Found net:"<<NetListdriver.netlistRoot->nets.at(i)->name.value().toStdString()<<" "<<NetListdriver.netlistRoot->nets.at(i)->code.value().toStdString()<<"\n"; | |
|
74 | // } | |
|
53 | 75 | } |
|
54 | 76 | } |
|
55 | 77 | } |
|
56 | 78 | |
|
57 | 79 | } |
|
58 | 80 | return 0; |
|
59 | 81 | } |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now