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.

161 lines
4.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: YYBase.hxx
  7. //
  8. // Contents: Custom base class for YYPARSER
  9. //
  10. // History: 18-Apr-2000 KitmanH Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include "parsepl.h"
  15. #include <dynstack.hxx>
  16. #include <set.hxx>
  17. class YYLEXER;
  18. class CValueParser;
  19. typedef struct
  20. {
  21. CDbColId *pps;
  22. DBTYPE dbType;
  23. } PROPINFO;
  24. typedef struct
  25. {
  26. int iGenerateMethod;
  27. XPtrST<WCHAR> xwszPropName;
  28. } STATE;
  29. //+---------------------------------------------------------------------------
  30. //
  31. // Class: CTripYYBase
  32. //
  33. // Purpose: Custom base class for BYACC-based parser. Encapsulates
  34. // Tripoli-specific features and data members.
  35. //
  36. // History: 18-Apr-2000 KitmanH Created
  37. //
  38. //----------------------------------------------------------------------------
  39. class CTripYYBase
  40. {
  41. public:
  42. CTripYYBase( IColumnMapper & ColumnMapper,
  43. LCID & locale,
  44. YYLEXER & yylex );
  45. ~CTripYYBase();
  46. #ifdef YYAPI_VALUETYPE
  47. CDbRestriction* GetParseTreeEx(); // Get result of parse
  48. #endif
  49. //
  50. // Members used in YYPARSER
  51. //
  52. void InitState(void);
  53. void PushProperty(WCHAR const * wszProperty);
  54. void PopProperty(void);
  55. void SetCurrentGenerate(int iGenerateMethod);
  56. void SaveState(void);
  57. void RestoreState(void);
  58. void GetCurrentProperty(CDbColId ** pp_ps, DBTYPE *dbType);
  59. void GetCurrentGenerate(int *iGenerateMethod);
  60. void SetDebug();
  61. CDbContentRestriction *BuildPhrase(WCHAR *wcsPhrase, int iGenMethod);
  62. //
  63. // Lexer pass-through
  64. //
  65. void yyprimebuffer(const YY_CHAR *pszBuffer);
  66. protected:
  67. void triperror( char const * szError );
  68. YYLEXER & _yylex;
  69. void Trace(TCHAR *message);
  70. void Trace(TCHAR *message, const TCHAR *tokname, short state = 0);
  71. void Trace(TCHAR *message, int state, short tostate = 0, short token = 0);
  72. friend class YYLEXER;
  73. // Storage to get things de-allocated from the parser stack if the parser throws
  74. TSet< CDbRestriction > _setRst;
  75. TSet< CStorageVariant > _setStgVar;
  76. TSet< CValueParser > _setValueParser;
  77. // Remember state
  78. BOOL fDeferredPop;
  79. LCID _lcid;
  80. private:
  81. IColumnMapper & _ColumnMapper;
  82. STATE _currentState;
  83. CDynStack<STATE> _savedStates;
  84. CDynStack<WCHAR> _propNameStack;
  85. };
  86. //+---------------------------------------------------------------------------
  87. //
  88. // Class: CValueParser
  89. //
  90. // Purpose: To intepret a sequence of tokens from a scanner
  91. // and place the results in a CStorageVariant
  92. //
  93. // Notes: This class throws CParserException when errors occur.
  94. // Copied from CPropertyValueParser, and updated to
  95. // set value in AddValue rather than ctor.
  96. //
  97. // History: 02-Mar-95 t-colinb Created.
  98. // 01-Oct-97 emilyb copied from CPropertyValueParser
  99. // 02-Sep-98 KLam Added locale.
  100. //
  101. //----------------------------------------------------------------------------
  102. class CValueParser
  103. {
  104. public :
  105. CValueParser( BOOL fVectorElement, DBTYPE PropType, LCID locale );
  106. void AddValue(WCHAR const * pwszValue);
  107. CStorageVariant *AcquireStgVariant( void )
  108. {
  109. return _pStgVariant.Acquire();
  110. }
  111. CStorageVariant *GetStgVariant( void )
  112. {
  113. return _pStgVariant.GetPointer();
  114. }
  115. private :
  116. BOOL CheckForRelativeDate( WCHAR const * phrase, FILETIME & ft );
  117. void ParseDateTime( WCHAR const * phrase, FILETIME & ft );
  118. LCID _locale;
  119. XPtr<CStorageVariant> _pStgVariant;
  120. BOOL _fVector;
  121. DBTYPE _PropType;
  122. unsigned _cElements;
  123. };