stage1_2/iec_bison.yy
changeset 873 dea39ef02847
parent 862 2b6b1202f8a8
child 876 e2c4f6f4abe2
equal deleted inserted replaced
872:3d682f87c870 873:dea39ef02847
   410 %token	EN
   410 %token	EN
   411 %token	ENO
   411 %token	ENO
   412 %type <leaf>	en_identifier
   412 %type <leaf>	en_identifier
   413 %type <leaf>	eno_identifier
   413 %type <leaf>	eno_identifier
   414 
   414 
       
   415 /* Keyword in IEC 61131-3 v3 */
       
   416 %token	REF
   415 
   417 
   416 
   418 
   417 
   419 
   418 /***************************/
   420 /***************************/
   419 /* B 0 - Programming Model */
   421 /* B 0 - Programming Model */
  1288  *    - unary_operator, multiply_operator,
  1290  *    - unary_operator, multiply_operator,
  1289  *      add_operator and comparison_operator
  1291  *      add_operator and comparison_operator
  1290  *      are not required. Their values are integrated
  1292  *      are not required. Their values are integrated
  1291  *      directly into other rules...
  1293  *      directly into other rules...
  1292  */
  1294  */
       
  1295 %type  <leaf>	ref_expression  /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
  1293 %type  <leaf>	expression
  1296 %type  <leaf>	expression
  1294 %type  <leaf>	xor_expression
  1297 %type  <leaf>	xor_expression
  1295 %type  <leaf>	and_expression
  1298 %type  <leaf>	and_expression
  1296 %type  <leaf>	comparison
  1299 %type  <leaf>	comparison
  1297 %type  <leaf>	equ_expression
  1300 %type  <leaf>	equ_expression
  7055 /***********************/
  7058 /***********************/
  7056 /* B 3.1 - Expressions */
  7059 /* B 3.1 - Expressions */
  7057 /***********************/
  7060 /***********************/
  7058 expression:
  7061 expression:
  7059   xor_expression
  7062   xor_expression
       
  7063 | ref_expression  /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
  7060 | expression OR xor_expression
  7064 | expression OR xor_expression
  7061 	{$$ = new or_expression_c($1, $3, locloc(@$));}
  7065 	{$$ = new or_expression_c($1, $3, locloc(@$));}
  7062 /* ERROR_CHECK_BEGIN */
  7066 /* ERROR_CHECK_BEGIN */
  7063 | expression OR error
  7067 | expression OR error
  7064   {$$ = NULL;
  7068   {$$ = NULL;
  7065 	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'OR' in ST expression.");}
  7069 	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'OR' in ST expression.");}
  7066 	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'OR' in ST expression."); yyclearin;}
  7070 	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'OR' in ST expression."); yyclearin;}
  7067 	 yyerrok;
  7071 	 yyerrok;
  7068 	}
  7072 	}
  7069 /* ERROR_CHECK_END */
  7073 /* ERROR_CHECK_END */
       
  7074 ;
       
  7075 
       
  7076 /*  REF(var_name) */
       
  7077 /*  This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */
       
  7078 /*  The REF() operator returns the adrress of the variable. Basically, it returns a pointer to the variable */
       
  7079 ref_expression:
       
  7080   REF '(' symbolic_variable ')'
       
  7081 	{$$ = new ref_expression_c($3, locloc(@$));}
  7070 ;
  7082 ;
  7071 
  7083 
  7072 xor_expression:
  7084 xor_expression:
  7073   and_expression
  7085   and_expression
  7074 | xor_expression XOR and_expression
  7086 | xor_expression XOR and_expression