Source code of Windows XP (NT5)
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.

146 lines
4.8 KiB

  1. /*****************************************************************************
  2. emrultk.h
  3. Owner: DaleG
  4. Copyright (c) 1992-1997 Microsoft Corporation
  5. Rule and Lexer-token history recording header file.
  6. *****************************************************************************/
  7. #ifndef EMRULTK_H
  8. #define EMRULTK_H
  9. MSOEXTERN_C_BEGIN // ***************** Begin extern "C" ********************
  10. #ifndef MSOCP_DEFINED
  11. typedef long MSOCP; // Character position
  12. #define msocpNil ((MSOCP) -1)
  13. #define msocp0 ((MSOCP) 0)
  14. #define msocpMax ((MSOCP) 0x7FFFFFFF)
  15. #define MSOCP_DEFINED
  16. #endif /* !MSOCP_DEFINED */
  17. /*************************************************************************
  18. Types:
  19. rultk Rule/lexer-token history record.
  20. rultkh Rule/lexer-token history cache.
  21. *************************************************************************/
  22. /* M S O R U L T K */
  23. /*----------------------------------------------------------------------------
  24. %%Structure: MSORULTK
  25. %%Contact: daleg
  26. Rule/lexer-token history record.
  27. ----------------------------------------------------------------------------*/
  28. typedef struct _MSORULTK
  29. {
  30. void *pObject; // Object, e.g. doc
  31. MSOCP cpFirst; // First CP of token
  32. MSOCP dcp; // CP len of token
  33. int ich; // Char offset of tk
  34. long dich; // Num of chars of tk
  35. long wInterval; // Num intervals
  36. int tk; // Token number
  37. long lValue; // Token value
  38. } MSORULTK;
  39. #define irultkNil (-2)
  40. /* M S O R U L T K H */
  41. /*----------------------------------------------------------------------------
  42. %%Structure: MSORULTKH
  43. %%Contact: daleg
  44. Rule/lexer-token history cache structure.
  45. ----------------------------------------------------------------------------*/
  46. typedef struct _MSORULTKH
  47. {
  48. MSORULTK *rgrultkCache; // History record list
  49. int irultkMac; // Lim of allocated
  50. int irultkMin; // User-defined marker
  51. int irultkLim; // Next cache index
  52. int irultkAbsBase; // Absolute irultk base
  53. } MSORULTKH;
  54. /* M S O C A */
  55. /*----------------------------------------------------------------------------
  56. %%Structure: MSOCA
  57. %%Contact: daleg
  58. Rule/lexer text range
  59. ----------------------------------------------------------------------------*/
  60. typedef struct _MSOCA
  61. {
  62. void *pObject; // Object, e.g. doc
  63. long cpFirst; // First char pos
  64. long cpLim; // Lim char pos
  65. } MSOCA;
  66. // Define (D)elta of a (T)o(K)en cache index
  67. typedef int DTK;
  68. // Define (D)elta of a (T)o(K)en cache (I)nterval
  69. typedef int DTKI;
  70. // Token-history cache access
  71. #define PrultkFromIrultk(irultk, prultk) \
  72. (&prultk[irultk])
  73. // Move to next cache record, wrapping around if necessary
  74. #define IncrPrultk(pprultk, pirultk, prultkHist, irultkMax) \
  75. if (++(*pirultk) >= (irultkMax)) \
  76. { \
  77. (*pirultk) = 0; \
  78. (*pprultk) = PrultkFromIrultk(0, prultkHist); \
  79. } \
  80. else \
  81. (*pprultk)++;
  82. // Move to next cache record, wrapping around if necessary
  83. #define DecrPrultk(pprultk, pirultk, prultkHist, irultkMax) \
  84. if (--(*pirultk) < 0) \
  85. { \
  86. (*pirultk) += (irultkMax); \
  87. (*pprultk) += (irultkMax) - 1; \
  88. } \
  89. else \
  90. (*pprultk)--;
  91. // Move index to next cache record, wrapping around if necessary
  92. #define IncrPirultk(pirultk, dirultk, irultkMax) \
  93. if (((*pirultk) += dirultk) >= (irultkMax)) \
  94. (*pirultk) -= (irultkMax);
  95. // Move index to prev cache record, wrapping around if necessary
  96. #define DecrPirultk(pirultk, dirultk, irultkMax) \
  97. if (((*pirultk) -= dirultk) < 0) \
  98. (*pirultk) += (irultkMax);
  99. MSORULTK *PrultkExpand( // Expand cache
  100. MSORULTK **pprultkCache,
  101. int *pirultkMax,
  102. int irultkMax,
  103. int irultkSplit
  104. );
  105. // defines
  106. #define msodtkNotFound 30000 // arbitrarily lg. flag
  107. MSOEXTERN_C_END // ****************** End extern "C" *********************
  108. #endif /* EMRULTK_H */