Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

  1. /*
  2. ** File: lexutils.hxx
  3. **
  4. ** Description: Helper functions for MIDL lexer
  5. ** Copyright (C) 1989-1999 Microsoft Corp.
  6. */
  7. /* there is a warning 3 (type conversion) in the next line...
  8. it has something to do with istream::get(char&).
  9. */
  10. #define ccgetc() (pbch?(pbch=0,ch):(cceof())?(char)0:((input_fileptr_G->get(ch),ch=='\n' )?(curr_line_G++,ch):(ch)))
  11. #define ccputbackc() (pbch=1)
  12. #define cceof() (input_fileptr_G->eof())
  13. typedef USHORT token_t;
  14. void StartImport();
  15. void CloseImport();
  16. void init_lex(void);
  17. token_t cnv_int(void);
  18. token_t cnv_hex(void);
  19. token_t cnv_octal(void);
  20. token_t cnv_float(void);
  21. long convert(char *ptr, short base);
  22. token_t name(void);
  23. token_t map_token(token_t);
  24. void lex_error(int);
  25. token_t lex(void);
  26. token_t comment(void);
  27. char convesc();
  28. extern short handle_import;
  29. #define AND '&'
  30. #define LBRACK '['
  31. #define RBRACK ']'
  32. #define LCURLY '{'
  33. #define RCURLY '}'
  34. #define LPAREN '('
  35. #define RPAREN ')'
  36. #define SEMI ';'
  37. #define COLON ':'
  38. #define COMMA ','
  39. #define DIV '/'
  40. #define EXCLAIM '!'
  41. #define MOD '%'
  42. #define PLUS '+'
  43. #define XOR '^'
  44. #define LT '<'
  45. #define GT '>'
  46. #define MINUS '-'
  47. #define MULT '*'
  48. #define ASSIGN '='
  49. #define OR '|'
  50. extern short curr_line_G;
  51. extern FILE * hFile_G;
  52. // chCached allows us to look two characters ahead instead
  53. // of one. If NewCCPutbackc is called once, the character
  54. // is put in chCached. If it's called twice, the character
  55. // that was previously in chCached is pushed back into the
  56. // stream and the second character is put into chCached.
  57. // Behavior is undefined if it's called a third time in succession.
  58. extern int chCached;
  59. // #define NewCCGetch() (char) (pImportCntrl->GetChar())
  60. inline
  61. char NewCCGetch()
  62. {
  63. char ch;
  64. if ( ( ch = (char) chCached ) != 0 )
  65. {
  66. chCached = 0;
  67. }
  68. else
  69. {
  70. if ( ( (ch = (char)getc(hFile_G) ) == EOF ) && feof(hFile_G) )
  71. return 0;
  72. }
  73. if ( ch == '\n' )
  74. curr_line_G++;
  75. return ch;
  76. }
  77. //#define NewCCputbackc(c) (char )(pImportCntrl->UnGetChar(c))
  78. extern
  79. char NewCCputbackc( char ch );