merge
authorMario de Sousa <msousa@fe.up.pt>
Sat, 18 Mar 2017 22:15:19 +0000
changeset 1036 1000db86d0af
parent 1035 0a58b2720976 (diff)
parent 1025 c43f1c254180 (current diff)
child 1037 bf39078476e4
merge
--- a/configure.ac	Wed Oct 12 17:54:52 2016 +0300
+++ b/configure.ac	Sat Mar 18 22:15:19 2017 +0000
@@ -42,6 +42,10 @@
   (exit 1); exit 1;
 fi
 
+if test "x$LEX" == "x:"; then
+   AC_MSG_ERROR("flex/lex is missing")
+fi
+
 # Checks for header files.
 AC_CHECK_HEADERS([float.h limits.h stdint.h stdlib.h string.h strings.h sys/timeb.h unistd.h])
 
--- a/lib/C/iec_std_lib.h	Wed Oct 12 17:54:52 2016 +0300
+++ b/lib/C/iec_std_lib.h	Sat Mar 18 22:15:19 2017 +0000
@@ -318,7 +318,7 @@
 	  days += __isleap(dt.tm_year) ? 366 : 365;
   }
   dt.tm_mon = 1;
-  while (days > __mon_yday[__isleap(dt.tm_year)][dt.tm_mon]) {
+  while (days >= __mon_yday[__isleap(dt.tm_year)][dt.tm_mon]) {
 	  dt.tm_mon += 1;
   }
   dt.tm_day = days - __mon_yday[__isleap(dt.tm_year)][dt.tm_mon - 1] + 1;
--- a/stage1_2/iec_bison.yy	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage1_2/iec_bison.yy	Sat Mar 18 22:15:19 2017 +0000
@@ -5846,17 +5846,17 @@
 
 
 transition_condition:
-  ':' eol_list simple_instr_list
-	{$$ = new transition_condition_c($3, NULL, locloc(@$));}
+ start_IL_body_token ':' eol_list simple_instr_list
+	{$$ = new transition_condition_c($4, NULL, locloc(@$));}
 | ASSIGN expression ';'
 	{$$ = new transition_condition_c(NULL, $2, locloc(@$));}
 /* ERROR_CHECK_BEGIN */
-| eol_list simple_instr_list
-	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing before IL condition in transition declaration."); yynerrs++;}
-| ':' eol_list error
+| start_IL_body_token eol_list simple_instr_list
+	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':' missing before IL condition in transition declaration."); yynerrs++;}
+| start_IL_body_token ':' eol_list error
 	{$$ = NULL;
-	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no instructions defined in IL condition of transition declaration.");}
-	 else {print_err_msg(locf(@3), locl(@3), "invalid instructions in IL condition of transition declaration."); yyclearin;}
+	 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no instructions defined in IL condition of transition declaration.");}
+	 else {print_err_msg(locf(@4), locl(@4), "invalid instructions in IL condition of transition declaration."); yyclearin;}
 	 yyerrok;
 	}
 | ASSIGN ';'
--- a/stage1_2/iec_flex.ll	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage1_2/iec_flex.ll	Sat Mar 18 22:15:19 2017 +0000
@@ -1193,10 +1193,11 @@
 				  else				 	{append_bodystate_buffer(yytext);}
 				}
  
-	/* check if ';' occurs before an END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM or END_ACTION. (If true => we are parsing ST; If false => parsing IL). */
+	/* check if ';' occurs before an END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM, END_ACTION or END_TRANSITION. (If true => we are parsing ST; If false => parsing IL). */
 END_ACTION			| /* execute the next rule's action, i.e. fall-through! */
 END_FUNCTION			|
 END_FUNCTION_BLOCK		|
+END_TRANSITION   		|
 END_PROGRAM			{ append_bodystate_buffer(yytext); unput_bodystate_buffer(); BEGIN(il_state); /*printf("returning start_IL_body_token\n");*/ return start_IL_body_token;}
 .|\n				{ append_bodystate_buffer(yytext);
 				  if (strcmp(yytext, ";") == 0)
--- a/stage3/narrow_candidate_datatypes.cc	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage3/narrow_candidate_datatypes.cc	Sat Mar 18 22:15:19 2017 +0000
@@ -930,6 +930,20 @@
 	return NULL;
 }
 
