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.

189 lines
7.1 KiB

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