73 #include <stdlib.h> // EXIT_FAILURE |
73 #include <stdlib.h> // EXIT_FAILURE |
74 #include "absyntax/absyntax.hh" // symbol_c type |
74 #include "absyntax/absyntax.hh" // symbol_c type |
75 |
75 |
76 /* A macro for printing out internal parser errors... */ |
76 /* A macro for printing out internal parser errors... */ |
77 #include <iostream> // required for std::cerr |
77 #include <iostream> // required for std::cerr |
78 #define ERROR error_exit(__FILE__,__LINE__) |
78 |
|
79 #ifndef HGVERSION |
|
80 #define HGVERSION "" |
|
81 #endif |
|
82 |
|
83 #define ERROR error_exit(__FILE__,__LINE__) |
79 void error_exit(const char *file_name, int line_no) { |
84 void error_exit(const char *file_name, int line_no) { |
80 std::cerr << "\nInternal program error in file " << file_name |
85 std::cerr << "\nInternal compiler error in file " << file_name |
81 << " at line " << line_no << "\n\n\n"; |
86 << " at line " << line_no << "\n"; |
|
87 // if (msg != NULL) std::cerr << message << "\n\n"; |
82 exit(EXIT_FAILURE); |
88 exit(EXIT_FAILURE); |
83 } |
89 } |
84 |
90 |
85 |
91 |
86 |
92 |
87 |
93 #include "config/config.h" |
88 #include "stage1_2/stage1_2.hh" |
94 #include "stage1_2/stage1_2.hh" |
89 #include "absyntax_utils/absyntax_utils.hh" |
95 #include "absyntax_utils/absyntax_utils.hh" |
90 |
96 |
91 int stage3(symbol_c *tree_root); |
97 int stage3(symbol_c *tree_root); |
92 int stage4(symbol_c *tree_root, const char *builddir); |
98 int stage4(symbol_c *tree_root, const char *builddir); |
93 |
99 |
94 |
100 |
95 static void printusage(const char *cmd) { |
101 static void printusage(const char *cmd) { |
96 printf("syntax: %s [-h] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd); |
102 printf("syntax: %s [-h] [-v] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd); |
97 printf(" h : show this help message\n"); |
103 printf(" h : show this help message\n"); |
98 printf(" f : full token location on error messages\n"); |
104 printf(" v : print version number\n"); |
|
105 printf(" f : display full token location on error messages\n"); |
99 /******************************************************/ |
106 /******************************************************/ |
100 /* whether we are suporting safe extensions */ |
107 /* whether we are suporting safe extensions */ |
101 /* as defined in PLCopen - Technical Committee 5 */ |
108 /* as defined in PLCopen - Technical Committee 5 */ |
102 /* Safety Software Technical Specification, */ |
109 /* Safety Software Technical Specification, */ |
103 /* Part 1: Concepts and Function Blocks, */ |
110 /* Part 1: Concepts and Function Blocks, */ |
105 /******************************************************/ |
112 /******************************************************/ |
106 printf(" s : allow use of safe extensions\n"); |
113 printf(" s : allow use of safe extensions\n"); |
107 printf("\n"); |
114 printf("\n"); |
108 printf("%s - Copyright (C) 2003-2011 \n" |
115 printf("%s - Copyright (C) 2003-2011 \n" |
109 "This program comes with ABSOLUTELY NO WARRANTY!\n" |
116 "This program comes with ABSOLUTELY NO WARRANTY!\n" |
110 "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", cmd); |
117 "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); |
111 } |
118 } |
112 |
119 |
113 |
120 |
114 |
121 |
115 int main(int argc, char **argv) { |
122 int main(int argc, char **argv) { |
123 */ |
130 */ |
124 |
131 |
125 /******************************************/ |
132 /******************************************/ |
126 /* Parse command line options... */ |
133 /* Parse command line options... */ |
127 /******************************************/ |
134 /******************************************/ |
128 while ((optres = getopt(argc, argv, ":hfsI:T:")) != -1) { |
135 while ((optres = getopt(argc, argv, ":hvfsI:T:")) != -1) { |
129 switch(optres) { |
136 switch(optres) { |
130 case 'h': |
137 case 'h': |
131 printusage(argv[0]); |
138 printusage(argv[0]); |
132 return 0; |
139 return 0; |
133 break; |
140 case 'v': |
|
141 fprintf(stdout, "%s version %s\n" |
|
142 "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION); |
|
143 return 0; |
134 case 'f': |
144 case 'f': |
135 stage1_2_options.full_token_loc = true; |
145 stage1_2_options.full_token_loc = true; |
136 break; |
146 break; |
137 case 's': |
147 case 's': |
138 stage1_2_options.safe_extensions = true; |
148 stage1_2_options.safe_extensions = true; |