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.

160 lines
5.4 KiB

  1. // Notes: The parser is embodied/encapsulated in the class YYPARSER. Given a
  2. // <grammar>.y the C++ YACC generates a YYPARSER object along with the needed
  3. // parse tables as static data members. To create a parser object is as simple
  4. // as creating an object of class YYPARSER. The YYPARSER code now is
  5. // automatically re-entrant.
  6. #ifndef YYPARS_INCLUDED
  7. #define YYPARS_INCLUDED
  8. #ifdef UNICODE
  9. #define yyitos _itow
  10. #else
  11. #define yyitos _itoa
  12. #endif
  13. #ifndef YYAPI_PACKAGE
  14. # define YYAPI_TOKENNAME yychar //name used for return value of yylex
  15. # define YYAPI_TOKENTYPE int //type of the token
  16. # define YYAPI_TOKENEME(t) (t) //the value of the token that the parser should see
  17. # define YYAPI_TOKENNONE -2 //the representation when there is no token
  18. # define YYAPI_TOKENSTR(t) (yyitos(t,yyitoa,10)) //string representation of the token
  19. # define YYAPI_VALUENAME yylval //the name of the value of the token
  20. # define YYAPI_VALUETYPE YYSTYPE //the type of the value of the token (if null, then the value is derivable from the token itself)
  21. # define YYAPI_VALUEOF(v) (v) //how to get the value of the token
  22. # define YYAPI_CALLAFTERYYLEX(t) //
  23. # define YYAPI_PACKAGE //package is in use
  24. #endif // YYAPI_PACKAGE
  25. #ifndef YYPARSER
  26. # define YYPARSER yyparse
  27. #endif
  28. #ifndef YYLEX
  29. # define YYLEX yylex
  30. #endif
  31. #ifndef YYPARSEPROTO
  32. # define YYPARSEPROTO
  33. #endif
  34. #ifndef YYSTYPE
  35. # define YYSTYPE int
  36. #endif
  37. #define yyerrok ClearErrRecoveryState() //provided for compatibility with YACC
  38. #define yyclearin YYAPI_TOKENNAME = YYAPI_TOKENNONE
  39. #ifndef YYMAXDEPTH
  40. #define YYMAXDEPTH 150
  41. #endif
  42. #ifndef YYR_T
  43. #define YYR_T int
  44. typedef YYR_T yyr_t;
  45. #endif
  46. class CImpIParserSession;
  47. class CImpIParserTreeProperties;
  48. class YYPARSER {
  49. friend class YYLEXER;
  50. // ctor & dtor
  51. public:
  52. YYPARSER(CImpIParserSession* pParserSession, CImpIParserTreeProperties* pParserTreeProperties);
  53. ~YYPARSER();
  54. // Public interface
  55. public:
  56. void ResetParser(); //use to possibly restart parser
  57. HRESULT Parse(YYPARSEPROTO); //bread and butter function
  58. // Public interface that's reluctantly provided
  59. public:
  60. int NoOfErrors(); //current count of parsing errors
  61. int ErrRecoveryState(); //error recovery state.
  62. void ClearErrRecoveryState(); //error recovery is complete.
  63. #ifdef YYAPI_VALUETYPE
  64. YYAPI_VALUETYPE GetParseTree() // Get result of parse
  65. {
  66. return /*YYAPI_VALUENAME*/yyval;
  67. };
  68. #endif
  69. YYAPI_TOKENTYPE GetCurrentToken(); //current token seen by the parser.
  70. void SetCurrentToken(YYAPI_TOKENTYPE newToken); //change current token.
  71. void YYPARSER::yySetBuffer(short iBuffer, YY_CHAR *szValue);
  72. YY_CHAR *YYPARSER::yyGetBuffer(short iBuffer);
  73. void yyprimebuffer(YY_CHAR *pszBuffer);
  74. void yyprimelexer(int eToken);
  75. void EmptyValueStack();
  76. HRESULT CoerceScalar(DBTYPE dbTypeExpected, DBCOMMANDTREE** ppct);
  77. // private data
  78. private:
  79. int yyn;
  80. int yychar1; /* lookahead token as an internal (translated) token number */
  81. short yyssa[YYMAXDEPTH]; /* the state stack */
  82. YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */
  83. short *yyss; /* refer to the stacks thru separate pointers */
  84. YYSTYPE *yyvs; /* to allow yyoverflow to reallocate them elsewhere */
  85. int yystacksize;
  86. int yynerrs;
  87. YYSTYPE yyval;/* the variable used to return */
  88. /* semantic values from the action */
  89. /* routines */
  90. int yylen;
  91. YYAPI_TOKENTYPE YYAPI_TOKENNAME; //current input token
  92. #ifdef YYAPI_VALUETYPE
  93. //could be defined as attribute of the token; In this case.
  94. //YYAPI_TOKENNAME and YYAPI_VALUENAME must match.
  95. YYAPI_VALUETYPE YYAPI_VALUENAME; //value of current input token
  96. #endif
  97. int yyerrflag; //error recovery flag
  98. int yyerrstatus; /* number of tokens to shift before error messages enabled */
  99. // private pointer data
  100. private:
  101. short yystate; //parse state
  102. short *yyssp; //state pointer
  103. YYSTYPE *yyvsp; //pointer to value of a state
  104. CImpIParserSession* m_pIPSession; //all of the data necessary for this parser
  105. CImpIParserTreeProperties * m_pIPTProperties;
  106. public:
  107. YYLEXER m_yylex; // lexer object for this instance of parser
  108. // private tables
  109. private:
  110. //These may be allocated dynamically
  111. YY_CHAR yyitoa[20]; // Buff to store text version of token
  112. // debugging helpers
  113. public:
  114. // ICommand* m_pICommand; //command object
  115. #ifdef YYDEBUG
  116. int yydebug;
  117. #endif
  118. private:
  119. #ifdef YYDUMP
  120. void DumpYYS();
  121. void DumpYYV();
  122. #endif
  123. void Trace(TCHAR *message);
  124. void Trace(TCHAR *message, const TCHAR *tokname, short state = 0);
  125. void Trace(TCHAR *message, int state, short tostate = 0, short token = 0);
  126. private:
  127. # define maxYYBuffer 5
  128. YY_CHAR *rgpszYYBuffer[maxYYBuffer];
  129. };
  130. #endif // YYPARS_INCLUDED