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.

189 lines
7.1 KiB

  1. /*++
  2. Copyright (C) 1995-2001 Microsoft Corporation
  3. Module Name:
  4. MOFPARSE.H
  5. Abstract:
  6. Declarations for MOF Parser class.
  7. History:
  8. a-raymcc 18-Oct-95 Created.
  9. a-raymcc 27-Jan-96 Reference & alias support.
  10. --*/
  11. #ifndef _MOFPARSE_H_
  12. #define _MOFPARSE_H_
  13. #include "wstring.h"
  14. #include "parmdefs.h"
  15. #include "moflex.h"
  16. #include "mofprop.h"
  17. #include "mofdata.h"
  18. #include "bmof.h"
  19. #include "bmofhelp.h"
  20. #include "trace.h"
  21. enum SCOPE_CHECK{IN_CLASS, IN_INSTANCE, IN_PROPERTY, IN_PARAM, IN_METHOD};
  22. bool ValidFlags(bool bClass, long lFlags);
  23. class CMofParser
  24. {
  25. CMofLexer m_Lexer;
  26. CMofData m_Output;
  27. PDBG m_pDbg;
  28. LPWSTR m_wszNamespace;
  29. long m_lDefClassFlags;
  30. long m_lDefInstanceFlags;
  31. bool m_bAutoRecover;
  32. bool m_bNotBMOFCompatible;
  33. WCHAR * m_wszAmendment;
  34. bool m_bRemotePragmaPaths;
  35. bool m_bOK;
  36. int m_nToken;
  37. int m_nErrorContext;
  38. int m_nErrorLineNumber;
  39. TCHAR m_cFileName[MAX_PATH];
  40. PARSESTATE m_State;
  41. bool m_bDoScopeCheck;
  42. // Internal functions.
  43. // ===================
  44. // Nonterminal symbols from productions.
  45. // =====================================
  46. public:
  47. void SetToDoScopeCheck(){m_bDoScopeCheck = true;};
  48. void SetToNotScopeCheck(){m_bDoScopeCheck = false;};
  49. void SetState(PARSESTATE state){m_State = state;};
  50. void NextToken(bool bDontAllowWhitespace = false) { m_nToken = m_Lexer.NextToken(bDontAllowWhitespace); }
  51. BOOL top_level_decl(); // stores in CMofData
  52. BOOL decl_type(); // stores in CMofData
  53. BOOL class_decl(ACQUIRE CMoQualifierArray* paAttrs, VARIANT * pValue, ParseState *pQualPosition); // stores in CMofData
  54. BOOL class_def(ACQUIRE CMoQualifierArray* paAttrs, BSTR strClassName,
  55. int nFirstLine, ParseState * pQualPosition, VARIANT * pValue);
  56. BOOL instance_decl(ACQUIRE CMoQualifierArray* paAttrs, VARIANT * pValue, ParseState * QualPosition = NULL);// stores in CMofData
  57. BOOL qualifier_decl(OUT CMoQualifierArray& aAttrs, bool bTopLevel, QUALSCOPE qs);
  58. BOOL type(OUT CMoType& Type);
  59. BOOL opt_parent_class(OUT BSTR* pstrParentName);
  60. BOOL property_decl_list(MODIFY CMObject* pObject);
  61. BOOL as_alias(OUT LPWSTR& wszAlias);
  62. BOOL prop_init_list(MODIFY CMObject* pObject);
  63. BOOL prop_init(OUT CMoProperty& Prop);
  64. BOOL alias(OUT LPWSTR& wszAlias);
  65. BOOL PropOrMeth_decl(OUT CMoProperty **ppProp);
  66. BOOL PropOrMeth_decl2(OUT CMoProperty **ppProp, CMoQualifierArray * paQualifiers);
  67. BOOL finish_PropOrMeth(CMoType & Type, WString & sName, CMoProperty ** ppProp, CMoQualifierArray * paQualifiers);
  68. BOOL finish_prop(CMoType & Type, WString & sName, CMoProperty ** ppProp, CMoQualifierArray * paQualifiers);
  69. BOOL finish_meth(CMoType & Type, WString & sName, CMoProperty ** ppProp, CMoQualifierArray * paQualifiers);
  70. BOOL TypeAndName(MODIFY CMoType& Type, WString & sName);
  71. BOOL arg_list(CMethodProperty * pMethProp);
  72. BOOL arg_decl(CMethodProperty * pMethProp);
  73. BOOL rest_of_args(CMethodProperty * pMethProp);
  74. BOOL opt_ref(MODIFY CMoType& Type);
  75. BOOL opt_array(MODIFY CMoType& Type, CMoQualifierArray * paQualifiers);
  76. BOOL opt_array_detail(MODIFY CMoType& Type, CMoQualifierArray * paQualifiers);
  77. BOOL default_value(READ_ONLY CMoType& Type, OUT CMoValue& Value);
  78. BOOL initializer(MODIFY CMoType& Type, OUT CMoValue& Value);
  79. BOOL qualifier_list(OUT CMoQualifierArray& aAttrs, bool bTopLevel, QUALSCOPE qs);
  80. BOOL qualifier(OUT CMoQualifier& Attr, bool bTopLevel, QUALSCOPE qs);
  81. BOOL qualifier_list_rest(MODIFY CMoQualifierArray& aAttrs, bool bTopLevel, QUALSCOPE qs);
  82. BOOL qualifier_parm(OUT CMoQualifier& Attr, bool bTopLevel, QUALSCOPE qs);
  83. BOOL qualifier_initializer_list(OUT CMoValue& Value);
  84. BOOL const_value(MODIFY CMoType& Type, OUT VARIANT& varValue, bool bQualifier);
  85. BOOL simple_initializer(MODIFY CMoType& Type, OUT CMoValue& Value, bool bQualifier);
  86. BOOL initializer_list(MODIFY CMoType& Type, OUT CMoValue& Value, bool bQualifier);
  87. BOOL preprocessor_command(); // executes
  88. BOOL pound_include(); // executes
  89. BOOL pound_define(); // executes
  90. BOOL pound_pragma(); // executes
  91. bool flag_list(bool bClass);
  92. bool string_list(bool bClass, long & lNewValue);
  93. bool GetFlagValue(long & lNewValue);
  94. BOOL typedef_(ACQUIRE CMoQualifierArray* paAttrs);
  95. BOOL complete_type();
  96. BOOL enum_();
  97. BOOL enum_data();
  98. BOOL enum_data_rest();
  99. BOOL int_enum_data_rest();
  100. BOOL int_enum_datum();
  101. BOOL string_enum_data_rest();
  102. BOOL string_enum_datum();
  103. BOOL opt_name();
  104. BOOL opt_subrange();
  105. BOOL const_int();
  106. BOOL const_string();
  107. BOOL const_char();
  108. BOOL flavor_param(OUT CMoQualifier& Qual, bool bDefaultQual);
  109. BOOL flavor_list(OUT CMoQualifier& Qual);
  110. BOOL flavor_list_rest(CMoQualifier& Qual);
  111. BOOL def_flavor_list(OUT CMoQualifier& Qual);
  112. BOOL def_flavor_list_rest(CMoQualifier& Qual);
  113. BOOL flavor_value(CMoQualifier& Qual);
  114. bool sys_or_regular();
  115. BOOL qualifier_default();
  116. BOOL finish_qualifier_default(CMoQualifier& Qual);
  117. BOOL finish_qualifier_end(CMoQualifier& Qual);
  118. BOOL scope_list(OUT CMoQualifier& Qual);
  119. BOOL scope_list_rest(CMoQualifier& Qual);
  120. BOOL scope_value(CMoQualifier& Qual);
  121. BOOL FailOrNoFail(bool * pbFail);
  122. CMofParser(const TCHAR *pFilename, PDBG pdbg);
  123. CMofParser(PDBG pdbg);
  124. ~CMofParser();
  125. HRESULT SetBuffer(char *pMemory, DWORD dwMemSize){return m_Lexer.SetBuffer(pMemory, dwMemSize);};
  126. PDBG GetDbg(){return m_pDbg;};
  127. HRESULT SetDefaultNamespace(LPCWSTR wszDefault);
  128. void SetOtherDefaults(long lClass, long lInst, bool bAutoRecover){m_lDefClassFlags = lClass;m_lDefInstanceFlags=lInst;
  129. m_bAutoRecover = bAutoRecover; return;};
  130. long GetClassFlags(void){return m_lDefClassFlags;};
  131. long GetInstanceFlags(void){return m_lDefInstanceFlags;};
  132. bool GetAutoRecover(void){return m_bAutoRecover;};
  133. HRESULT SetAmendment(LPCWSTR wszDefault);
  134. WCHAR * GetAmendment(void){return m_wszAmendment;};
  135. bool GetRemotePragmaPaths(void){return m_bRemotePragmaPaths;};
  136. BOOL Parse();
  137. bool GetErrorInfo(TCHAR *pBuffer, DWORD dwBufSize,
  138. int *pLineNumber, int *pColumn, int *pError, LPWSTR * pErrorFile);
  139. TCHAR * GetFileName(){return m_cFileName;};
  140. TCHAR * GetAutoRecoverFileName(){return m_Lexer.GetFileName();};
  141. INTERNAL CMofData *AccessOutput() { return &m_Output; }
  142. BOOL IsUnicode(){return m_Lexer.IsUnicode();};
  143. bool IsntBMOFCompatible(){return m_bNotBMOFCompatible;};
  144. void SetParserPosition(ParseState * pPos){m_Lexer.SetLexPosition(pPos); m_nToken = pPos->m_nToken;};
  145. void GetParserPosition(ParseState * pPos){m_Lexer.GetLexPosition(pPos); pPos->m_nToken = m_nToken;};
  146. BOOL CheckScopes(SCOPE_CHECK scope_check, CMoQualifierArray* paQualifiers, CMoProperty * pProperty);
  147. BOOL IsBMOF(){ return m_Lexer.IsBMOF(); };
  148. };
  149. #endif