merge
authormjsousa
Sat, 05 Jul 2014 14:10:28 +0100
changeset 902 38dca2e264b6
parent 901 6a3964be6a29 (current diff)
parent 894 39086e324665 (diff)
child 903 f712705bef65
merge
stage4/generate_c/generate_c.cc
--- a/stage1_2/Makefile.am	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage1_2/Makefile.am	Sat Jul 05 14:10:28 2014 +0100
@@ -5,12 +5,15 @@
 
 # Make sure this header file is generated first (by bison), as it is included
 # by other C++ code that will also be compiled.
-BUILT_SOURCES = iec_bison.h
+BUILT_SOURCES = iec_bison.hh
+
+%.hh: %.h
+	cp $< $@
 
 CLEANFILES = \
 	iec_flex.cc \
 	iec_bison.cc \
-	iec_bison.h
+	iec_bison.hh
 
 lib_LIBRARIES = libstage1_2.a
 libstage1_2_a_SOURCES = \
@@ -19,5 +22,5 @@
     create_enumtype_conversion_functions.cc \
 	stage1_2.cc 
 
-libstage1_2_a_CPPFLAGS =  -DDEFAULT_LIBDIR='"lib"' -I../../absyntax -DYY_BUF_SIZE=65536
+libstage1_2_a_CPPFLAGS =  -DDEFAULT_LIBDIR='"lib"' -I../../absyntax -DYY_BUF_SIZE=65536 -fpermissive
 
--- a/stage1_2/iec_bison.yy	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage1_2/iec_bison.yy	Sat Jul 05 14:10:28 2014 +0100
@@ -96,7 +96,7 @@
 #include "../absyntax/absyntax.hh"
 
 /* file with declaration of token constants. Generated by bison! */
-#include "iec_bison.h"
+#include "iec_bison.hh"
 
 /* The interface through which bison and flex interact. */
 #include "stage1_2_priv.hh"
@@ -169,10 +169,10 @@
 /* global variables...   */
 /*************************/
 /* NOTE: For some strange reason bison ver 2.3 is including these declarations
- *       in the iec_bison.h file, which is in turn included by flex.
+ *       in the iec_bison.hh file, which is in turn included by flex.
  *       We cannot therefore define any variables over here, but merely declare 
  *       their existance (otherwise we get errors when linking the code, since we
- *       would get a new variable defined each time iec_bison.h is included!).
+ *       would get a new variable defined each time iec_bison.hh is included!).
  *       Even though the variables are declared 'extern' over here, they will in
  *       fact be defined towards the end of this same file (i.e. in the prologue)
  */
