absyntax/absyntax.def
changeset 471 da650a87662d
parent 459 01f6664bf8c5
child 476 38d85e9a0507
equal deleted inserted replaced
470:d2cd05c5e01a 471:da650a87662d
   162  *       real_c or integer_c with the value being negated.
   162  *       real_c or integer_c with the value being negated.
   163  *          neg_literal_c -> integer_literal_c
   163  *          neg_literal_c -> integer_literal_c
   164  *                OR
   164  *                OR
   165  *          neg_literal_c -> real_literal_c
   165  *          neg_literal_c -> real_literal_c
   166  *
   166  *
   167  *      In the semantic verification and code generation stages of the compiler,
   167  *       However, this has since been changed to...
   168  *      the integer_c is treated as a basic (undefined) data type, since an integer
       
   169  *      constant may be used as a BYTE, BOOLEAN, REAL, etc..., depending on the
       
   170  *      context in which it is used.
       
   171  *      However, an integer_c that is preceded by a '-' may not be used
       
   172  *      as an ANY_BIT data type (BYTE, BOOLEAN, WORD, ...).
       
   173  *      We must therefore be able to determine, holding a simple pointer
       
   174  *      to an integer_c, if that integer_c value is preceded by a '-'.
       
   175  *      However, since the neg_literal_c points to the integer_c, and not
       
   176  *      vice-versa, we can't determine that.
       
   177  *      There are 3 simple ways of working around this:
       
   178  *        - change the order of the pointers: 
       
   179  *              have the integer_c and real_c point to the neg_literal_c
       
   180  *        - maintain the order of the pointers, and
       
   181  *              add redundant info to the integer_c and real_c
       
   182  *        - replace the neg_literal_c with two distinc classes
   168  *        - replace the neg_literal_c with two distinc classes
   183  *              (neg_integer_c and neg_real_c), one for each
   169  *              (neg_integer_c and neg_real_c), one for each
   184  *              lietral type. This means that we can now treat
   170  *              lietral type. 
   185  *              each of these classes as an unknown data type
   171  *
   186  *              just as we do with the integer_c and real_c.
   172  *       This change was done in order to ease the writing of semantic verification (stage3) code.
   187  *
   173  *       However, that version of the code has since been replaced by a newer and better algoritm.
   188  *      The second option is simply ugly.
   174  *       This means the above change can now be undone, but there is really no need to undo it,
   189  *      and the first has a serious drawback: when generating code it is
   175  *       so we leave it as it is.
   190  *      easier to encapsulate the real or integer values inside prefix
       
   191  *      and postfix symbols (e.g. NEG(<value>) - with postfix ')' )
       
   192  *      if we keep the pointer order as is.
       
   193  *
       
   194  *      For the above reasoning, we use the third option.
       
   195  */  
   176  */  
   196 SYM_REF1(neg_real_c, exp)
   177 SYM_REF1(neg_real_c, exp)
   197 SYM_REF1(neg_integer_c, exp)
   178 SYM_REF1(neg_integer_c, exp)
   198 
   179 
   199 /* Not required:
   180 /* Not required: