##// END OF EJS Templates
Sync
jeandet -
r1:0db2be5e5c43 default
parent child
Show More
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/
22 /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/
2 #include "lispLike_driver.h"
23 #include "lispLike_driver.h"
3 #include<assert.h>
24 #include<assert.h>
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #ifndef LISPLIKE_DRIVER_H
22 #ifndef LISPLIKE_DRIVER_H
2 #define LISPLIKE_DRIVER_H
23 #define LISPLIKE_DRIVER_H
3 #include <string>
24 #include <string>
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #include "lispLike_scanner.h"
22 #include "lispLike_scanner.h"
2
23
3 QIlib::lispLike_Scanner::lispLike_Scanner(std::istream *in)
24 QIlib::lispLike_Scanner::lispLike_Scanner(std::istream *in)
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #ifndef LISPLIKE_SCANNER_H
22 #ifndef LISPLIKE_SCANNER_H
2 #define LISPLIKE_SCANNER_H
23 #define LISPLIKE_SCANNER_H
3 #if ! defined(yyFlexLexerOnce)
24 #if ! defined(yyFlexLexerOnce)
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #include "qicadnet.h"
22 #include "qicadnet.h"
2
23
3 QIlib::QIcadNet::QIcadNet()
24 QIlib::QIcadNet::QIcadNet()
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #ifndef QINET_H
22 #ifndef QINET_H
2 #define QINET_H
23 #define QINET_H
3 #include <QString>
24 #include <QString>
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #include "qicadnetlist.h"
22 #include "qicadnetlist.h"
2 #include <QRegularExpression>
23 #include <QRegularExpression>
3
24
@@ -116,9 +137,9 void QIlib::QIcadNetList::updateConcrete
116
137
117
138
118
139
119 QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper()
140 QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node)
120 {
141 {
121
142 this->p_node = node;
122 }
143 }
123
144
124 QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper()
145 QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper()
@@ -130,3 +151,50 QIlib::QIcadAbstractNodeWrapper::~QIcadA
130 delete this->childs.at(i);
151 delete this->childs.at(i);
131 }
152 }
132 }
153 }
154
155 QString QIlib::QIcadAbstractNodeWrapper::value()
156 {
157 if((p_node->Values.count()>0) && p_node)
158 return p_node->Values.at(0);
159 return QString("");
160 }
161
162 QString QIlib::QIcadAbstractNodeWrapper::value(int index)
163 {
164 if((p_node->Values.count()>index) && p_node)
165 return p_node->Values.at(index);
166 return QString("");
167 }
168
169 QString QIlib::QIcadAbstractNodeWrapper::catValues()
170 {
171 if(p_node)
172 {
173 QString result("");
174 for(int i=0;i<p_node->Values.count();i++)
175 {
176 result.append(p_node->Values.at(i));
177 }
178 return result;
179 }
180 }
181
182 void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node)
183 {
184 this->p_node = node;
185 }
186
187
188
189 QIlib::QIcadNetListRoot::QIcadNetListRoot(QIlib::AbstractNode *node)
190 :QIcadAbstractNodeWrapper(node)
191 {
192
193 }
194
195
196 QIlib::QIcadNetListComponent::QIcadNetListComponent(QIlib::AbstractNode *node)
197 :QIcadAbstractNodeWrapper(node)
198 {
199
200 }
@@ -2,6 +2,27
2 #define QICADNETLIST_H
2 #define QICADNETLIST_H
3 #include <QString>
3 #include <QString>
4 #include <QStringList>
4 #include <QStringList>
5 /*------------------------------------------------------------------------------
6 -- This file is a part of the Kicad Tools Software
7 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
8 --
9 -- This program is free software; you can redistribute it and/or modify
10 -- it under the terms of the GNU General Public License as published by
11 -- the Free Software Foundation; either version 2 of the License, or
12 -- (at your option) any later version.
13 --
14 -- This program is distributed in the hope that it will be useful,
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 -- GNU General Public License for more details.
18 --
19 -- You should have received a copy of the GNU General Public License
20 -- along with this program; if not, write to the Free Software
21 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 -------------------------------------------------------------------------------*/
23 /*-- Author : Alexis Jeandet
24 -- Mail : alexis.jeandet@member.fsf.org
25 ----------------------------------------------------------------------------*/
5 #include <QList>
26 #include <QList>
6 #include <QFile>
27 #include <QFile>
7 #include <parsers/lispLike_driver.h>
28 #include <parsers/lispLike_driver.h>
@@ -113,15 +134,128 public:
113 class QIcadAbstractNodeWrapper
134 class QIcadAbstractNodeWrapper
114 {
135 {
115 public:
136 public:
116 QIcadAbstractNodeWrapper();
137 QIcadAbstractNodeWrapper(QIlib::AbstractNode* node);
117 ~QIcadAbstractNodeWrapper();
138 ~QIcadAbstractNodeWrapper();
118 QString value();
139 QString value();
140 QString value(int index);
141 QString catValues();
142 void setNode(QIlib::AbstractNode* node);
119 QList<QIcadAbstractNodeWrapper*> childs;
143 QList<QIcadAbstractNodeWrapper*> childs;
120 QIcadAbstractNodeWrapper* parent;
144 QIcadAbstractNodeWrapper* parent;
145
121 private:
146 private:
122 QIlib::AbstractNode* node;
147 QIlib::AbstractNode* p_node;
148 };
149
150 class QIcadNetListRoot : public AbstractNode
151 {
152 public:
153 QIcadNetListRoot(QIlib::AbstractNode* node);
154 QIcadAbstractNodeWrapper source;
155 QIcadAbstractNodeWrapper date;
156 QIcadAbstractNodeWrapper tool;
157 QList<QIcadNetListComponent*> components;
158 QList<QIcadNetListLibPart*> libparts;
159 QList<QIcadNetListLibrary*> libraries;
160 };
161
162
163 /*
164 * (comp (ref IC1)
165 (value 24L-MOD-8)
166 (libsource (lib guan) (part 24L-MOD-8))
167 (sheetpath (names /) (tstamps /))
168 (tstamp 52533BBE))
169 */
170 class QIcadNetListComponent:public QIcadAbstractNodeWrapper
171 {
172 public:
173 QIcadNetListComponent(AbstractNode* node);
174 QIcadAbstractNodeWrapper ref;
175 QIcadAbstractNodeWrapper value;
176 QIcadAbstractNodeWrapper libsource;
177 QIcadAbstractNodeWrapper sheetpath;
178 QIcadAbstractNodeWrapper tstamp;
179 };
180
181
182 /*
183 (libparts
184 (libpart (lib guan) (part 24L-MOD-8)
185 (fields
186 (field (name Reference) IC)
187 (field (name Value) 24L-MOD-8))
188 (pins
189 (pin (num 1) (name GND) (type power_in))
190 (pin (num 2) (name VCC) (type power_in))
191 */
192 class QIcadNetListField : QIcadAbstractNodeWrapper
193 {
194 public:
195 QIcadNetListField(AbstractNode* node);
196 QIcadAbstractNodeWrapper name;
123 };
197 };
124
198
199
200 class QIcadNetListLibPart : QIcadAbstractNodeWrapper
201 {
202 class QIcadNetListPin : QIcadAbstractNodeWrapper
203 {
204 public:
205 QIcadNetListPin(AbstractNode* node);
206 QIcadAbstractNodeWrapper type;
207 QIcadAbstractNodeWrapper num;
208 QIcadAbstractNodeWrapper name;
209 };
210 public:
211 QIcadNetListLibPart(AbstractNode* node);
212 QList<QIcadNetListField*> fields;
213 QList<QIcadNetListPin*> pins;
214 };
215
216 /*
217 (libraries
218 (library (logical guan)
219 (uri /home/guan/boards/guan.lib))
220 (library (logical device)
221 (uri /usr/share/kicad/library/device.lib))
222 (library (logical conn)
223 (uri /usr/share/kicad/library/conn.lib)))
224 */
225
226 class QIcadNetListLibrary : QIcadAbstractNodeWrapper
227 {
228 public:
229 QIcadNetListLibrary(AbstractNode* node);
230 QIcadAbstractNodeWrapper uri;
231 };
232 /*
233 (nets
234 (net (code 15) (name "")
235 (node (ref C4) (pin 1))
236 (node (ref U2) (pin 4)))
237 (net (code 16) (name GND)
238 (node (ref D1) (pin 2))
239 (node (ref C1) (pin 2))
240 (node (ref IC1) (pin 1))
241 */
242
243 class QIcadNetListNet : QIcadAbstractNodeWrapper
244 {
245 class QIcadNetListNetNode: QIcadAbstractNodeWrapper
246 {
247 public:
248 QIcadNetListNetNode(AbstractNode* node);
249 QIcadAbstractNodeWrapper ref;
250 QIcadAbstractNodeWrapper pin;
251 };
252 public:
253 QIcadNetListNet(AbstractNode* node);
254 QList<QIcadNetListNetNode*> NetNodes;
255 };
256
257
258
125 class QIcadNetList : private lispLike_Driver
259 class QIcadNetList : private lispLike_Driver
126 {
260 {
127 public:
261 public:
@@ -135,6 +269,7 public:
135 QList<QIcadNetListLibPart*> libparts;
269 QList<QIcadNetListLibPart*> libparts;
136 QIcadNetListLevel rootSheet;
270 QIcadNetListLevel rootSheet;
137 QString print();
271 QString print();
272 QIcadAbstractNodeWrapper netlistRoot;
138 private:
273 private:
139 QIlib::AbstractNode* getAbstractNode(const QString& node,int index);
274 QIlib::AbstractNode* getAbstractNode(const QString& node,int index);
140 QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index);
275 QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index);
@@ -1,3 +1,24
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 ----------------------------------------------------------------------------*/
1 #include <QDir>
22 #include <QDir>
2 #include <QFile>
23 #include <QFile>
3 #include <QApplication>
24 #include <QApplication>
@@ -408,4 +408,4
408 (net (code 45) (name "")
408 (net (code 45) (name "")
409 (node (ref U1) (pin 3)))
409 (node (ref U1) (pin 3)))
410 (net (code 46) (name "")
410 (net (code 46) (name "")
411 (node (ref U1) (pin 5))))) No newline at end of file
411 (node (ref U1) (pin 5)))))
General Comments 0
You need to be logged in to leave comments. Login now