@@ -250,14 +250,14 @@
 /* The following definitions need to be inside a '%code requires' 
  * so that they are also included in the header files. If this were not the case,
  * YYLTYPE would be delcared as something in the iec.cc file, and another thing
- * (actually the default value of YYLTYPE) in the iec_bison.h heder file.
+ * (actually the default value of YYLTYPE) in the iec_bison.hh heder file.
  */
 %code requires {
 /* define a new data type to store the locations, so we can also store
  * the filename in which the token is expressed.
  */
-/* NOTE: since this code will be placed in the iec_bison.h header file,
- * as well as the iec.cc file that also includes the iec_bison.h header file,
+/* NOTE: since this code will be placed in the iec_bison.hh header file,
+ * as well as the iec.cc file that also includes the iec_bison.hh header file,
  * declaring the typedef struct yyltype__local here would result in a 
  * compilation error when compiling iec.cc, as this struct would be
  * declared twice.
--- a/stage1_2/iec_flex.ll	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage1_2/iec_flex.ll	Sat Jul 05 14:10:28 2014 +0100
@@ -124,17 +124,17 @@
 /* Required only for the declaration of abstract syntax classes
  * (class symbol_c; class token_c; class list_c;)
  * These will not be used in flex, but the token type union defined
- * in iec_bison.h contains pointers to these classes, so we must include
+ * in iec_bison.hh contains pointers to these classes, so we must include
  * it here.
  */
 #include "../absyntax/absyntax.hh"
 
 
-/* iec_bison.h is generated by bison.
+/* iec_bison.hh is generated by bison.
  * Contains the definition of the token constants, and the
  * token value type YYSTYPE (in our case, a 'const char *')
  */
-#include "iec_bison.h"
+#include "iec_bison.hh"
 #include "stage1_2_priv.hh"
 
 
--- a/stage1_2/stage1_2.cc	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage1_2/stage1_2.cc	Sat Jul 05 14:10:28 2014 +0100
@@ -44,7 +44,7 @@
 
 
 #include "stage1_2.hh"
-#include "iec_bison.h"
+#include "iec_bison.hh"
 #include "stage1_2_priv.hh"
 #include "create_enumtype_conversion_functions.hh"
 
@@ -135,14 +135,14 @@
 /* NOTE: only accessed indirectly by the lexical parser (flex)
  *       through the function get_identifier_token()
  */
-/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.h.
+/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.hh.
  *       We need this constant defined before we can declare the symbol tables.
- *       However, we cannot #include "iec_bison.h" in this file (stage1_2_priv.hh) directly
+ *       However, we cannot #include "iec_bison.hh" in this file (stage1_2_priv.hh) directly
  *       because of the way bison ver. 3.2 is copying all declarations in the prologue
- *       of iec.y to the iec_bison.h file (including an #include stage1_2_priv.hh).
- *       So, if we were to include "iec_bison.h" here, we would get a circular include.
+ *       of iec.y to the iec_bison.hh file (including an #include stage1_2_priv.hh).
+ *       So, if we were to include "iec_bison.hh" here, we would get a circular include.
  *       All this means that whoever includes this file (stage1_2_priv.hh) will need
- *       to take care to first inlcude iec_bison.h !!
+ *       to take care to first inlcude iec_bison.hh !!
  */ 
 /* A symbol table to store all the library elements */
 /* e.g.: <function_name , function_decl>
--- a/stage1_2/stage1_2_priv.hh	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage1_2/stage1_2_priv.hh	Sat Jul 05 14:10:28 2014 +0100
@@ -40,10 +40,10 @@
 /* !!! WARNING !!!
  *
  *       Whoever includes this file (stage1_2_priv.hh) will need
- *       to first inlcude iec_bison.h !!
+ *       to first inlcude iec_bison.hh !!
  *
  *       Read other comments further down to understand why we don't
- *       include iec_bison.h in this file.
+ *       include iec_bison.hh in this file.
  */
 
 
@@ -194,14 +194,14 @@
  *
  *       In essence, they are a data passing mechanism between Bison and Flex.
  */
-/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.h.
+/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.hh.
  *       We need this constant defined before we can declare the symbol tables.
- *       However, we cannot #include "iec_bison.h" in this file (stage1_2_priv.hh) directly
+ *       However, we cannot #include "iec_bison.hh" in this file (stage1_2_priv.hh) directly
  *       because of the way bison ver. 2.3 is copying all declarations in the prologue
- *       of iec.y to the iec_bison.h file (including an #include stage1_2_priv.hh).
- *       So, if we were to include "iec_bison.h" here, we would get a circular include.
+ *       of iec.y to the iec_bison.hh file (including an #include stage1_2_priv.hh).
+ *       So, if we were to include "iec_bison.hh" here, we would get a circular include.
  *       All this means that whoever includes this file (stage1_2_priv.hh) will need
- *       to take care to first inlcude iec_bison.h !!
+ *       to take care to first inlcude iec_bison.hh !!
  */ 
 /* A symbol table to store all the library elements */
 /* e.g.: <function_name , function_decl>
--- a/stage4/generate_c/generate_c.cc	Sat Jul 05 13:57:39 2014 +0100
+++ b/stage4/generate_c/generate_c.cc	Sat Jul 05 14:10:28 2014 +0100
@@ -170,11 +170,12 @@
 /***********************************************************************/
 /***********************************************************************/
 
+
+static int generate_line_directives__ = 0;
+
+#ifdef __unix__
 /* Parse command line options passed from main.c !! */
 #include <stdlib.h> // for getsybopt()
-
-static int generate_line_directives__ = 0;
-
 int  stage4_parse_options(char *options) {
   enum {                    LINE_OPT = 0             /*, SOME_OTHER_OPT, YET_ANOTHER_OPT */};
   char *const token[] = { /*[LINE_OPT]=*/(char *)"l" /*, SOME_OTHER_OPT, ...             */, NULL };
@@ -198,7 +199,12 @@
   printf("          (options must be separated by commas. Example: 'l,w,x')\n"); 
   printf("      l : insert '#line' directives in generated C code.\n"); 
 }
-
+#else /* not __unix__ */
+/* getsubopt isn't supported with mingw, 
+ *  then stage4 options aren't available on windows*/
+void stage4_print_options(void) {}
+int  stage4_parse_options(char *options) {}
+#endif 
 
 /***********************************************************************/
 /***********************************************************************/