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.

68 lines
2.0 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef SIMC_SCANNER_H
  5. #define SIMC_SCANNER_H
  6. class SIMCParser;
  7. /*
  8. * This is the SIMCScanner class that forms the scanner (tokenizer)
  9. * used by the SIMCParser class, which is the parser. The SIMCScanner
  10. * class is derived form the yy_scan class that is generated by the
  11. * MKS LEX utility from the information in the lex.l file.
  12. *
  13. * It adds functionality to it, like column numbers, naming the
  14. * input stream, and redefining yyerror().
  15. */
  16. class SIMCScanner : public yy_scan
  17. {
  18. CString _inputStreamName;
  19. // The parser that is making use of this scanner currently.
  20. // This value *has* to be set by the parser, if it makes
  21. // a call to yy_scan::yyerror, since this value is used there
  22. SIMCParser *_theParser;
  23. public:
  24. // Create s scanner, by specifying a parser. If this is specified
  25. // as null, it has to be set using the SetParser() function, before
  26. // it is used
  27. SIMCScanner(SIMCParser * parser = NULL);
  28. ~SIMCScanner();
  29. // Various ways of setting the input that is scanned. This is used as
  30. // the source. NOTE: Only the second one has been tested (ie., the
  31. // one that specifies an input file name
  32. BOOL SetInput(ifstream& inputStream);
  33. BOOL SetInput(const CString& inputFile);
  34. BOOL SetInput(const int fd = 0);
  35. BOOL SetInput(FILE * fileStream);
  36. // Column number. Make it public, as is the LEX tradition
  37. long columnNo;
  38. virtual void output(int);
  39. // Sets the parse that uses this scanner currently
  40. void SetParser(SIMCParser *parser)
  41. {
  42. _theParser = parser;
  43. }
  44. SIMCParser *GetParser() const
  45. {
  46. return _theParser;
  47. }
  48. // The redefinition of yy_scan.yyerror() to suit our needs
  49. // of error reporting
  50. virtual void yyerror (char *fmt, ...);
  51. inline const char * const GetInputStreamName() const
  52. {
  53. return _inputStreamName;
  54. }
  55. void SetInputStreamName( const CString& streamName);
  56. };
  57. #endif SIMC_SCANNER_H