skip.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* $Header$ */
  2. /* PREPROCESSOR: INPUT SKIP FUNCTIONS */
  3. #include "nopp.h"
  4. #include "arith.h"
  5. #include "LLlex.h"
  6. #include "class.h"
  7. #include "input.h"
  8. #include "interface.h"
  9. #ifndef NOPP
  10. PRIVATE int
  11. skipspaces(ch)
  12. register int ch;
  13. {
  14. /* skipspaces() skips any white space and returns the first
  15. non-space character.
  16. */
  17. for (;;) {
  18. while (class(ch) == STSKIP)
  19. LoadChar(ch);
  20. /* How about "\\\n"????????? */
  21. if (ch == '/') {
  22. LoadChar(ch);
  23. if (ch == '*') {
  24. skipcomment();
  25. LoadChar(ch);
  26. }
  27. else {
  28. PushBack();
  29. return '/';
  30. }
  31. }
  32. else
  33. return ch;
  34. }
  35. }
  36. #endif NOPP
  37. PRIVATE
  38. skipline()
  39. {
  40. /* skipline() skips all characters until a newline character
  41. is seen, not escaped by a '\\'.
  42. Any comment is skipped.
  43. */
  44. register int c;
  45. LoadChar(c);
  46. while (class(c) != STNL && c != EOI) {
  47. if (c == '\\') {
  48. LoadChar(c);
  49. if (class(c) == STNL)
  50. ++LineNumber;
  51. }
  52. if (c == '/') {
  53. LoadChar(c);
  54. if (c == '*')
  55. skipcomment();
  56. else
  57. continue;
  58. }
  59. LoadChar(c);
  60. }
  61. ++LineNumber;
  62. if (c == EOI) { /* garbage input... */
  63. lexerror("unexpected EOF while skipping text");
  64. PushBack();
  65. }
  66. }