vhdl_scanner.cpp
64 lines
| 2.2 KiB
| text/x-c
|
CppLexer
r0 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the VHDL 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 "vhdl_scanner.h" | ||||
#include <QDebug> | ||||
r1 | VHDL_Tools::vhdl_Scanner::vhdl_Scanner(std::istream *in, const QString &fileName) | |||
r0 | : yyFlexLexer(in) | |||
{ | ||||
r1 | this->rootNode = new VHDL_Tools::VHDL_AST_Node(fileName,VHDL_Tools::rootNode); | |||
this->currentNode = rootNode; | ||||
r2 | this->rootNode->setParent(this->rootNode); | |||
r0 | } | |||
r1 | VHDL_Tools::vhdl_Scanner::~vhdl_Scanner() | |||
{ | ||||
r2 | delete rootNode; | |||
r1 | } | |||
r0 | int VHDL_Tools::vhdl_Scanner::scan() | |||
{ | ||||
return( yylex() ); | ||||
} | ||||
r1 | int VHDL_Tools::vhdl_Scanner::newFile(std::istream *in, const QString &fileName,bool trashPreviousTree) | |||
r0 | { | |||
r1 | switch_streams(in); | |||
if(trashPreviousTree) | ||||
r2 | delete rootNode; | |||
this->yylineno=1; | ||||
this->yycolumn=1; | ||||
r1 | this->rootNode = new VHDL_Tools::VHDL_AST_Node(fileName,VHDL_Tools::rootNode); | |||
this->currentNode = rootNode; | ||||
r2 | this->rootNode->setParent(this->rootNode); | |||
r1 | return 1; | |||
r0 | } | |||
r1 | ||||
r0 | void VHDL_Tools::vhdl_Scanner::appendNode(VHDL_Tools::VHDL_AST_Node *node) | |||
{ | ||||
r2 | node->move(currentNode); | |||
// this->currentNode->childs.append(node); | ||||
// node->parent = this->currentNode; | ||||
r1 | this->currentNode = node; | |||
r0 | } | |||