yyless.c 387 B

1234567891011121314151617181920212223242526
  1. #include <libl.h>
  2. #include <stdio.h>
  3. extern char yytext[];
  4. extern int yyleng;
  5. extern int yyprevious;
  6. void yyunput(int c);
  7. void
  8. yyless(int x)
  9. {
  10. char *lastch, *ptr;
  11. lastch = yytext+yyleng;
  12. if(x>=0 && x <= yyleng)
  13. ptr = x + yytext;
  14. else
  15. ptr = (char*)x;
  16. while(lastch > ptr)
  17. yyunput(*--lastch);
  18. *lastch = 0;
  19. if (ptr >yytext)
  20. yyprevious = *--lastch;
  21. yyleng = ptr-yytext;
  22. }