stage1_2/iec_bison.yy
changeset 919 8da635655f37
parent 909 8b2a31dea131
child 923 0ad7843d3790
equal deleted inserted replaced
918:e9bde0aa93ed 919:8da635655f37
   412 %token	EN
   412 %token	EN
   413 %token	ENO
   413 %token	ENO
   414 %type <leaf>	en_identifier
   414 %type <leaf>	en_identifier
   415 %type <leaf>	eno_identifier
   415 %type <leaf>	eno_identifier
   416 
   416 
   417 /* Keyword in IEC 61131-3 v3 */
   417 /* Keywords in IEC 61131-3 v3 */
   418 %token	REF
   418 %token	REF
   419 %token	REF_TO
   419 %token	REF_TO
       
   420 %token	NULL_token  /* cannot use simply 'NULL', as it conflicts with the NULL keyword in C++ */
   420 
   421 
   421 
   422 
   422 
   423 
   423 /***************************/
   424 /***************************/
   424 /* B 0 - Programming Model */
   425 /* B 0 - Programming Model */
   442 /*********************/
   443 /*********************/
   443 /* B 1.2 - Constants */
   444 /* B 1.2 - Constants */
   444 /*********************/
   445 /*********************/
   445 %type <leaf>	constant
   446 %type <leaf>	constant
   446 %type <leaf>	non_int_or_real_constant
   447 %type <leaf>	non_int_or_real_constant
       
   448 
       
   449 /*********************************/
       
   450 /* B 1.2.XX - Reference Literals */
       
   451 /*********************************/
       
   452 /* NOTE: The following syntax was added by MJS in order to add support for the NULL keyword, defined in  IEC 61131-3 v3
       
   453  *       In v3 expressions that reduce to a reference datatype (REF_TO) are handled explicitly in the syntax 
       
   454  *       (e.g., any variable that is a of reference datatpe falls under the 'ref_name' rule), which means 
       
   455  *       that we would need to keep track of which variables are declared as REF_TO. 
       
   456  *       In order to reduce the changes to the current IEC 61131-3 v2 syntax, I have opted not to do this,
       
   457  *       and simply let the ref_expressions (Ref_Assign, Ref_Compare) be interpreted as all other standard expressions 
       
   458  *       in v2. However, ref_expressions allow the use of the 'NULL' constant, which is handled explicitly
       
   459  *       in the ref_expressions syntax of v3.
       
   460  *       To allow the use of the 'NULL' constant in this extended v2, I have opted to interpret this 'NULL' constant 
       
   461  *       as a literal.
       
   462  */
       
   463 %type  <leaf>	ref_value_null_literal  /* defined in IEC 61131-3 v3 - Basically the 'NULL' keyword! */
       
   464 
   447 
   465 
   448 /******************************/
   466 /******************************/
   449 /* B 1.2.1 - Numeric Literals */
   467 /* B 1.2.1 - Numeric Literals */
   450 /******************************/
   468 /******************************/
   451 /* Done totally within flex...
   469 /* Done totally within flex...
  1775 | integer
  1793 | integer
  1776 /* NOTE: unsigned_integer, although used in some
  1794 /* NOTE: unsigned_integer, although used in some
  1777  * rules, is not defined in the spec!
  1795  * rules, is not defined in the spec!
  1778  * We therefore replaced unsigned_integer as integer
  1796  * We therefore replaced unsigned_integer as integer
  1779  */
  1797  */
       
  1798 | ref_value_null_literal /* defined in IEC 61131-3 v3. Basically the 'NULL' keyword! */
  1780 ;
  1799 ;
  1781 
  1800 
  1782 
  1801 
  1783 
  1802 
  1784 
  1803 
  1806  * For the above reason, our definition of the numeric_literal construct
  1825  * For the above reason, our definition of the numeric_literal construct
  1807  * is missing the integer and real constrcuts (when not preceded by a sign)
  1826  * is missing the integer and real constrcuts (when not preceded by a sign)
  1808  */
  1827  */
  1809 ;
  1828 ;
  1810 
  1829 
       
  1830 /*********************************/
       
  1831 /* B 1.2.XX - Reference Literals */
       
  1832 /*********************************/
       
  1833 /* NOTE: The following syntax was added by MJS in order to add support for the NULL keyword, defined in  IEC 61131-3 v3
       
  1834  *       Please read the comment where the 'ref_value_null_literal' is declared as a <leaf> 
       
  1835  */
       
  1836 /* defined in IEC 61131-3 v3 - Basically the 'NULL' keyword! */
       
  1837 ref_value_null_literal: 
       
  1838   NULL_token	{$$ = new ref_value_null_literal_c(locloc(@$));}
       
  1839 ;
  1811 
  1840 
  1812 /******************************/
  1841 /******************************/
  1813 /* B 1.2.1 - Numeric Literals */
  1842 /* B 1.2.1 - Numeric Literals */
  1814 /******************************/
  1843 /******************************/
  1815 /* NOTES:
  1844 /* NOTES: