5137 ; |
5137 ; |
5138 |
5138 |
5139 initial_step: |
5139 initial_step: |
5140 INITIAL_STEP step_name ':' action_association_list END_STEP |
5140 INITIAL_STEP step_name ':' action_association_list END_STEP |
5141 // INITIAL_STEP identifier ':' action_association_list END_STEP |
5141 // INITIAL_STEP identifier ':' action_association_list END_STEP |
5142 {$$ = new initial_step_c($2, $4, locloc(@$));} |
5142 {$$ = new initial_step_c($2, $4, locloc(@$)); |
|
5143 variable_name_symtable.insert($2, prev_declared_variable_name_token); // A step name may later be used as a structured variable!! |
|
5144 } |
5143 /* ERROR_CHECK_BEGIN */ |
5145 /* ERROR_CHECK_BEGIN */ |
5144 | INITIAL_STEP ':' action_association_list END_STEP |
5146 | INITIAL_STEP ':' action_association_list END_STEP |
5145 {$$ = NULL; print_err_msg(locf(@1), locl(@2), "no step name defined in initial step declaration."); yynerrs++;} |
5147 {$$ = NULL; print_err_msg(locf(@1), locl(@2), "no step name defined in initial step declaration."); yynerrs++;} |
5146 | INITIAL_STEP error ':' action_association_list END_STEP |
5148 | INITIAL_STEP error ':' action_association_list END_STEP |
5147 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in initial step declaration."); yyerrok;} |
5149 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in initial step declaration."); yyerrok;} |
5157 ; |
5159 ; |
5158 |
5160 |
5159 step: |
5161 step: |
5160 STEP step_name ':' action_association_list END_STEP |
5162 STEP step_name ':' action_association_list END_STEP |
5161 // STEP identifier ':' action_association_list END_STEP |
5163 // STEP identifier ':' action_association_list END_STEP |
5162 {$$ = new step_c($2, $4, locloc(@$));} |
5164 {$$ = new step_c($2, $4, locloc(@$)); |
|
5165 variable_name_symtable.insert($2, prev_declared_variable_name_token); // A step name may later be used as a structured variable!! |
|
5166 } |
5163 /* ERROR_CHECK_BEGIN */ |
5167 /* ERROR_CHECK_BEGIN */ |
5164 | STEP ':' action_association_list END_STEP |
5168 | STEP ':' action_association_list END_STEP |
5165 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no step name defined in step declaration."); yynerrs++;} |
5169 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no step name defined in step declaration."); yynerrs++;} |
5166 | STEP error ':' action_association_list END_STEP |
5170 | STEP error ':' action_association_list END_STEP |
5167 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in step declaration."); yyerrok;} |
5171 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in step declaration."); yyerrok;} |
5259 | SD {$$ = new timed_qualifier_c(strdup("SD"), locloc(@$));} |
5263 | SD {$$ = new timed_qualifier_c(strdup("SD"), locloc(@$));} |
5260 | DS {$$ = new timed_qualifier_c(strdup("DS"), locloc(@$));} |
5264 | DS {$$ = new timed_qualifier_c(strdup("DS"), locloc(@$));} |
5261 | SL {$$ = new timed_qualifier_c(strdup("SL"), locloc(@$));} |
5265 | SL {$$ = new timed_qualifier_c(strdup("SL"), locloc(@$));} |
5262 ; |
5266 ; |
5263 |
5267 |
|
5268 /* NOTE: A step_name may be used as a structured vaqriable, in order to access the status bit (e.g. Step1.X) |
|
5269 * or the time it has been active (e.g. Step1.T). |
|
5270 * In order to allow the step name to be used as a variable inside ST expressions (only ST expressions ??) |
|
5271 * when defining transitions, we need to add the step_name to the list of previously declared variables. |
|
5272 * This allows the step name to be used as a variable inside all transition expressions, as the user |
|
5273 * can clearly define the transition _after_ the step itself has been defined/declared, so the |
|
5274 * 'variable' is previously 'declared'. |
|
5275 * |
|
5276 * However, when defining/declaring a step, a variable name can also be used to define a timed |
|
5277 * action association. In this case, we may have a circular reference: |
|
5278 * e.g. |
|
5279 * ... |
|
5280 * STEP step1: |
|
5281 * action1 (D,t#100ms); |
|
5282 * end_step |
|
5283 * |
|
5284 * STEP step2: |
|
5285 * action1 (D,step3.T); <---- forward reference to step3.T !!!!!! |
|
5286 * end_step |
|
5287 * |
|
5288 * STEP step3: |
|
5289 * action1 (D,step2.T); <---- back reference to step2.T |
|
5290 * end_step |
|
5291 * |
|
5292 * |
|
5293 * There is no way the user can always use the step3.T variable only after it has |
|
5294 * been 'declared'. So adding the steps to the list of previously declared variables |
|
5295 * when the steps are declared is not a solution to the above situation. |
|
5296 * |
|
5297 * Fortunately, the standard does not allow ST expressions in the above syntax |
|
5298 * (i.e. when defining the delay of a timed actions), but only either a |
|
5299 * Time literal, or a variable. |
|
5300 * This is why we change the definition of action_time from |
|
5301 * action_time: |
|
5302 * duration |
|
5303 * | variable |
|
5304 * ; |
|
5305 * |
|
5306 * to: |
|
5307 * action_time: |
|
5308 * duration |
|
5309 * | any_symbolic_variable |
|
5310 * ; |
|
5311 * |
|
5312 * NOTE that this same problem does not occur with the 'indicator_name': it does not |
|
5313 * make sense to set/indicate a step1.X variable, as these variables are read-only! |
|
5314 */ |
|
5315 |
5264 action_time: |
5316 action_time: |
5265 duration |
5317 duration |
5266 | variable |
5318 //| variable |
|
5319 | any_symbolic_variable |
5267 ; |
5320 ; |
5268 |
5321 |
5269 indicator_name: variable; |
5322 indicator_name: variable; |
5270 |
5323 |
5271 // transition_name: identifier; |
5324 // transition_name: identifier; |