iv-phonic 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/.autotest +24 -0
  2. data/Manifest.txt +49 -0
  3. data/README.rdoc +32 -0
  4. data/Rakefile +54 -0
  5. data/ext/include/iv/algorithm.h +23 -0
  6. data/ext/include/iv/alloc.h +200 -0
  7. data/ext/include/iv/any.h +71 -0
  8. data/ext/include/iv/ast-factory.h +277 -0
  9. data/ext/include/iv/ast-fwd.h +92 -0
  10. data/ext/include/iv/ast-serializer.h +579 -0
  11. data/ext/include/iv/ast-visitor.h +121 -0
  12. data/ext/include/iv/ast.h +1127 -0
  13. data/ext/include/iv/chars.h +83 -0
  14. data/ext/include/iv/cmdline.h +830 -0
  15. data/ext/include/iv/conversions.h +308 -0
  16. data/ext/include/iv/dtoa.h +20 -0
  17. data/ext/include/iv/enable_if.h +18 -0
  18. data/ext/include/iv/errors.h +15 -0
  19. data/ext/include/iv/fixedcontainer.h +42 -0
  20. data/ext/include/iv/functor.h +29 -0
  21. data/ext/include/iv/lexer.h +1281 -0
  22. data/ext/include/iv/location.h +23 -0
  23. data/ext/include/iv/mt19937.h +175 -0
  24. data/ext/include/iv/noncopyable.h +30 -0
  25. data/ext/include/iv/none.h +10 -0
  26. data/ext/include/iv/parser.h +2150 -0
  27. data/ext/include/iv/source.h +27 -0
  28. data/ext/include/iv/space.h +178 -0
  29. data/ext/include/iv/static_assert.h +30 -0
  30. data/ext/include/iv/stringpiece.h +385 -0
  31. data/ext/include/iv/token.h +311 -0
  32. data/ext/include/iv/ucdata.h +58 -0
  33. data/ext/include/iv/uchar.h +8 -0
  34. data/ext/include/iv/ustring.h +28 -0
  35. data/ext/include/iv/ustringpiece.h +9 -0
  36. data/ext/include/iv/utils.h +83 -0
  37. data/ext/include/iv/xorshift.h +74 -0
  38. data/ext/iv/phonic/ast-fwd.h +21 -0
  39. data/ext/iv/phonic/ast.h +10 -0
  40. data/ext/iv/phonic/creator.h +530 -0
  41. data/ext/iv/phonic/encoding.h +110 -0
  42. data/ext/iv/phonic/extconf.rb +5 -0
  43. data/ext/iv/phonic/factory.h +247 -0
  44. data/ext/iv/phonic/parser.h +12 -0
  45. data/ext/iv/phonic/phonic.cc +69 -0
  46. data/ext/iv/phonic/rnode.h +15 -0
  47. data/ext/iv/phonic/rparser.h +48 -0
  48. data/ext/iv/phonic/source.h +146 -0
  49. data/test/test_iv_phonic.rb +32 -0
  50. metadata +159 -0
@@ -0,0 +1,83 @@
1
+ #ifndef _IV_CHARS_H_
2
+ #define _IV_CHARS_H_
3
+ #include <cassert>
4
+ #include <tr1/cstdint>
5
+ #include "uchar.h"
6
+ #include "ucdata.h"
7
+
8
+ namespace iv {
9
+ namespace core {
10
+
11
+ class Chars {
12
+ public:
13
+ enum CharCategory {
14
+ UPPERCASE_LETTER = 1 << UC16::kUpperCaseLetter,
15
+ LOWERCASE_LETTER = 1 << UC16::kLowerCaseLetter,
16
+ TITLECASE_LETTER = 1 << UC16::kTitleCaseLetter,
17
+ MODIFIER_LETTER = 1 << UC16::kModifierLetter,
18
+ OTHER_LETTER = 1 << UC16::kOtherLetter,
19
+ NON_SPACING_MARK = 1 << UC16::kNonSpacingMark,
20
+ COMBINING_SPACING_MARK = 1 << UC16::kCombiningSpacingMark,
21
+ DECIMAL_DIGIT_NUMBER = 1 << UC16::kDecimalDigitNumber,
22
+ SPACE_SEPARATOR = 1 << UC16::kSpaceSeparator,
23
+ CONNECTOR_PUNCTUATION = 1 << UC16::kConnectorPunctuation
24
+ };
25
+ static inline uint32_t Category(const int c) {
26
+ assert(c <= 0xffff+1);
27
+ return (c < 0) ? 1 : (1 << UnicodeData::kCategory[c]);
28
+ }
29
+ static inline bool IsASCII(const int c) {
30
+ return !(c & ~0x7F);
31
+ }
32
+ static inline bool IsASCIIAlpha(const int c) {
33
+ return (c | 0x20) >= 'a' && (c | 0x20) <= 'z';
34
+ }
35
+ static inline bool IsASCIIAlphanumeric(const int c) {
36
+ return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z');
37
+ }
38
+ static inline bool IsNonASCIIIdentifierStart(const int c) {
39
+ return Category(c) & (UPPERCASE_LETTER | LOWERCASE_LETTER |
40
+ TITLECASE_LETTER | MODIFIER_LETTER | OTHER_LETTER);
41
+ }
42
+ static inline bool IsNonASCIIIdentifierPart(const int c) {
43
+ return Category(c) & (UPPERCASE_LETTER | LOWERCASE_LETTER |
44
+ TITLECASE_LETTER | MODIFIER_LETTER |
45
+ OTHER_LETTER | NON_SPACING_MARK |
46
+ COMBINING_SPACING_MARK |
47
+ DECIMAL_DIGIT_NUMBER |
48
+ CONNECTOR_PUNCTUATION);
49
+ }
50
+ static inline bool IsSeparatorSpace(const int c) {
51
+ return UnicodeData::kCategory[c] == UC16::kSpaceSeparator;
52
+ }
53
+ static inline bool IsWhiteSpace(const int c) {
54
+ return IsASCII(c) ?
55
+ (c == ' ' || c == '\t' || c == 0xB || c == 0xC) : IsSeparatorSpace(c);
56
+ }
57
+ static inline bool IsLineTerminator(const int c) {
58
+ return c == '\r' || c == '\n' || (c & ~1) == 0x2028;
59
+ }
60
+ static inline bool IsHexDigit(const int c) {
61
+ return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
62
+ }
63
+ static inline bool IsDecimalDigit(const int c) {
64
+ return c >= '0' && c <= '9';
65
+ }
66
+ static inline bool IsOctalDigit(const int c) {
67
+ return c >= '0' && c <= '7';
68
+ }
69
+ static inline bool IsIdentifierStart(const int c) {
70
+ return IsASCII(c) ? c == '$' || c == '_' ||
71
+ c == '\\' || IsASCIIAlpha(c) :
72
+ IsNonASCIIIdentifierStart(c);
73
+ }
74
+ static inline bool IsIdentifierPart(const int c) {
75
+ return IsASCII(c) ? c == '$' || c == '_' ||
76
+ c == '\\' || IsASCIIAlphanumeric(c) :
77
+ IsNonASCIIIdentifierPart(c);
78
+ }
79
+ };
80
+
81
+ } } // namespace iv::core
82
+
83
+ #endif // _IV_CHARS_H_