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.

80 lines
3.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: syntax.cpp
  4. //
  5. // Contents: data definitions for the syntax modules
  6. //
  7. // Classes:
  8. //
  9. // Functions:
  10. //
  11. // Coupling:
  12. //
  13. // Notes:
  14. //
  15. // History: 3-29-00 ericne Created
  16. //
  17. //----------------------------------------------------------------------------
  18. #include "stdafx.h"
  19. #pragma hdrstop
  20. #include <memory.h>
  21. #include "syntax.h"
  22. namespace regex
  23. {
  24. // Initialize the perl syntax look-up tables
  25. perl_syntax_base::init_perl_syntax::init_perl_syntax()
  26. {
  27. memset( perl_syntax_base::s_rgreg, 0, sizeof( perl_syntax_base::s_rgreg ) );
  28. memset( perl_syntax_base::s_rgreg, 0, sizeof( perl_syntax_base::s_rgreg ) );
  29. // REGULAR TOKENS
  30. perl_syntax_base::s_rgreg[ (unsigned char)'(' ] = BEGIN_GROUP;
  31. perl_syntax_base::s_rgreg[ (unsigned char)')' ] = END_GROUP;
  32. perl_syntax_base::s_rgreg[ (unsigned char)'|' ] = ALTERNATION;
  33. perl_syntax_base::s_rgreg[ (unsigned char)'^' ] = BEGIN_LINE;
  34. perl_syntax_base::s_rgreg[ (unsigned char)'$' ] = END_LINE;
  35. perl_syntax_base::s_rgreg[ (unsigned char)'[' ] = BEGIN_CHARSET;
  36. perl_syntax_base::s_rgreg[ (unsigned char)'.' ] = MATCH_ANY;
  37. perl_syntax_base::s_rgreg[ (unsigned char)'\\' ] = ESCAPE;
  38. // ESCAPE TOKENS
  39. perl_syntax_base::s_rgescape[ (unsigned char)'d' ] = ESC_DIGIT;
  40. perl_syntax_base::s_rgescape[ (unsigned char)'D' ] = ESC_NOT_DIGIT;
  41. perl_syntax_base::s_rgescape[ (unsigned char)'s' ] = ESC_SPACE;
  42. perl_syntax_base::s_rgescape[ (unsigned char)'S' ] = ESC_NOT_SPACE;
  43. perl_syntax_base::s_rgescape[ (unsigned char)'w' ] = ESC_WORD;
  44. perl_syntax_base::s_rgescape[ (unsigned char)'W' ] = ESC_NOT_WORD;
  45. perl_syntax_base::s_rgescape[ (unsigned char)'A' ] = ESC_BEGIN_STRING;
  46. perl_syntax_base::s_rgescape[ (unsigned char)'Z' ] = ESC_END_STRING;
  47. perl_syntax_base::s_rgescape[ (unsigned char)'z' ] = ESC_END_STRING_z;
  48. perl_syntax_base::s_rgescape[ (unsigned char)'b' ] = ESC_WORD_BOUNDARY;
  49. perl_syntax_base::s_rgescape[ (unsigned char)'B' ] = ESC_NOT_WORD_BOUNDARY;
  50. perl_syntax_base::s_rgescape[ (unsigned char)'Q' ] = ESC_QUOTE_META_ON;
  51. perl_syntax_base::s_rgescape[ (unsigned char)'E' ] = ESC_QUOTE_META_OFF;
  52. }
  53. TOKEN perl_syntax_base::s_rgreg[ UCHAR_MAX + 1 ];
  54. TOKEN perl_syntax_base::s_rgescape[ UCHAR_MAX + 1 ];
  55. perl_syntax_base::init_perl_syntax perl_syntax_base::s_init_perl_syntax;
  56. extern const posix_charset_type g_rgposix_charsets[] =
  57. {
  58. posix_charset_type("[:alnum:]",9),
  59. posix_charset_type("[:alpha:]",9),
  60. posix_charset_type("[:blank:]",9),
  61. posix_charset_type("[:cntrl:]",9),
  62. posix_charset_type("[:digit:]",9),
  63. posix_charset_type("[:graph:]",9),
  64. posix_charset_type("[:lower:]",9),
  65. posix_charset_type("[:print:]",9),
  66. posix_charset_type("[:punct:]",9),
  67. posix_charset_type("[:space:]",9),
  68. posix_charset_type("[:upper:]",9),
  69. posix_charset_type("[:xdigit:]",10)
  70. };
  71. extern const size_t g_cposix_charsets = ARRAYSIZE(g_rgposix_charsets);
  72. } // namespace regex