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.

219 lines
8.4 KiB

  1. /*++
  2. // Copyright (c) 1995-2001 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. OPATHLEX2.CPP
  5. Abstract:
  6. Object Path Lexer Map (for use with GENLEX.CPP).
  7. History:
  8. 24-Jun-95 Created.
  9. 14-Apr-98 Radical update for singly quoted strings, remove
  10. unused tokens, add hex constants, etc.
  11. --*/
  12. #include "precomp.h"
  13. #include <stdio.h>
  14. #include <genlex.h>
  15. #include <opathlex2.h>
  16. #define ST_IDENT 24
  17. #define ST_NUMERIC 30
  18. #define ST_DECIMAL 32
  19. #define ST_HEX 34
  20. #define ST_SQ_STRING 38
  21. #define ST_DQ_STRING 42
  22. #define ST_DQ_STRING_ESC 45
  23. #define ST_REFERENCE 48
  24. #define ST_REFERENCE_ESC 51
  25. // DFA State Table for Object Path tokens.
  26. // =======================================
  27. LexEl OPath_LexTable2[] =
  28. {
  29. // State First Last New state, Return tok, Instructions
  30. // =======================================================================
  31. // -------------------------------------------------------------
  32. // Identifiers
  33. /* 0 */ L'A', L'Z', ST_IDENT, 0, GLEX_ACCEPT,
  34. /* 1 */ L'a', L'z', ST_IDENT, 0, GLEX_ACCEPT,
  35. /* 2 */ 0x80, 0xfffd, ST_IDENT, 0, GLEX_ACCEPT,
  36. /* 3 */ L'_', GLEX_EMPTY, ST_IDENT, 0, GLEX_ACCEPT,
  37. // -------------------------------------------------------------
  38. // Single symbols
  39. /* 4 */ L'.', GLEX_EMPTY, 0, OPATH_TOK_DOT, GLEX_ACCEPT,
  40. /* 5 */ '@', GLEX_EMPTY, 0, OPATH_TOK_SINGLETON_SYM, GLEX_ACCEPT,
  41. /* 6 */ L'=', GLEX_EMPTY, 0, OPATH_TOK_EQ, GLEX_ACCEPT,
  42. /* 7 */ L':', GLEX_EMPTY, 0, OPATH_TOK_COLON, GLEX_ACCEPT,
  43. // -------------------------------------------------------------
  44. // Backslashes & forward slashes are interchangeable and reported
  45. // as OPATH_TOK_BACKSLASH to the parser.
  46. /* 8 */ L'\\', GLEX_EMPTY, 0, OPATH_TOK_BACKSLASH, GLEX_ACCEPT,
  47. /* 9 */ L'/', GLEX_EMPTY, 0, OPATH_TOK_BACKSLASH, GLEX_ACCEPT,
  48. // -------------------------------------------------------------
  49. // Simple numeric transition. The '-' must be followed
  50. // by decimal digit sequence. The '0' may be the beginning of a hex
  51. // or a decimal sequence.
  52. /* 10 */ L'1', L'9', ST_DECIMAL, 0, GLEX_ACCEPT,
  53. /* 11 */ L'-', GLEX_EMPTY, ST_DECIMAL, 0, GLEX_ACCEPT,
  54. /* 12 */ L'0', GLEX_EMPTY, ST_NUMERIC, 0, GLEX_ACCEPT,
  55. // -------------------------------------------------------------
  56. // Simple string transition
  57. //
  58. // If a single quote begins the string, it must end the string.
  59. // Escapes are not supported: 'ab', 'a"b' <not: 'a\'b'>
  60. //
  61. // If a double quote begins the string, it must end the string,
  62. // except that escape+quote is an embedded double quote:
  63. //
  64. // "ab", "a'b", "a\"b"
  65. //
  66. /* 13 */ L'"', GLEX_EMPTY, ST_DQ_STRING, 0, GLEX_CONSUME,
  67. /* 14 */ L'\'', GLEX_EMPTY, ST_SQ_STRING, 0, GLEX_CONSUME,
  68. // -------------------------------------------------------------
  69. // Whitespace, newlines, etc. Whitespace is an error.
  70. /* 15 */ L' ', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  71. /* 16 */ L'\t', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  72. /* 17 */ L'\n', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  73. /* 18 */ L'\r', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  74. /* 19 */ 0, GLEX_EMPTY, 0, OPATH_TOK_EOF, GLEX_CONSUME|GLEX_RETURN, // Note forced return
  75. /* 20 */ L',', GLEX_EMPTY, 0, OPATH_TOK_COMMA, GLEX_ACCEPT,
  76. /* 21 */ L'{', GLEX_EMPTY, ST_REFERENCE, 0, GLEX_ACCEPT,
  77. /* 22 */ L'{', GLEX_EMPTY, ST_REFERENCE, 0, GLEX_ACCEPT, // Actually reserved for next new
  78. // All remaining unknown characters
  79. /* 23 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  80. //TODO
  81. // -------------------------------------------------------------
  82. // ST_IDENT
  83. // Accepts C/C++ identifiers, plus any char >= U+0080.
  84. /* 24 */ L'a', L'z', ST_IDENT, 0, GLEX_ACCEPT,
  85. /* 25 */ L'A', L'Z', ST_IDENT, 0, GLEX_ACCEPT,
  86. /* 26 */ L'_', GLEX_EMPTY, ST_IDENT, 0, GLEX_ACCEPT,
  87. /* 27 */ L'0', L'9', ST_IDENT, 0, GLEX_ACCEPT,
  88. /* 28 */ 0x80, 0xfffd, ST_IDENT, 0, GLEX_ACCEPT,
  89. /* 29 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_IDENT, GLEX_PUSHBACK|GLEX_RETURN,
  90. // -------------------------------------------------------------
  91. // ST_NUMERIC
  92. //
  93. // A zero has been recognized.
  94. // If the next char is 'x' or 'X', we have a valid hex sequence.
  95. // Otherwise, if '1' to '9' we have a decimal sequence.
  96. //
  97. /* 30 */ L'x', GLEX_EMPTY, ST_HEX, 0, GLEX_ACCEPT,
  98. /* 31 */ L'X', GLEX_EMPTY, ST_HEX, 0, GLEX_ACCEPT,
  99. // -------------------------------------------------------------
  100. // ST_DECIMAL
  101. //
  102. /* 32 */ L'0', L'9', ST_DECIMAL, 0, GLEX_ACCEPT,
  103. /* 33 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_INT, GLEX_PUSHBACK|GLEX_RETURN,
  104. // -------------------------------------------------------------
  105. // ST_HEX
  106. //
  107. // Recognizes a valid hex sequence.
  108. /* 34 */ L'a', L'f', ST_HEX, 0, GLEX_ACCEPT,
  109. /* 35 */ L'A', L'F', ST_HEX, 0, GLEX_ACCEPT,
  110. /* 36 */ L'0', L'9', ST_HEX, 0, GLEX_ACCEPT,
  111. /* 37 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_HEXINT, GLEX_PUSHBACK|GLEX_RETURN,
  112. // -------------------------------------------------------------
  113. // ST_SQ_STRING : Single quoted strings
  114. //
  115. // If a single quote begins the string, it must end the string.
  116. // Escapes are not supported: 'ab', 'a"b' <not: 'a\'b'>
  117. /* 38 */ L'\n', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_LINEFEED,
  118. /* 39 */ L'\r', GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_LINEFEED,
  119. /* 40 */ L'\'', GLEX_EMPTY, 0, OPATH_TOK_QSTRING, GLEX_CONSUME,
  120. /* 41 */ GLEX_ANY, GLEX_EMPTY, ST_SQ_STRING, 0, GLEX_ACCEPT,
  121. // -------------------------------------------------------------
  122. // ST_DQ_STRING
  123. //
  124. // If a double quote begins the string, it must end the string,
  125. // except that escape+quote is an embedded double quote:
  126. //
  127. // "ab", "a'b", "a\"b"
  128. //
  129. /* 42 */ L'\\', GLEX_EMPTY, ST_DQ_STRING_ESC, 0, GLEX_CONSUME, // Escape
  130. /* 43 */ L'"', GLEX_EMPTY, 0, OPATH_TOK_QSTRING, GLEX_CONSUME,
  131. /* 44 */ L'"', GLEX_EMPTY, ST_DQ_STRING, 0, GLEX_ACCEPT|GLEX_NOT,
  132. // Accept anything but a quote
  133. //-------------------------------------------------------------
  134. // ST_DQ_STRING_ESC
  135. //
  136. // An escape occurred while in a string.
  137. // Either an embedded slash or embedded quote must have occurred.
  138. // Otherwise, an unsupported escape has occurred and we fail.
  139. /* 45 */ L'\\', GLEX_EMPTY, ST_DQ_STRING, 0, GLEX_ACCEPT,
  140. /* 46 */ L'"', GLEX_EMPTY, ST_DQ_STRING, 0, GLEX_ACCEPT,
  141. /* 47 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  142. // -------------------------------------------------------------
  143. // ST_DQ_REFERENCE
  144. //
  145. // A reference begins with '{' and ends with '}'. Embedded
  146. // '}' are allowed if preceeded by '\':
  147. /* 48 */ L'\\', GLEX_EMPTY, ST_REFERENCE_ESC, 0, GLEX_CONSUME, // Escape
  148. /* 49 */ L'}', GLEX_EMPTY, 0, OPATH_TOK_REFERENCE, GLEX_ACCEPT,
  149. /* 50 */ L'}', GLEX_EMPTY, ST_REFERENCE, 0, GLEX_ACCEPT|GLEX_NOT,
  150. // Accept anything but a quote
  151. //-------------------------------------------------------------
  152. // ST_DQ_REFERENCE_ESC
  153. //
  154. // An escape occurred while in a string.
  155. // Either an embedded slash or embedded quote must have occurred.
  156. // Otherwise, an unsupported escape has occurred and we fail.
  157. /* 51 */ L'\\', GLEX_EMPTY, ST_REFERENCE, 0, GLEX_ACCEPT,
  158. /* 52 */ L'}', GLEX_EMPTY, ST_REFERENCE, 0, GLEX_ACCEPT,
  159. /* 53 */ GLEX_ANY, GLEX_EMPTY, 0, OPATH_TOK_ERROR, GLEX_ACCEPT|GLEX_RETURN,
  160. };