+
+void *narrow_candidate_datatypes_c::visit(action_qualifier_c *symbol) {
+	if (symbol->action_time) {
+		for(unsigned int i = 0; i < symbol->action_time->candidate_datatypes.size(); i++) {
+			if (get_datatype_info_c::is_TIME_compatible(symbol->action_time->candidate_datatypes[i]))
+				symbol->action_time->datatype = symbol->action_time->candidate_datatypes[i];
+		}
+		symbol->action_time->accept(*this);
+	}
+	symbol->action_qualifier->accept(*this); // Not really necessary for now...
+	return NULL;
+}
+    
+
 /********************************/
 /* B 1.7 Configuration elements */
 /********************************/
--- a/stage3/narrow_candidate_datatypes.hh	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage3/narrow_candidate_datatypes.hh	Sat Mar 18 22:15:19 2017 +0000
@@ -249,6 +249,7 @@
     /* B 1.6 Sequential function chart elements */
     /********************************************/
     void *visit(transition_condition_c *symbol);
+    void *visit(action_qualifier_c     *symbol);
 
     /********************************/
     /* B 1.7 Configuration elements */
--- a/stage4/generate_c/generate_c_sfc.cc	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage4/generate_c/generate_c_sfc.cc	Sat Mar 18 22:15:19 2017 +0000
@@ -577,7 +577,7 @@
               s4o.print(s4o.indent_spaces + "if (active && __time_cmp(");
               print_step_argument(current_step, "T.value");
               s4o.print(", ");
-              symbol->action_time->accept(*this);
+              symbol->action_time->accept(*generate_c_st);
               if (strcmp(qualifier, "L") == 0)
                 s4o.print(") < 0) ");
               else
@@ -618,7 +618,7 @@
               s4o.print(" = 1;\n" + s4o.indent_spaces);
               print_action_argument(current_action, "reset_remaining_time");
               s4o.print(" = ");
-              symbol->action_time->accept(*this);
+              symbol->action_time->accept(*generate_c_st);
               s4o.print(";\n");
               s4o.indent_left();
               s4o.print(s4o.indent_spaces + "}\n");
@@ -632,7 +632,7 @@
               s4o.print("\n" + s4o.indent_spaces);
               print_action_argument(current_action, "set_remaining_time");
               s4o.print(" = ");
-              symbol->action_time->accept(*this);
+              symbol->action_time->accept(*generate_c_st);
               s4o.print(";\n");
               s4o.indent_left();
               s4o.print(s4o.indent_spaces + "}\n");
--- a/stage4/generate_c/generate_c_st.cc	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage4/generate_c/generate_c_st.cc	Sat Mar 18 22:15:19 2017 +0000
@@ -593,7 +593,7 @@
 
 void *visit(xor_expression_c *symbol) {
   if (get_datatype_info_c::is_BOOL_compatible(symbol->datatype)) {
-    s4o.print("(");
+    s4o.print("((");
     symbol->l_exp->accept(*this);
     s4o.print(" && !");
     symbol->r_exp->accept(*this);
@@ -601,7 +601,7 @@
     symbol->l_exp->accept(*this);
     s4o.print(" && ");
     symbol->r_exp->accept(*this);
-    s4o.print(")");
+    s4o.print("))");
     return NULL;
   }
   if (get_datatype_info_c::is_ANY_nBIT_compatible(symbol->datatype))
--- a/stage4/generate_c/generate_c_vardecl.cc	Wed Oct 12 17:54:52 2016 +0300
+++ b/stage4/generate_c/generate_c_vardecl.cc	Sat Mar 18 22:15:19 2017 +0000
@@ -2137,6 +2137,7 @@
           }
           print_retain();
           s4o.print(")");
+          current_varqualifier = none_vq;
 #if 0
       /* The following code would be for globalinit_vf !!
        * But it is not currently required...