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.

157 lines
5.5 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. const MI_BGIN = 257;
  5. const MI_CCE = 258;
  6. const MI_COMMA = 259;
  7. const MI_DEFINITIONS = 260;
  8. const MI_FROM = 261;
  9. const MI_ID = 262;
  10. const MI_IMPORTS = 263;
  11. const MI_NAME = 264;
  12. const MI_SEMICOLON = 265;
  13. const MI_LBRACE = 266;
  14. const MI_RBRACE = 267;
  15. const MI_LPAREN = 268;
  16. const MI_RPAREN = 269;
  17. const MI_DOT = 270;
  18. const MI_LITNUMBER = 271;
  19. typedef union {
  20. char * yy_name;
  21. } MODULEINFOSTYPE;
  22. extern MODULEINFOSTYPE ModuleInfolval;
  23. // C++ YACC parser header
  24. // Copyright 1991 by Mortice Kern Systems Inc. All rights reserved.
  25. //
  26. // ModuleInfo_parse => class defining a parsing object
  27. // ModuleInfo_parse needs a class ModuleInfo_scan, which defines the scanner.
  28. // %prefix or option -p xx determines name of this class; if not used,
  29. // defaults to 'ModuleInfo_scan'
  30. //
  31. // constructor fills in the tables for this grammar; give it a size
  32. // to determine size of state and value stacks. Default is 150 entries.
  33. // destructor discards those state and value stacks
  34. //
  35. // int ModuleInfo_parse::ModuleInfoparse(ModuleInfo_scan *) invokes parse; if this returns,
  36. // it can be recalled to continue parsing at last point.
  37. // void ModuleInfo_parse::ModuleInforeset() can be called to reset the parse;
  38. // call ModuleInforeset() before ModuleInfo_parse::ModuleInfoparse(ModuleInfo_scan *)
  39. #include <stdio.h> // uses printf(), et cetera
  40. #include <stdlib.h> // uses exit()
  41. const MODULEINFOERRCODE = 256; // YACC 'error' value
  42. // You can use these macros in your action code
  43. #define MODULEINFOERROR goto ModuleInfoerrlabel
  44. #define MODULEINFOACCEPT MODULEINFORETURN(0)
  45. #define MODULEINFOABORT MODULEINFORETURN(1)
  46. #define MODULEINFORETURN(val) return(val)
  47. #if MODULEINFODEBUG
  48. typedef struct ModuleInfoNamedType_tag { /* Tokens */
  49. char * name; /* printable name */
  50. short token; /* token # */
  51. short type; /* token type */
  52. } ModuleInfoNamedType;
  53. typedef struct ModuleInfoTypedRules_tag { /* Typed rule table */
  54. char * name; /* compressed rule string */
  55. short type; /* rule result type */
  56. } ModuleInfoTypedRules;
  57. #endif
  58. #ifdef YACC_WINDOWS
  59. // include all windows prototypes, macros, constants, etc.
  60. #include <windows.h>
  61. // the following is the handle to the current
  62. // instance of a windows program. The user
  63. // program calling ModuleInfoparse must supply this!
  64. extern HANDLE hInst;
  65. #endif /* YACC_WINDOWS */
  66. class ModuleInfo_parse {
  67. protected:
  68. #ifdef YACC_WINDOWS
  69. // protected member function for actual scanning
  70. int win_ModuleInfoparse(ModuleInfo_scan * ps); // parse with given scanner
  71. #endif /* YACC_WINDOWS */
  72. int mustfree; // set if tables should be deleted
  73. int size; // size of state and value stacks
  74. int reset; // if set, reset state
  75. short ModuleInfoi; // table index
  76. short ModuleInfostate; // current state
  77. short * stateStack; // states stack
  78. MODULEINFOSTYPE * valueStack; // values stack
  79. short * ModuleInfops; // top of state stack
  80. MODULEINFOSTYPE * ModuleInfopv; // top of value stack
  81. MODULEINFOSTYPE ModuleInfolval; // saved ModuleInfolval
  82. MODULEINFOSTYPE ModuleInfoval; // $
  83. MODULEINFOSTYPE * ModuleInfopvt; // $n
  84. int ModuleInfochar; // current token
  85. int ModuleInfoerrflag; // error flag
  86. int ModuleInfonerrs; // error count
  87. #if MODULEINFODEBUG
  88. int done; // set from trace to stop parse
  89. int rule, npop; // reduction rule # and length
  90. short * typeStack; // type stack to mirror valueStack[]
  91. short * ModuleInfotp; // top of type stack
  92. char * ModuleInfogetState(int); // read 'states.out'
  93. #endif
  94. public:
  95. #if MODULEINFODEBUG
  96. // C++ has trouble with initialized arrays inside classes
  97. static long * States; // pointer to ModuleInfoStates[]
  98. static ModuleInfoTypedRules * Rules; // pointer to ModuleInfoRules[]
  99. static ModuleInfoNamedType * TokenTypes; // pointer to ModuleInfoTokenTypes[]
  100. static int ModuleInfontoken; // number of tokens
  101. static int ModuleInfonvar; // number of variables (nonterminals)
  102. static int ModuleInfonstate; // number of YACC-generated states
  103. static int ModuleInfonrule; // number of rules in grammar
  104. char* ModuleInfoptok(int); // printable token string
  105. int ModuleInfoExpandName(int, int, char *, int);
  106. // expand encoded string
  107. virtual int ModuleInfoGetType(int); // return type of token
  108. virtual void ModuleInfoShowRead(); // see newly read token
  109. virtual void ModuleInfoShowState(); // see state, value stacks
  110. virtual void ModuleInfoShowReduce(); // see reduction
  111. virtual void ModuleInfoShowGoto(); // see goto
  112. virtual void ModuleInfoShowShift(); // see shift
  113. virtual void ModuleInfoShowErrRecovery(); // see error recovery
  114. virtual void ModuleInfoShowErrDiscard(); // see token discard in error
  115. #endif
  116. ModuleInfo_scan* scan; // pointer to scanner
  117. int ModuleInfodebug; // if set, tracing if compiled with MODULEINFODEBUG=1
  118. ModuleInfo_parse(int = 150); // constructor for this grammar
  119. ModuleInfo_parse(int, short *, MODULEINFOSTYPE *); // another constructor
  120. ~ModuleInfo_parse(); // destructor
  121. int ModuleInfoparse(ModuleInfo_scan * ps); // parse with given scanner
  122. void ModuleInforeset() { reset = 1; } // restore state for next ModuleInfoparse()
  123. void setdebug(int y) { ModuleInfodebug = y; }
  124. // The following are useful in user actions:
  125. void ModuleInfoerrok() { ModuleInfoerrflag = 0; } // clear error
  126. void ModuleInfoclearin() { ModuleInfochar = -1; } // clear input
  127. int MODULEINFORECOVERING() { return ModuleInfoerrflag != 0; }
  128. };
  129. // end of .hpp header