etisserant@0: /* msousa@267: * matiec - a compiler for the programming languages defined in IEC 61131-3 etisserant@0: * msousa@267: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) Edouard@279: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant etisserant@0: * msousa@267: * This program is free software: you can redistribute it and/or modify msousa@267: * it under the terms of the GNU General Public License as published by msousa@267: * the Free Software Foundation, either version 3 of the License, or msousa@267: * (at your option) any later version. msousa@267: * msousa@267: * This program is distributed in the hope that it will be useful, msousa@267: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@267: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@267: * GNU General Public License for more details. msousa@267: * msousa@267: * You should have received a copy of the GNU General Public License msousa@267: * along with this program. If not, see . msousa@267: * etisserant@0: * etisserant@0: * This code is made available on the understanding that it will not be etisserant@0: * used in safety-critical situations without a full and competent review. etisserant@0: */ etisserant@0: etisserant@0: /* msousa@267: * An IEC 61131-3 compiler. etisserant@0: * etisserant@0: * Based on the etisserant@0: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) etisserant@0: * etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: /* etisserant@0: * This file contains the code that stores the output generated etisserant@0: * by each specific version of the 4th stage. etisserant@0: */ etisserant@0: conti@746: #ifndef _STAGE4_HH conti@746: #define _STAGE4_HH etisserant@0: etisserant@0: #include "../absyntax/absyntax.hh" etisserant@0: msousa@522: msousa@522: void stage4err(const char *stage4_generator_id, symbol_c *symbol1, symbol_c *symbol2, const char *errmsg, ...); msousa@522: msousa@522: etisserant@0: class stage4out_c { etisserant@0: public: etisserant@0: std::string indent_level; etisserant@0: std::string indent_spaces; etisserant@0: etisserant@0: public: etisserant@0: stage4out_c(std::string indent_level = " "); lbessard@46: stage4out_c(const char *dir, const char *radix, const char *extension, std::string indent_level = " "); etisserant@0: ~stage4out_c(void); msousa@296: msousa@296: void flush(void); msousa@296: msousa@267: void enable_output(void); msousa@267: void disable_output(void); msousa@267: etisserant@0: void indent_right(void); etisserant@0: void indent_left(void); etisserant@0: msousa@594: void *print( std::string value); msousa@594: void *print( const char *value); msousa@594: //void *print( int64_t value); // not required, since we have long long int, or similar msousa@594: //void *print( uint64_t value); // not required, since we have long long int, or similar msousa@594: void *print( real64_t value); msousa@594: void *print( int value); msousa@594: void *print( long int value); msousa@594: void *print( long long int value); msousa@594: void *print(unsigned int value); msousa@594: void *print(unsigned long int value); msousa@594: void *print(unsigned long long int value); lbessard@28: laurent@397: void *print_long_integer(unsigned long l_integer, bool suffix=true); laurent@397: void *print_long_long_integer(unsigned long long ll_integer, bool suffix=true); etisserant@0: msousa@580: etisserant@0: void *printupper(const char *str); etisserant@0: void *printupper(std::string str); etisserant@26: etisserant@26: void *printlocation(const char *str); etisserant@26: void *printlocation(std::string str); etisserant@26: etisserant@55: void *printlocation_comasep(const char *str); etisserant@55: etisserant@27: protected: etisserant@27: std::ostream *out; etisserant@27: std::fstream *m_file; msousa@267: msousa@267: /* A flag to tell whether to really print to the file, or to ignore any request to print to the file */ msousa@267: /* This is used to implement the no_code_generation pragmas, that lets the user tell the compiler msousa@267: * when to switch on and off the code generation, without stoping the lexical, syntatical, and msousa@267: * semantic analysers from analysing the code. msousa@267: */ msousa@267: bool allow_output; etisserant@27: etisserant@0: }; etisserant@0: etisserant@0: etisserant@0: conti@746: int stage4(symbol_c *tree_root, const char *builddir); etisserant@0: conti@746: #endif /* _STAGE4_HH */