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.

190 lines
6.9 KiB

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