stage1_2/iec_flex.ll
changeset 1057 2b25052fadca
parent 1056 a47dc03f0e53
child 1065 0066fe31a034
equal deleted inserted replaced
1056:a47dc03f0e53 1057:2b25052fadca
  1131 	 *       or PROGAM.
  1131 	 *       or PROGAM.
  1132 	 * 
  1132 	 * 
  1133 	 * WARNING: From 2016-05 (May 2016) onwards, matiec supports a non-standard option in which a Function
  1133 	 * WARNING: From 2016-05 (May 2016) onwards, matiec supports a non-standard option in which a Function
  1134 	 *          may be declared with no Input, Output or IN_OUT variables. This means that the above 
  1134 	 *          may be declared with no Input, Output or IN_OUT variables. This means that the above 
  1135 	 *          assumption is no longer valid.
  1135 	 *          assumption is no longer valid.
  1136 	 *          To make things simpler (i.e. so we do not need to change the transition conditions in the flex state machine),
  1136 	 * 
  1137 	 *          when using this non-standard extension matiec requires that Functions must include at least one 
  1137 	 * NOTE: Some code being parsed may be erroneous and not contain any VAR END_VAR block.
  1138 	 *          VAR .. END_VAR block. This implies that the above assumption remains valid!
  1138 	 *       To generate error messages that make sense, the flex state machine should not get lost
  1139 	 *          This limitation of requiring a VAR .. END_VAR block is not really very limiting, as a function
  1139 	 *       in these situations. We therefore consider the possibility of finding 
  1140 	 *          with no input and output parameters will probably need to do some 'work', and for that it will
  1140 	 *       END_FUNCTION, END_FUNCTION_BLOCK or END_PROGRAM when inside the header_state.
  1141 	 *          probably need some local variables declared in a VAR .. END_VAR block.
       
  1142 	 *          Note however that in the extreme it might make sense to have a function with no variables whatsoever
       
  1143 	 *          (e.g.: a function that only calls other functions that all return VOID - another non standard extension!).
       
  1144 	 *          For now we do not consider this!!
       
  1145 	 */
  1141 	 */
  1146 <header_state>{
  1142 <header_state>{
  1147 VAR				| /* execute the next rule's action, i.e. fall-through! */
  1143 VAR				| /* execute the next rule's action, i.e. fall-through! */
  1148 VAR_INPUT			|
  1144 VAR_INPUT			|
  1149 VAR_OUTPUT			|
  1145 VAR_OUTPUT			|
  1150 VAR_IN_OUT			|
  1146 VAR_IN_OUT			|
  1151 VAR_EXTERNAL			|
  1147 VAR_EXTERNAL			|
  1152 VAR_GLOBAL			|
  1148 VAR_GLOBAL			|
  1153 VAR_TEMP			|
  1149 VAR_TEMP			|
  1154 VAR_CONFIG			|
  1150 VAR_CONFIG			|
  1155 VAR_ACCESS			unput_text(0); /* printf("\nChanging to vardecl_list_state\n") */; BEGIN(vardecl_list_state);
  1151 VAR_ACCESS			unput_text(0); BEGIN(vardecl_list_state);
       
  1152 
       
  1153 END_FUNCTION			| /* execute the next rule's action, i.e. fall-through! */
       
  1154 END_FUNCTION_BLOCK		| 
       
  1155 END_PROGRAM			unput_text(0); BEGIN(vardecl_list_state); 
       
  1156 				/* Notice that we do NOT go directly to body_state, as that requires a push().
       
  1157 				 * If we were to puch to body_state here, then the corresponding pop() at the
       
  1158 				 *end of body_state would return to header_state.
       
  1159 				 * After this pop() header_state would not return to INITIAL as it should, but
       
  1160 				 * would instead enter an infitie loop push()ing again to body_state
       
  1161 				 */
  1156 }
  1162 }
  1157 
  1163 
  1158 
  1164 
  1159 	/* vardecl_list_state -> (vardecl_state | body_state | INITIAL) */
  1165 	/* vardecl_list_state -> (vardecl_state | body_state | INITIAL) */
  1160 <vardecl_list_state>{
  1166 <vardecl_list_state>{