iverilog/tgt-vhdl/vhdl_element.hh

55 lines
1.5 KiB
C++
Raw Normal View History

/*
* VHDL abstract syntax elements.
*
* Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk)
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef INC_VHDL_ELEMENT_HH
#define INC_VHDL_ELEMENT_HH
#include <fstream>
2008-05-29 17:24:16 +02:00
#include <list>
#include <string>
2008-06-06 18:36:15 +02:00
typedef std::list<std::string> string_list_t;
2008-06-02 01:12:47 +02:00
/*
* Any VHDL syntax element. Each element can also contain a comment.
*/
class vhdl_element {
public:
virtual ~vhdl_element() {}
2008-05-29 17:24:16 +02:00
virtual void emit(std::ofstream &of, int level=0) const = 0;
void set_comment(std::string comment);
protected:
void emit_comment(std::ofstream &of, int level,
bool end_of_line=false) const;
2008-05-29 17:24:16 +02:00
private:
std::string comment_;
};
typedef std::list<vhdl_element*> element_list_t;
int indent(int level);
void newline(std::ofstream &of, int level);
void blank_line(std::ofstream &of, int level);
#endif
2008-05-29 17:24:16 +02:00