main.cc
changeset 375 7a11f9e9e703
parent 374 01068ccb73b2
child 516 8591746fa134
--- a/main.cc	Wed Sep 07 19:28:10 2011 +0200
+++ b/main.cc	Thu Sep 08 20:25:00 2011 +0200
@@ -75,16 +75,22 @@
 
 /* A macro for printing out internal parser errors... */
 #include <iostream> // required for std::cerr
-#define ERROR error_exit(__FILE__,__LINE__)
+
+#ifndef HGVERSION
+#define HGVERSION ""
+#endif
+
+#define ERROR          error_exit(__FILE__,__LINE__)
 void error_exit(const char *file_name, int line_no) {
-  std::cerr << "\nInternal program error in file " << file_name
-            << " at line " << line_no << "\n\n\n";
+  std::cerr << "\nInternal compiler error in file " << file_name
+            << " at line " << line_no << "\n";
+//   if (msg != NULL) std::cerr << message << "\n\n";
   exit(EXIT_FAILURE);
 }
 
 
 
-
+#include "config/config.h"
 #include "stage1_2/stage1_2.hh"
 #include "absyntax_utils/absyntax_utils.hh"
 
@@ -93,9 +99,10 @@
 
 
 static void printusage(const char *cmd) {
-  printf("syntax: %s [-h] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
+  printf("syntax: %s [-h] [-v] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
   printf("  h : show this help message\n");
-  printf("  f : full token location on error messages\n");
+  printf("  v : print version number\n");  
+  printf("  f : display full token location on error messages\n");
       /******************************************************/
       /* whether we are suporting safe extensions           */
       /* as defined in PLCopen - Technical Committee 5      */
@@ -107,7 +114,7 @@
   printf("\n");
   printf("%s - Copyright (C) 2003-2011 \n"
          "This program comes with ABSOLUTELY NO WARRANTY!\n"
-         "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", cmd);
+         "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", PACKAGE_NAME);
 }
 
 
@@ -125,12 +132,15 @@
   /******************************************/
   /*   Parse command line options...        */
   /******************************************/
-  while ((optres = getopt(argc, argv, ":hfsI:T:")) != -1) {
+  while ((optres = getopt(argc, argv, ":hvfsI:T:")) != -1) {
     switch(optres) {
     case 'h':
       printusage(argv[0]);
       return 0;
-      break;
+    case 'v':
+      fprintf(stdout, "%s version %s\n"
+		      "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
+      return 0;        
     case 'f':
       stage1_2_options.full_token_loc = true;
       break;
@@ -169,6 +179,7 @@
   }
 
   if (errflg) {
+      printf("\n");
       printusage(argv[0]);
       return EXIT_FAILURE;
   }