12 #include "libfaudes.h" 
   16 using namespace faudes;
 
   21 void usage_exit(
const std::string& message=
"") {
 
   23     std::cout << 
"compiledes: " << message << std::endl;
 
   24     std::cout << 
"" << std::endl;
 
   28   std::cout << 
"" << std::endl;
 
   29   std::cout << 
"compiledes: usage: " << std::endl;
 
   30   std::cout << 
"compiledes [-q][-v] -t <target> -o <outfile> <srcfile>"<< std::endl;
 
   31   std::cout << 
"where " << std::endl;
 
   32   std::cout << 
"  <scrfile>: code generator source file, typically \"*.cgc\"" << std::endl;
 
   33   std::cout << 
"" << std::endl;
 
   34   std::cout << 
"  -q:  less console output " << std::endl;
 
   35   std::cout << 
"  -qq: absolutely no console output " << std::endl;
 
   36   std::cout << 
"  -v:  more console output" << std::endl;
 
   37   std::cout << 
"  -vv: even more console output" << std::endl;
 
   38   std::cout << 
"" << std::endl;
 
   39   std::cout << 
"  -t <target>: target platform, see also below " << std::endl;
 
   40   std::cout << 
"  -o <outfile>: (base)name of output file(s), defaults to console output" << std::endl;
 
   41   std::cout << 
"" << std::endl;
 
   42   std::cout << 
"compiledes: target platforms: ";
 
   44   for(
size_t i=0; i<registry.size(); ++i)
 
   45       std::cout << registry[i] << 
" ";
 
   46   std::cout << 
"" << std::endl;
 
   47   std::cout << 
"" << std::endl;
 
   52 int main(
int argc, 
char* argv[]) {
 
   55   std::string mMark=
"% compiledes: ========================================= ";
 
   59   std::string mSrcFile=
"";
 
   60   std::string mOutFile=
"std::cout";
 
   61   std::string mTarget=
"";
 
   64   for(
int i=1; i<argc; i++) {
 
   65     std::string option(argv[i]);
 
   67     if((option==
"-q") || (option==
"--quiet")) {
 
   77     if((option==
"-v") || (option==
"--verbose")) {
 
   87     if((option==
"-o") || (option==
"--out")) {
 
   88       i++; 
if(i>=argc) usage_exit();
 
   93     if((option==
"-t") || (option==
"--target")) {
 
   94       i++; 
if(i>=argc) usage_exit();
 
   99     if((option==
"-?") || (option==
"--help")) {
 
  104     if(option.c_str()[0]==
'-') {
 
  105       usage_exit(
"unknown option "+ option);
 
  110       usage_exit(
"more than one source file specified" );
 
  116     usage_exit(
"you must specify a source file" );
 
  123     usage_exit(
"unknown target platform");
 
  126   mpCodeGenerator->
Verbose(mConsoleOut);
 
  130     mpCodeGenerator->Read(mSrcFile);
 
  132   catch(
const Exception& fe) {
 
  133     std::cout << std::flush;
 
  134     std::cerr << fe.Message() << std::endl;
 
  135     std::cerr << 
"CompileDES: caught libFAUDES exception --- missing/missformed configuration file" << std::endl;
 
  143   catch(
const Exception& fe) {
 
  144     std::cout << std::flush;
 
  145     std::cerr << fe.Message() << std::endl;
 
  146     std::cerr << 
"CompileDES: caught libFAUDES exception --- failed to setup output file/console or output filters" << std::endl;
 
  154   catch(
const Exception& fe) {
 
  155     std::cout << std::flush;
 
  156     std::cerr << fe.Message() << std::endl;
 
  157     std::cerr << 
"CompileDES: caught libFAUDES exception --- failed to compile configuration data to internal representation" << std::endl;
 
  165   catch(
const Exception& fe) {
 
  166     std::cout << std::flush;
 
  167     std::cerr << fe.Message() << std::endl;
 
  168     std::cerr << 
"CompileDES: caught libFAUDES exception --- failed to generate target code for specified options" << std::endl;
 
Code-generator common base class.
 
Code-generation common base.
 
static std::vector< std::string > Registry(void)
Access registry contents.
 
virtual void OutputMode(const std::string &mode)
Set code output mode.
 
static CodeGenerator * New(const std::string &type)
Instantiate by identifier (returns 0 on unknown class)
 
void Verbose(int level, std::ostream *altout=0)
Set verbosity level.
 
static std::string VersionString(void)
Version (refers to macro COMPILEDES_VERSION, defined in cgp_codegenerator.h)
 
virtual void Compile(void)
Compile input data for alternative representation.
 
virtual void Generate(void)
Generate code.