stage1_2/iec.y
changeset 287 9df7fcb9bde5
parent 286 a4f4990d5c66
child 295 e7ce7c6bbb5d
equal deleted inserted replaced
286:a4f4990d5c66 287:9df7fcb9bde5
   114 
   114 
   115 
   115 
   116 /* Macros used to pass the line and column locations when
   116 /* Macros used to pass the line and column locations when
   117  * creating a new object for the abstract syntax tree.
   117  * creating a new object for the abstract syntax tree.
   118  */
   118  */
   119 #define locloc(foo) foo.first_line, foo.first_column, foo.first_file, foo.last_line, foo.last_column, foo.last_file
   119 #define locloc(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order, foo.last_line, foo.last_column, foo.last_file, foo.last_order
   120 #define   locf(foo) foo.first_line, foo.first_column, foo.first_file
   120 #define   locf(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order
   121 #define   locl(foo) foo.last_line,  foo.last_column, foo.last_file
   121 #define   locl(foo) foo.last_line,  foo.last_column,  foo.last_file,  foo.last_order
   122 
   122 
   123 /* Redefine the default action to take for each rule, so that the filenames are correctly processed... */
   123 /* Redefine the default action to take for each rule, so that the filenames are correctly processed... */
   124 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
   124 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
   125          do                                                                  \
   125          do                                                                  \
   126            if (N)                                                            \
   126            if (N)                                                            \
   127              {                                                               \
   127              {                                                               \
   128                (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;         \
   128                (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;         \
   129                (Current).first_column = YYRHSLOC(Rhs, 1).first_column;       \
   129                (Current).first_column = YYRHSLOC(Rhs, 1).first_column;       \
   130                (Current).first_file   = YYRHSLOC(Rhs, 1).first_file;         \
   130                (Current).first_file   = YYRHSLOC(Rhs, 1).first_file;         \
       
   131                (Current).first_order  = YYRHSLOC(Rhs, 1).first_order;        \
   131                (Current).last_line    = YYRHSLOC(Rhs, N).last_line;          \
   132                (Current).last_line    = YYRHSLOC(Rhs, N).last_line;          \
   132                (Current).last_column  = YYRHSLOC(Rhs, N).last_column;        \
   133                (Current).last_column  = YYRHSLOC(Rhs, N).last_column;        \
   133                (Current).last_file    = YYRHSLOC(Rhs, 1).last_file;          \
   134                (Current).last_file    = YYRHSLOC(Rhs, 1).last_file;          \
       
   135                (Current).last_order   = YYRHSLOC(Rhs, 1).last_order;         \
   134              }                                                               \
   136              }                                                               \
   135            else                                                              \
   137            else                                                              \
   136              {                                                               \
   138              {                                                               \
   137                (Current).first_line   = (Current).last_line   =              \
   139                (Current).first_line   = (Current).last_line   =              \
   138                  YYRHSLOC(Rhs, 0).last_line;                                 \
   140                  YYRHSLOC(Rhs, 0).last_line;                                 \
   139                (Current).first_column = (Current).last_column =              \
   141                (Current).first_column = (Current).last_column =              \
   140                  YYRHSLOC(Rhs, 0).last_column;                               \
   142                  YYRHSLOC(Rhs, 0).last_column;                               \
   141                (Current).first_file   = (Current).last_file   =              \
   143                (Current).first_file   = (Current).last_file   =              \
   142                  YYRHSLOC(Rhs, 0).last_file;                                 \
   144                  YYRHSLOC(Rhs, 0).last_file;                                 \
       
   145                (Current).first_order  = (Current).last_order  =              \
       
   146                  YYRHSLOC(Rhs, 0).last_order;                                \
   143              }                                                               \
   147              }                                                               \
   144          while (0)
   148          while (0)
   145 
   149 
   146 
   150 
   147 /* A macro for printing out internal parser errors... */
   151 /* A macro for printing out internal parser errors... */
   203 
   207 
   204 /* print an error message */
   208 /* print an error message */
   205 void print_err_msg(int first_line,
   209 void print_err_msg(int first_line,
   206                    int first_column,
   210                    int first_column,
   207                    const char *first_filename,
   211                    const char *first_filename,
       
   212                    long int first_order,
   208                    int last_line,
   213                    int last_line,
   209                    int last_column,
   214                    int last_column,
   210                    const char *last_filename,
   215                    const char *last_filename,
       
   216                    long int last_order,
   211                    const char *additional_error_msg);
   217                    const char *additional_error_msg);
   212 %}
   218 %}
   213 
   219 
   214 
   220 
   215 
   221 
   243  * I (Mario) think this is kind of a hack. If you know how to
   249  * I (Mario) think this is kind of a hack. If you know how to
   244  * do this re-declaration of YYLTYPE properly, please let me know!
   250  * do this re-declaration of YYLTYPE properly, please let me know!
   245  */
   251  */
   246 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
   252 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
   247   typedef struct {
   253   typedef struct {
   248     int first_line;
   254     int         first_line;
   249     int first_column;
   255     int         first_column;
   250     const char *first_file;
   256     const char *first_file;
   251     int last_line;
   257     long int    first_order;
   252     int last_column;
   258     int         last_line;
       
   259     int         last_column;
   253     const char *last_file;
   260     const char *last_file;
       
   261     long int    last_order;
   254   } yyltype__local;
   262   } yyltype__local;
   255   #define YYLTYPE yyltype__local
   263   #define YYLTYPE yyltype__local
   256 #endif
   264 #endif
   257 }
   265 }
   258 
   266 
  7890 
  7898 
  7891 
  7899 
  7892 void print_err_msg(int first_line,
  7900 void print_err_msg(int first_line,
  7893                    int first_column,
  7901                    int first_column,
  7894                    const char *first_filename,
  7902                    const char *first_filename,
       
  7903                    long int first_order,
  7895                    int last_line,
  7904                    int last_line,
  7896                    int last_column,
  7905                    int last_column,
  7897                    const char *last_filename,
  7906                    const char *last_filename,
       
  7907                    long int last_order,
  7898                    const char *additional_error_msg) {
  7908                    const char *additional_error_msg) {
  7899 
  7909 
  7900   const char *unknown_file = "<unknown_file>";
  7910   const char *unknown_file = "<unknown_file>";
  7901   if (first_filename == NULL) first_filename = unknown_file;
  7911   if (first_filename == NULL) first_filename = unknown_file;
  7902   if ( last_filename == NULL)  last_filename = unknown_file;
  7912   if ( last_filename == NULL)  last_filename = unknown_file;
  7998 
  8008 
  7999   res = new identifier_c(strdup(name), 
  8009   res = new identifier_c(strdup(name), 
  8000                          il_operator->first_line,
  8010                          il_operator->first_line,
  8001                          il_operator->first_column,
  8011                          il_operator->first_column,
  8002                          il_operator->first_file,
  8012                          il_operator->first_file,
       
  8013                          il_operator->first_order,
  8003                          il_operator->last_line,
  8014                          il_operator->last_line,
  8004                          il_operator->last_column,
  8015                          il_operator->last_column,
  8005                          il_operator->last_file
  8016                          il_operator->last_file,
       
  8017                          il_operator->last_order
  8006                         );
  8018                         );
  8007   free(il_operator);
  8019   free(il_operator);
  8008   return res;
  8020   return res;
  8009 }
  8021 }
  8010 
  8022