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.

66 lines
1.4 KiB

  1. #include <windows.h>
  2. #include "scntable.h"
  3. #include "RuleLex.H"
  4. CRuleLexicon::CRuleLexicon()
  5. {
  6. }
  7. CRuleLexicon::~CRuleLexicon()
  8. {
  9. }
  10. BOOL CRuleLexicon::IsAWord(
  11. LPCWSTR lpwszString,
  12. INT nLength)
  13. {
  14. DFAState State;
  15. WCHAR wc;
  16. INT nCurrPos = 0;
  17. Transition t;
  18. do {
  19. State = g_nStartState;
  20. while (nCurrPos <= nLength) {
  21. if (nCurrPos == nLength) {
  22. ++nCurrPos;
  23. wc = ' ';
  24. } else {
  25. wc = lpwszString[nCurrPos++];
  26. }
  27. if (!(g_uFirstChar <= wc && wc <= g_uLastChar)) {
  28. return FALSE;
  29. }
  30. t = g_sMinimalDFA[State - 1][g_CharClass[wc - g_uFirstChar] - 1];
  31. switch(t.Action) {
  32. case Move:
  33. if (0 == t.NextState) {
  34. return FALSE;
  35. } else {
  36. State = t.NextState;
  37. }
  38. break;
  39. case Error:
  40. return FALSE;
  41. break;
  42. case Halt:
  43. if (t.Major && (nCurrPos > nLength)) {
  44. return TRUE;
  45. } else {
  46. return FALSE;
  47. }
  48. break;
  49. default:
  50. return FALSE;
  51. }
  52. }
  53. } while (nCurrPos <= nLength);
  54. if (nCurrPos == nLength) {
  55. return TRUE;
  56. } else {
  57. return FALSE;
  58. }
  59. }