stage1_2/iec.flex
changeset 131 f55ef301e14c
parent 86 1988bf1634da
child 136 32bd7ef40897
equal deleted inserted replaced
130:a8263f33123f 131:f55ef301e14c
  1502    * a second time when they are processed again by flex.
  1502    * a second time when they are processed again by flex.
  1503    * We therefore determine how many newlines are in the text we are returning,
  1503    * We therefore determine how many newlines are in the text we are returning,
  1504    * and decrement the line counter acordingly...
  1504    * and decrement the line counter acordingly...
  1505    */
  1505    */
  1506   unsigned int i;
  1506   unsigned int i;
       
  1507   unsigned int line_number = 0;
       
  1508   int before_yylineno = yylineno;
  1507 
  1509 
  1508   for (i = n; i < strlen(yytext); i++)
  1510   for (i = n; i < strlen(yytext); i++)
  1509     if (yytext[i] == '\n')
  1511     if (yytext[i] == '\n')
  1510       yylineno--;
  1512       line_number++;
  1511 
  1513 
  1512   /* now return all the text back to the input stream... */
  1514   /* now return all the text back to the input stream... */
  1513   yyless(n);
  1515   yyless(n);
       
  1516   
       
  1517   if (line_number > 0 && before_yylineno == yylineno)
       
  1518     yylineno = yylineno - line_number;
  1514 }
  1519 }
  1515 
  1520 
  1516 
  1521 
  1517 /* Called by flex when it reaches the end-of-file */
  1522 /* Called by flex when it reaches the end-of-file */
  1518 int yywrap(void)
  1523 int yywrap(void)