stage1_2/iec.flex
changeset 287 9df7fcb9bde5
parent 286 a4f4990d5c66
child 350 2c3c4dc34979
equal deleted inserted replaced
286:a4f4990d5c66 287:9df7fcb9bde5
   177     result = GetNextChar(buf, max_size);\
   177     result = GetNextChar(buf, max_size);\
   178     if (  result <= 0  )\
   178     if (  result <= 0  )\
   179       result = YY_NULL;\
   179       result = YY_NULL;\
   180     }
   180     }
   181 
   181 
       
   182 
       
   183 /* A counter to track the order by which each token is processed.
       
   184  * NOTE: This counter is not exactly linear (i.e., it does not get incremented by 1 for each token).
       
   185  *       i.e.. it may get incremented by more than one between two consecutive tokens.
       
   186  *       This is due to the fact that the counter gets incremented every 'user action' in flex,
       
   187  *       however not every user action will result in a token being passed to bison.
       
   188  *       Nevertheless this is still OK, as we are only interested in the relative
       
   189  *       ordering of tokens...
       
   190  */
       
   191 static long int current_order = 0;
       
   192 
       
   193 
   182 /* Macro that is executed for every action.
   194 /* Macro that is executed for every action.
   183  * We use it to pass the location of the token
   195  * We use it to pass the location of the token
   184  * back to the bison parser...
   196  * back to the bison parser...
   185  */
   197  */
   186 #define YY_USER_ACTION {\
   198 #define YY_USER_ACTION {\
   187 	yylloc.first_line = current_tracking->lineNumber;\
   199 	yylloc.first_line = current_tracking->lineNumber;			\
   188 	yylloc.first_column = current_tracking->currentTokenStart;\
   200 	yylloc.first_column = current_tracking->currentTokenStart;		\
   189 	yylloc.first_file = current_filename;\
   201 	yylloc.first_file = current_filename;					\
   190 	yylloc.last_line = current_tracking->lineNumber;\
   202 	yylloc.first_order = current_order;					\
   191 	yylloc.last_column = current_tracking->currentChar - 1;\
   203 	yylloc.last_line = current_tracking->lineNumber;			\
   192 	yylloc.last_file = current_filename;\
   204 	yylloc.last_column = current_tracking->currentChar - 1;			\
   193 	current_tracking->currentTokenStart = current_tracking->currentChar;\
   205 	yylloc.last_file = current_filename;					\
       
   206 	yylloc.last_order = current_order;					\
       
   207 	current_tracking->currentTokenStart = current_tracking->currentChar;	\
       
   208 	current_order++;							\
   194 	}
   209 	}
   195 
   210 
   196 
   211 
   197 /* Since this lexical parser we defined only works in ASCII based
   212 /* Since this lexical parser we defined only works in ASCII based
   198  * systems, we might as well make sure it is being compiled on
   213  * systems, we might as well make sure it is being compiled on