File: FAUhdlc.hpp

package info (click to toggle)
fauhdlc 20180504-3.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 3,064 kB
  • sloc: cpp: 23,188; ansic: 6,077; yacc: 3,764; lex: 763; makefile: 605; python: 412; xml: 403; sh: 61
file content (129 lines) | stat: -rw-r--r-- 3,181 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* $Id$ 
 *
 * Copyright (C) 2007-2010 FAUmachine Team <info@faumachine.org>.
 * This program is free software. You can redistribute it and/or modify it
 * under the terms of the GNU General Public License, either version 2 of
 * the License, or (at your option) any later version. See COPYING.
 */

#ifndef __FAUHDLC_HPP_INCLUDED
#define __FAUHDLC_HPP_INCLUDED

#include <list>
#include <iostream>
#include <string>
#include "frontend/ast/AstNode.hpp"
#include "frontend/misc/SymbolTable.hpp"
#include "intermediate/Node.hpp"

namespace compiler {

//! main compiler class.
class FAUhdlc {
public:
	//! c'tor
	FAUhdlc();

	//! d'tor
	~FAUhdlc();

	//! parse the command line arguments
	/** @param argc number of command line arguments.
          * @param argv vector of command line arguments.
          */
	void parseCmdLine(int argc, char **argv);

	//! compile.
	/** @return exit status */
	int run();

private:
	/** possible error codes */
	enum ResultCodes {
		FAUHDLC_EXIT_SUCCESS = 0, 	//!< everything ok.
		FAUHDLC_EXIT_COMMAND_ARGS = 1,	//!< wrong command line args
		FAUHDLC_EXIT_ERROR = 3, //!< compile error was found
		FAUHDLC_EXIT_EXCEPTION = 4	//!< other Exception occured
	};

	//! mapping class for filename to library name
	struct LibFile {
		std::string *filename; 	//!< full path to file.
		const char *library;	//!< name of library in which file is.
	};

	//! display command line usage.
	/** @param out stream on which usage should be put. */
	void usage(std::ostream &out) const;

	//! parse a file
	void doParse(void);

	//! do the semantic analysis
	void doSemanticAnalysis(void);

	//! write out any warnings/errors 
	void putCompileMessages(void);

	//! perform transformations on intermediate code
	/** currently, this will only write the intermediate code to 
	 *  the output file, in case one was specified.
	 *  More to come.
	 */
	void doIntermediateTransform(void);

	//! print intermediate code to file.
	/** print intermediate code to file specified in
	 *  this->outfile.
	 */
	void printICode(void);

	//! generate C code from intermediate code
	/** generate C code from intermediate code and output
	 *  it to file specified in this->cFile.
	 */
	void genCCode(void);

	/** top AST node. */
	ast::AstNode *topNode;

	/** stop after parsing */
	bool parseOnly;

	/** generate dot file after parsing. */
	bool dotParse;

	/** result code reported back to main */
	enum ResultCodes resultCode;

	/** file that should get compiled */
	std::list<struct LibFile*> sourceFiles;

	/** filename of the dot file after parsing */
	const char *dotParseFile;
	
	/** name of the output file */
	const char *outputFile;

	/** symbol table used in first steps of semantic analysis */
	ast::SymbolTable *symbolTable;

	/** intermediate code top node. */
	intermediate::Node *iTopNode;

	/** create dot file after constant propagation? */
	bool dotConst;

	/** filename of the dot file after constant propagation */
	const char *dotConstFile;

	/** freestanding mode? (don't load common libraries like std_logic */
	bool freeStanding;

	/** filename of C output file. */
	const char *cFile;
};

}; /* namespace compiler */

#endif /* __FAUHDLC_HPP_INCLUDED */