diff --git a/qilib/parsers/lispLike_driver.cpp b/qilib/parsers/lispLike_driver.cpp --- a/qilib/parsers/lispLike_driver.cpp +++ b/qilib/parsers/lispLike_driver.cpp @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ /*Mainly copied from http://research.engineering.wustl.edu/~beardj/FlexBisonC++.html*/ #include "lispLike_driver.h" #include diff --git a/qilib/parsers/lispLike_driver.h b/qilib/parsers/lispLike_driver.h --- a/qilib/parsers/lispLike_driver.h +++ b/qilib/parsers/lispLike_driver.h @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #ifndef LISPLIKE_DRIVER_H #define LISPLIKE_DRIVER_H #include diff --git a/qilib/parsers/lispLike_scanner.cpp b/qilib/parsers/lispLike_scanner.cpp --- a/qilib/parsers/lispLike_scanner.cpp +++ b/qilib/parsers/lispLike_scanner.cpp @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #include "lispLike_scanner.h" QIlib::lispLike_Scanner::lispLike_Scanner(std::istream *in) diff --git a/qilib/parsers/lispLike_scanner.h b/qilib/parsers/lispLike_scanner.h --- a/qilib/parsers/lispLike_scanner.h +++ b/qilib/parsers/lispLike_scanner.h @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #ifndef LISPLIKE_SCANNER_H #define LISPLIKE_SCANNER_H #if ! defined(yyFlexLexerOnce) diff --git a/qilib/qicadnet.cpp b/qilib/qicadnet.cpp --- a/qilib/qicadnet.cpp +++ b/qilib/qicadnet.cpp @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #include "qicadnet.h" QIlib::QIcadNet::QIcadNet() diff --git a/qilib/qicadnet.h b/qilib/qicadnet.h --- a/qilib/qicadnet.h +++ b/qilib/qicadnet.h @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #ifndef QINET_H #define QINET_H #include diff --git a/qilib/qicadnetlist.cpp b/qilib/qicadnetlist.cpp --- a/qilib/qicadnetlist.cpp +++ b/qilib/qicadnetlist.cpp @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #include "qicadnetlist.h" #include @@ -116,9 +137,9 @@ void QIlib::QIcadNetList::updateConcrete -QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper() +QIlib::QIcadAbstractNodeWrapper::QIcadAbstractNodeWrapper(AbstractNode *node) { - + this->p_node = node; } QIlib::QIcadAbstractNodeWrapper::~QIcadAbstractNodeWrapper() @@ -130,3 +151,50 @@ QIlib::QIcadAbstractNodeWrapper::~QIcadA delete this->childs.at(i); } } + +QString QIlib::QIcadAbstractNodeWrapper::value() +{ + if((p_node->Values.count()>0) && p_node) + return p_node->Values.at(0); + return QString(""); +} + +QString QIlib::QIcadAbstractNodeWrapper::value(int index) +{ + if((p_node->Values.count()>index) && p_node) + return p_node->Values.at(index); + return QString(""); +} + +QString QIlib::QIcadAbstractNodeWrapper::catValues() +{ + if(p_node) + { + QString result(""); + for(int i=0;iValues.count();i++) + { + result.append(p_node->Values.at(i)); + } + return result; + } +} + +void QIlib::QIcadAbstractNodeWrapper::setNode(QIlib::AbstractNode *node) +{ + this->p_node = node; +} + + + +QIlib::QIcadNetListRoot::QIcadNetListRoot(QIlib::AbstractNode *node) + :QIcadAbstractNodeWrapper(node) +{ + +} + + +QIlib::QIcadNetListComponent::QIcadNetListComponent(QIlib::AbstractNode *node) + :QIcadAbstractNodeWrapper(node) +{ + +} diff --git a/qilib/qicadnetlist.h b/qilib/qicadnetlist.h --- a/qilib/qicadnetlist.h +++ b/qilib/qicadnetlist.h @@ -2,6 +2,27 @@ #define QICADNETLIST_H #include #include +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #include #include #include @@ -113,15 +134,128 @@ public: class QIcadAbstractNodeWrapper { public: - QIcadAbstractNodeWrapper(); + QIcadAbstractNodeWrapper(QIlib::AbstractNode* node); ~QIcadAbstractNodeWrapper(); QString value(); + QString value(int index); + QString catValues(); + void setNode(QIlib::AbstractNode* node); QList childs; QIcadAbstractNodeWrapper* parent; + private: - QIlib::AbstractNode* node; + QIlib::AbstractNode* p_node; +}; + +class QIcadNetListRoot : public AbstractNode +{ +public: + QIcadNetListRoot(QIlib::AbstractNode* node); + QIcadAbstractNodeWrapper source; + QIcadAbstractNodeWrapper date; + QIcadAbstractNodeWrapper tool; + QList components; + QList libparts; + QList libraries; +}; + + + /* + * (comp (ref IC1) + (value 24L-MOD-8) + (libsource (lib guan) (part 24L-MOD-8)) + (sheetpath (names /) (tstamps /)) + (tstamp 52533BBE)) +*/ +class QIcadNetListComponent:public QIcadAbstractNodeWrapper +{ +public: + QIcadNetListComponent(AbstractNode* node); + QIcadAbstractNodeWrapper ref; + QIcadAbstractNodeWrapper value; + QIcadAbstractNodeWrapper libsource; + QIcadAbstractNodeWrapper sheetpath; + QIcadAbstractNodeWrapper tstamp; +}; + + +/* +(libparts + (libpart (lib guan) (part 24L-MOD-8) + (fields + (field (name Reference) IC) + (field (name Value) 24L-MOD-8)) + (pins + (pin (num 1) (name GND) (type power_in)) + (pin (num 2) (name VCC) (type power_in)) +*/ +class QIcadNetListField : QIcadAbstractNodeWrapper +{ +public: + QIcadNetListField(AbstractNode* node); + QIcadAbstractNodeWrapper name; }; + +class QIcadNetListLibPart : QIcadAbstractNodeWrapper +{ + class QIcadNetListPin : QIcadAbstractNodeWrapper + { + public: + QIcadNetListPin(AbstractNode* node); + QIcadAbstractNodeWrapper type; + QIcadAbstractNodeWrapper num; + QIcadAbstractNodeWrapper name; + }; +public: + QIcadNetListLibPart(AbstractNode* node); + QList fields; + QList pins; +}; + +/* +(libraries + (library (logical guan) + (uri /home/guan/boards/guan.lib)) + (library (logical device) + (uri /usr/share/kicad/library/device.lib)) + (library (logical conn) + (uri /usr/share/kicad/library/conn.lib))) +*/ + +class QIcadNetListLibrary : QIcadAbstractNodeWrapper +{ +public: + QIcadNetListLibrary(AbstractNode* node); + QIcadAbstractNodeWrapper uri; +}; +/* +(nets + (net (code 15) (name "") + (node (ref C4) (pin 1)) + (node (ref U2) (pin 4))) + (net (code 16) (name GND) + (node (ref D1) (pin 2)) + (node (ref C1) (pin 2)) + (node (ref IC1) (pin 1)) +*/ + +class QIcadNetListNet : QIcadAbstractNodeWrapper +{ + class QIcadNetListNetNode: QIcadAbstractNodeWrapper + { + public: + QIcadNetListNetNode(AbstractNode* node); + QIcadAbstractNodeWrapper ref; + QIcadAbstractNodeWrapper pin; + }; +public: + QIcadNetListNet(AbstractNode* node); + QList NetNodes; +}; + + + class QIcadNetList : private lispLike_Driver { public: @@ -135,6 +269,7 @@ public: QList libparts; QIcadNetListLevel rootSheet; QString print(); + QIcadAbstractNodeWrapper netlistRoot; private: QIlib::AbstractNode* getAbstractNode(const QString& node,int index); QIlib::AbstractNode* getAbstractNode(QIlib::AbstractNode* rootNode,const QString& node,int* index); diff --git a/test/dumpLispLikeFiles/main.cpp b/test/dumpLispLikeFiles/main.cpp --- a/test/dumpLispLikeFiles/main.cpp +++ b/test/dumpLispLikeFiles/main.cpp @@ -1,3 +1,24 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the Kicad Tools Software +-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ #include #include #include diff --git a/test/testFiles/netlist1.net b/test/testFiles/netlist1.net --- a/test/testFiles/netlist1.net +++ b/test/testFiles/netlist1.net @@ -408,4 +408,4 @@ (net (code 45) (name "") (node (ref U1) (pin 3))) (net (code 46) (name "") - (node (ref U1) (pin 5))))) \ No newline at end of file + (node (ref U1) (pin 5)))))