github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/analysis/standard/tokenizerImpl.go (about) 1 package standard 2 3 import ( 4 . "github.com/balzaczyy/golucene/core/analysis/tokenattributes" 5 "io" 6 ) 7 8 // standard/StandardTokenizerImpl.java 9 10 /* initial size of the lookahead buffer */ 11 const ZZ_BUFFERSIZE = 255 12 13 /* lexical states */ 14 const YYINITIAL = 0 15 16 /* 17 ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l 18 ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the beginning of a line 19 l is of the form l = 2*k, k a non negative integer 20 */ 21 var ZZ_LEXSTATE = [2]int{0, 0} 22 23 /* Translates characters to character classes */ 24 var ZZ_CMAP_PACKED = []int{ 25 042, 000, 001, 015, 004, 000, 001, 014, 004, 000, 001, 007, 001, 000, 001, 010, 001, 000, 012, 004, 26 001, 006, 001, 007, 005, 000, 032, 001, 004, 000, 001, 011, 001, 000, 032, 001, 057, 000, 001, 001, 27 002, 000, 001, 003, 007, 000, 001, 001, 001, 000, 001, 006, 002, 000, 001, 001, 005, 000, 027, 001, 28 001, 000, 037, 001, 001, 000, int('\u01ca'), 001, 004, 000, 014, 001, 005, 000, 001, 006, 010, 000, 005, 001, 29 007, 000, 001, 001, 001, 000, 001, 001, 021, 000, 0160, 003, 005, 001, 001, 000, 002, 001, 002, 000, 30 004, 001, 001, 007, 007, 000, 001, 001, 001, 006, 003, 001, 001, 000, 001, 001, 001, 000, 024, 001, 31 001, 000, 0123, 001, 001, 000, 0213, 001, 001, 000, 007, 003, 0236, 001, 011, 000, 046, 001, 002, 000, 32 001, 001, 007, 000, 047, 001, 001, 000, 001, 007, 007, 000, 055, 003, 001, 000, 001, 003, 001, 000, 33 002, 003, 001, 000, 002, 003, 001, 000, 001, 003, 010, 000, 033, 016, 005, 000, 003, 016, 001, 001, 34 001, 006, 013, 000, 005, 003, 007, 000, 002, 007, 002, 000, 013, 003, 001, 000, 001, 003, 003, 000, 35 053, 001, 025, 003, 012, 004, 001, 000, 001, 004, 001, 007, 001, 000, 002, 001, 001, 003, 0143, 001, 36 001, 000, 001, 001, 010, 003, 001, 000, 006, 003, 002, 001, 002, 003, 001, 000, 004, 003, 002, 001, 37 012, 004, 003, 001, 002, 000, 001, 001, 017, 000, 001, 003, 001, 001, 001, 003, 036, 001, 033, 003, 38 002, 000, 0131, 001, 013, 003, 001, 001, 016, 000, 012, 004, 041, 001, 011, 003, 002, 001, 002, 000, 39 001, 007, 001, 000, 001, 001, 005, 000, 026, 001, 004, 003, 001, 001, 011, 003, 001, 001, 003, 003, 40 001, 001, 005, 003, 022, 000, 031, 001, 003, 003, 0104, 000, 001, 001, 001, 000, 013, 001, 067, 000, 41 033, 003, 001, 000, 004, 003, 066, 001, 003, 003, 001, 001, 022, 003, 001, 001, 007, 003, 012, 001, 42 002, 003, 002, 000, 012, 004, 001, 000, 007, 001, 001, 000, 007, 001, 001, 000, 003, 003, 001, 000, 43 010, 001, 002, 000, 002, 001, 002, 000, 026, 001, 001, 000, 007, 001, 001, 000, 001, 001, 003, 000, 44 004, 001, 002, 000, 001, 003, 001, 001, 007, 003, 002, 000, 002, 003, 002, 000, 003, 003, 001, 001, 45 010, 000, 001, 003, 004, 000, 002, 001, 001, 000, 003, 001, 002, 003, 002, 000, 012, 004, 002, 001, 46 017, 000, 003, 003, 001, 000, 006, 001, 004, 000, 002, 001, 002, 000, 026, 001, 001, 000, 007, 001, 47 001, 000, 002, 001, 001, 000, 002, 001, 001, 000, 002, 001, 002, 000, 001, 003, 001, 000, 005, 003, 48 004, 000, 002, 003, 002, 000, 003, 003, 003, 000, 001, 003, 007, 000, 004, 001, 001, 000, 001, 001, 49 007, 000, 012, 004, 002, 003, 003, 001, 001, 003, 013, 000, 003, 003, 001, 000, 011, 001, 001, 000, 50 003, 001, 001, 000, 026, 001, 001, 000, 007, 001, 001, 000, 002, 001, 001, 000, 005, 001, 002, 000, 51 001, 003, 001, 001, 010, 003, 001, 000, 003, 003, 001, 000, 003, 003, 002, 000, 001, 001, 017, 000, 52 002, 001, 002, 003, 002, 000, 012, 004, 021, 000, 003, 003, 001, 000, 010, 001, 002, 000, 002, 001, 53 002, 000, 026, 001, 001, 000, 007, 001, 001, 000, 002, 001, 001, 000, 005, 001, 002, 000, 001, 003, 54 001, 001, 007, 003, 002, 000, 002, 003, 002, 000, 003, 003, 010, 000, 002, 003, 004, 000, 002, 001, 55 001, 000, 003, 001, 002, 003, 002, 000, 012, 004, 001, 000, 001, 001, 020, 000, 001, 003, 001, 001, 56 001, 000, 006, 001, 003, 000, 003, 001, 001, 000, 004, 001, 003, 000, 002, 001, 001, 000, 001, 001, 57 001, 000, 002, 001, 003, 000, 002, 001, 003, 000, 003, 001, 003, 000, 014, 001, 004, 000, 005, 003, 58 003, 000, 003, 003, 001, 000, 004, 003, 002, 000, 001, 001, 006, 000, 001, 003, 016, 000, 012, 004, 59 021, 000, 003, 003, 001, 000, 010, 001, 001, 000, 003, 001, 001, 000, 027, 001, 001, 000, 012, 001, 60 001, 000, 005, 001, 003, 000, 001, 001, 007, 003, 001, 000, 003, 003, 001, 000, 004, 003, 007, 000, 61 002, 003, 001, 000, 002, 001, 006, 000, 002, 001, 002, 003, 002, 000, 012, 004, 022, 000, 002, 003, 62 001, 000, 010, 001, 001, 000, 003, 001, 001, 000, 027, 001, 001, 000, 012, 001, 001, 000, 005, 001, 63 002, 000, 001, 003, 001, 001, 007, 003, 001, 000, 003, 003, 001, 000, 004, 003, 007, 000, 002, 003, 64 007, 000, 001, 001, 001, 000, 002, 001, 002, 003, 002, 000, 012, 004, 001, 000, 002, 001, 017, 000, 65 002, 003, 001, 000, 010, 001, 001, 000, 003, 001, 001, 000, 051, 001, 002, 000, 001, 001, 007, 003, 66 001, 000, 003, 003, 001, 000, 004, 003, 001, 001, 010, 000, 001, 003, 010, 000, 002, 001, 002, 003, 67 002, 000, 012, 004, 012, 000, 006, 001, 002, 000, 002, 003, 001, 000, 022, 001, 003, 000, 030, 001, 68 001, 000, 011, 001, 001, 000, 001, 001, 002, 000, 007, 001, 003, 000, 001, 003, 004, 000, 006, 003, 69 001, 000, 001, 003, 001, 000, 010, 003, 022, 000, 002, 003, 015, 000, 060, 020, 001, 021, 002, 020, 70 007, 021, 005, 000, 007, 020, 010, 021, 001, 000, 012, 004, 047, 000, 002, 020, 001, 000, 001, 020, 71 002, 000, 002, 020, 001, 000, 001, 020, 002, 000, 001, 020, 006, 000, 004, 020, 001, 000, 007, 020, 72 001, 000, 003, 020, 001, 000, 001, 020, 001, 000, 001, 020, 002, 000, 002, 020, 001, 000, 004, 020, 73 001, 021, 002, 020, 006, 021, 001, 000, 002, 021, 001, 020, 002, 000, 005, 020, 001, 000, 001, 020, 74 001, 000, 006, 021, 002, 000, 012, 004, 002, 000, 004, 020, 040, 000, 001, 001, 027, 000, 002, 003, 75 006, 000, 012, 004, 013, 000, 001, 003, 001, 000, 001, 003, 001, 000, 001, 003, 004, 000, 002, 003, 76 010, 001, 001, 000, 044, 001, 004, 000, 024, 003, 001, 000, 002, 003, 005, 001, 013, 003, 001, 000, 77 044, 003, 011, 000, 001, 003, 071, 000, 053, 020, 024, 021, 001, 020, 012, 004, 006, 000, 006, 020, 78 004, 021, 004, 020, 003, 021, 001, 020, 003, 021, 002, 020, 007, 021, 003, 020, 004, 021, 015, 020, 79 014, 021, 001, 020, 001, 021, 012, 004, 004, 021, 002, 020, 046, 001, 001, 000, 001, 001, 005, 000, 80 001, 001, 002, 000, 053, 001, 001, 000, 004, 001, int('\u0100'), 002, 0111, 001, 001, 000, 004, 001, 002, 000, 81 007, 001, 001, 000, 001, 001, 001, 000, 004, 001, 002, 000, 051, 001, 001, 000, 004, 001, 002, 000, 82 041, 001, 001, 000, 004, 001, 002, 000, 007, 001, 001, 000, 001, 001, 001, 000, 004, 001, 002, 000, 83 017, 001, 001, 000, 071, 001, 001, 000, 004, 001, 002, 000, 0103, 001, 002, 000, 003, 003, 040, 000, 84 020, 001, 020, 000, 0125, 001, 014, 000, int('\u026c'), 001, 002, 000, 021, 001, 001, 000, 032, 001, 005, 000, 85 0113, 001, 003, 000, 003, 001, 017, 000, 015, 001, 001, 000, 004, 001, 003, 003, 013, 000, 022, 001, 86 003, 003, 013, 000, 022, 001, 002, 003, 014, 000, 015, 001, 001, 000, 003, 001, 001, 000, 002, 003, 87 014, 000, 064, 020, 040, 021, 003, 000, 001, 020, 004, 000, 001, 020, 001, 021, 002, 000, 012, 004, 88 041, 000, 004, 003, 001, 000, 012, 004, 006, 000, 0130, 001, 010, 000, 051, 001, 001, 003, 001, 001, 89 005, 000, 0106, 001, 012, 000, 035, 001, 003, 000, 014, 003, 004, 000, 014, 003, 012, 000, 012, 004, 90 036, 020, 002, 000, 005, 020, 013, 000, 054, 020, 004, 000, 021, 021, 007, 020, 002, 021, 006, 000, 91 012, 004, 001, 020, 003, 000, 002, 020, 040, 000, 027, 001, 005, 003, 004, 000, 065, 020, 012, 021, 92 001, 000, 035, 021, 002, 000, 001, 003, 012, 004, 006, 000, 012, 004, 006, 000, 016, 020, 0122, 000, 93 005, 003, 057, 001, 021, 003, 007, 001, 004, 000, 012, 004, 021, 000, 011, 003, 014, 000, 003, 003, 94 036, 001, 015, 003, 002, 001, 012, 004, 054, 001, 016, 003, 014, 000, 044, 001, 024, 003, 010, 000, 95 012, 004, 003, 000, 003, 001, 012, 004, 044, 001, 0122, 000, 003, 003, 001, 000, 025, 003, 004, 001, 96 001, 003, 004, 001, 003, 003, 002, 001, 011, 000, 0300, 001, 047, 003, 025, 000, 004, 003, int('\u0116'), 001, 97 002, 000, 006, 001, 002, 000, 046, 001, 002, 000, 006, 001, 002, 000, 010, 001, 001, 000, 001, 001, 98 001, 000, 001, 001, 001, 000, 001, 001, 001, 000, 037, 001, 002, 000, 065, 001, 001, 000, 007, 001, 99 001, 000, 001, 001, 003, 000, 003, 001, 001, 000, 007, 001, 003, 000, 004, 001, 002, 000, 006, 001, 100 004, 000, 015, 001, 005, 000, 003, 001, 001, 000, 007, 001, 017, 000, 004, 003, 010, 000, 002, 010, 101 012, 000, 001, 010, 002, 000, 001, 006, 002, 000, 005, 003, 020, 000, 002, 011, 003, 000, 001, 007, 102 017, 000, 001, 011, 013, 000, 005, 003, 001, 000, 012, 003, 001, 000, 001, 001, 015, 000, 001, 001, 103 020, 000, 015, 001, 063, 000, 041, 003, 021, 000, 001, 001, 004, 000, 001, 001, 002, 000, 012, 001, 104 001, 000, 001, 001, 003, 000, 005, 001, 006, 000, 001, 001, 001, 000, 001, 001, 001, 000, 001, 001, 105 001, 000, 004, 001, 001, 000, 013, 001, 002, 000, 004, 001, 005, 000, 005, 001, 004, 000, 001, 001, 106 021, 000, 051, 001, int('\u032d'), 000, 064, 001, int('\u0716'), 000, 057, 001, 001, 000, 057, 001, 001, 000, 0205, 001, 107 006, 000, 004, 001, 003, 003, 002, 001, 014, 000, 046, 001, 001, 000, 001, 001, 005, 000, 001, 001, 108 002, 000, 070, 001, 007, 000, 001, 001, 017, 000, 001, 003, 027, 001, 011, 000, 007, 001, 001, 000, 109 007, 001, 001, 000, 007, 001, 001, 000, 007, 001, 001, 000, 007, 001, 001, 000, 007, 001, 001, 000, 110 007, 001, 001, 000, 007, 001, 001, 000, 040, 003, 057, 000, 001, 001, 0120, 000, 032, 012, 001, 000, 111 0131, 012, 014, 000, 0326, 012, 057, 000, 001, 001, 001, 000, 001, 012, 031, 000, 011, 012, 006, 003, 112 001, 000, 005, 005, 002, 000, 003, 012, 001, 001, 001, 001, 004, 000, 0126, 013, 002, 000, 002, 003, 113 002, 005, 003, 013, 0133, 005, 001, 000, 004, 005, 005, 000, 051, 001, 003, 000, 0136, 002, 021, 000, 114 033, 001, 065, 000, 020, 005, 0320, 000, 057, 005, 001, 000, 0130, 005, 0250, 000, int('\u19b6'), 012, 0112, 000, 115 int('\u51cd'), 012, 063, 000, int('\u048d'), 001, 0103, 000, 056, 001, 002, 000, int('\u010d'), 001, 003, 000, 020, 001, 012, 004, 116 002, 001, 024, 000, 057, 001, 004, 003, 001, 000, 012, 003, 001, 000, 031, 001, 007, 000, 001, 003, 117 0120, 001, 002, 003, 045, 000, 011, 001, 002, 000, 0147, 001, 002, 000, 004, 001, 001, 000, 004, 001, 118 014, 000, 013, 001, 0115, 000, 012, 001, 001, 003, 003, 001, 001, 003, 004, 001, 001, 003, 027, 001, 119 005, 003, 030, 000, 064, 001, 014, 000, 002, 003, 062, 001, 021, 003, 013, 000, 012, 004, 006, 000, 120 022, 003, 006, 001, 003, 000, 001, 001, 004, 000, 012, 004, 034, 001, 010, 003, 002, 000, 027, 001, 121 015, 003, 014, 000, 035, 002, 003, 000, 004, 003, 057, 001, 016, 003, 016, 000, 001, 001, 012, 004, 122 046, 000, 051, 001, 016, 003, 011, 000, 003, 001, 001, 003, 010, 001, 002, 003, 002, 000, 012, 004, 123 006, 000, 033, 020, 001, 021, 004, 000, 060, 020, 001, 021, 001, 020, 003, 021, 002, 020, 002, 021, 124 005, 020, 002, 021, 001, 020, 001, 021, 001, 020, 030, 000, 005, 020, 013, 001, 005, 003, 002, 000, 125 003, 001, 002, 003, 012, 000, 006, 001, 002, 000, 006, 001, 002, 000, 006, 001, 011, 000, 007, 001, 126 001, 000, 007, 001, 0221, 000, 043, 001, 010, 003, 001, 000, 002, 003, 002, 000, 012, 004, 006, 000, 127 int('\u2ba4'), 002, 014, 000, 027, 002, 004, 000, 061, 002, int('\u2104'), 000, int('\u016e'), 012, 002, 000, 0152, 012, 046, 000, 128 007, 001, 014, 000, 005, 001, 005, 000, 001, 016, 001, 003, 012, 016, 001, 000, 015, 016, 001, 000, 129 005, 016, 001, 000, 001, 016, 001, 000, 002, 016, 001, 000, 002, 016, 001, 000, 012, 016, 0142, 001, 130 041, 000, int('\u016b'), 001, 022, 000, 0100, 001, 002, 000, 066, 001, 050, 000, 014, 001, 004, 000, 020, 003, 131 001, 007, 002, 000, 001, 006, 001, 007, 013, 000, 007, 003, 014, 000, 002, 011, 030, 000, 003, 011, 132 001, 007, 001, 000, 001, 010, 001, 000, 001, 007, 001, 006, 032, 000, 005, 001, 001, 000, 0207, 001, 133 002, 000, 001, 003, 007, 000, 001, 010, 004, 000, 001, 007, 001, 000, 001, 010, 001, 000, 012, 004, 134 001, 006, 001, 007, 005, 000, 032, 001, 004, 000, 001, 011, 001, 000, 032, 001, 013, 000, 070, 005, 135 002, 003, 037, 002, 003, 000, 006, 002, 002, 000, 006, 002, 002, 000, 006, 002, 002, 000, 003, 002, 136 034, 000, 003, 003, 004, 000, 014, 001, 001, 000, 032, 001, 001, 000, 023, 001, 001, 000, 002, 001, 137 001, 000, 017, 001, 002, 000, 016, 001, 042, 000, 0173, 001, 0105, 000, 065, 001, 0210, 000, 001, 003, 138 0202, 000, 035, 001, 003, 000, 061, 001, 057, 000, 037, 001, 021, 000, 033, 001, 065, 000, 036, 001, 139 002, 000, 044, 001, 004, 000, 010, 001, 001, 000, 005, 001, 052, 000, 0236, 001, 002, 000, 012, 004, 140 int('\u0356'), 000, 006, 001, 002, 000, 001, 001, 001, 000, 054, 001, 001, 000, 002, 001, 003, 000, 001, 001, 141 002, 000, 027, 001, 0252, 000, 026, 001, 012, 000, 032, 001, 0106, 000, 070, 001, 006, 000, 002, 001, 142 0100, 000, 001, 001, 003, 003, 001, 000, 002, 003, 005, 000, 004, 003, 004, 001, 001, 000, 003, 001, 143 001, 000, 033, 001, 004, 000, 003, 003, 004, 000, 001, 003, 040, 000, 035, 001, 0203, 000, 066, 001, 144 012, 000, 026, 001, 012, 000, 023, 001, 0215, 000, 0111, 001, int('\u03b7'), 000, 003, 003, 065, 001, 017, 003, 145 037, 000, 012, 004, 020, 000, 003, 003, 055, 001, 013, 003, 002, 000, 001, 003, 022, 000, 031, 001, 146 007, 000, 012, 004, 006, 000, 003, 003, 044, 001, 016, 003, 001, 000, 012, 004, 0100, 000, 003, 003, 147 060, 001, 016, 003, 004, 001, 013, 000, 012, 004, int('\u04a6'), 000, 053, 001, 015, 003, 010, 000, 012, 004, 148 int('\u0936'), 000, int('\u036f'), 001, 0221, 000, 0143, 001, int('\u0b9d'), 000, int('\u042f'), 001, int('\u33d1'), 000, int('\u0239'), 001, int('\u04c7'), 000, 0105, 001, 149 013, 000, 001, 001, 056, 003, 020, 000, 004, 003, 015, 001, int('\u4060'), 000, 001, 005, 001, 013, int('\u2163'), 000, 150 005, 003, 003, 000, 026, 003, 002, 000, 007, 003, 036, 000, 004, 003, 0224, 000, 003, 003, int('\u01bb'), 000, 151 0125, 001, 001, 000, 0107, 001, 001, 000, 002, 001, 002, 000, 001, 001, 002, 000, 002, 001, 002, 000, 152 004, 001, 001, 000, 014, 001, 001, 000, 001, 001, 001, 000, 007, 001, 001, 000, 0101, 001, 001, 000, 153 004, 001, 002, 000, 010, 001, 001, 000, 007, 001, 001, 000, 034, 001, 001, 000, 004, 001, 001, 000, 154 005, 001, 001, 000, 001, 001, 003, 000, 007, 001, 001, 000, int('\u0154'), 001, 002, 000, 031, 001, 001, 000, 155 031, 001, 001, 000, 037, 001, 001, 000, 031, 001, 001, 000, 037, 001, 001, 000, 031, 001, 001, 000, 156 037, 001, 001, 000, 031, 001, 001, 000, 037, 001, 001, 000, 031, 001, 001, 000, 010, 001, 002, 000, 157 062, 004, int('\u1600'), 000, 004, 001, 001, 000, 033, 001, 001, 000, 002, 001, 001, 000, 001, 001, 002, 000, 158 001, 001, 001, 000, 012, 001, 001, 000, 004, 001, 001, 000, 001, 001, 001, 000, 001, 001, 006, 000, 159 001, 001, 004, 000, 001, 001, 001, 000, 001, 001, 001, 000, 001, 001, 001, 000, 003, 001, 001, 000, 160 002, 001, 001, 000, 001, 001, 002, 000, 001, 001, 001, 000, 001, 001, 001, 000, 001, 001, 001, 000, 161 001, 001, 001, 000, 001, 001, 001, 000, 002, 001, 001, 000, 001, 001, 002, 000, 004, 001, 001, 000, 162 007, 001, 001, 000, 004, 001, 001, 000, 004, 001, 001, 000, 001, 001, 001, 000, 012, 001, 001, 000, 163 021, 001, 005, 000, 003, 001, 001, 000, 005, 001, 001, 000, 021, 001, int('\u032a'), 000, 032, 017, 001, 013, 164 int('\u0dff'), 000, int('\ua6d7'), 012, 051, 000, int('\u1035'), 012, 013, 000, 0336, 012, int('\u3fe2'), 000, int('\u021e'), 012, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\uffff'), 000, int('\u05ee'), 000, 165 001, 003, 036, 000, 0140, 003, 0200, 000, 0360, 003, int('\uffff'), 000, int('\uffff'), 000, int('\ufe12'), 0, 166 } 167 168 /* Translates characters to character classes */ 169 var ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED) 170 171 /* Unpacks the comressed character translation table */ 172 func zzUnpackCMap(packed []int) []rune { 173 m := make([]rune, 0x110000) 174 j := 0 // index in unpacked array 175 var count int 176 assert(len(packed) == 2836) 177 for i, value := range packed { 178 if i%2 == 0 { 179 count = value 180 } else { 181 m[j] = rune(value) 182 j++ 183 count-- 184 for count > 0 { 185 m[j] = rune(value) 186 j++ 187 count-- 188 } 189 } 190 } 191 return m 192 } 193 194 /* Translates DFA states to action switch labels. */ 195 var ZZ_ACTION = zzUnpackAction([]int{ 196 001, 000, 001, 001, 001, 002, 001, 003, 001, 004, 001, 005, 001, 001, 001, 006, 197 001, 007, 001, 002, 001, 001, 001, 010, 001, 002, 001, 000, 001, 002, 001, 000, 198 001, 004, 001, 000, 002, 002, 002, 000, 001, 001, 001, 0, 199 }) 200 201 func zzUnpackAction(packed []int) []int { 202 m := make([]int, 24) 203 j := 0 204 for i, l := 0, len(packed); i < l; i += 2 { 205 count, value := packed[i], packed[i+1] 206 m[j] = value 207 j++ 208 count-- 209 for count > 0 { 210 m[j] = value 211 j++ 212 count-- 213 } 214 } 215 return m 216 } 217 218 /* Translates a state to a row index in the transition table */ 219 var ZZ_ROWMAP = zzUnpackRowMap([]int{ 220 000, 000, 000, 022, 000, 044, 000, 066, 000, 0110, 000, 0132, 000, 0154, 000, 176, 221 000, 0220, 000, 0242, 000, 0264, 000, 0306, 000, 0330, 000, 0352, 000, 0374, 000, int('\u010e'), 222 000, int('\u0120'), 000, 0154, 000, int('\u0132'), 000, int('\u0144'), 000, int('\u0156'), 000, 0264, 000, int('\u0168'), 000, int('\u017a'), 223 }) 224 225 func zzUnpackRowMap(packed []int) []int { 226 m := make([]int, 24) 227 j := 0 228 for i, l := 0, len(packed); i < l; i += 2 { 229 high, low := packed[i]<<16, packed[i+1] 230 m[j] = high | low 231 j++ 232 } 233 return m 234 } 235 236 /* The transition table of the DFA */ 237 var ZZ_TRANS = zzUnpackTrans([]int{ 238 001, 002, 001, 003, 001, 004, 001, 002, 001, 005, 001, 006, 003, 002, 001, 007, 239 001, 010, 001, 011, 002, 002, 001, 012, 001, 013, 002, 014, 023, 000, 003, 003, 240 001, 015, 001, 000, 001, 016, 001, 000, 001, 016, 001, 017, 002, 000, 001, 016, 241 001, 000, 001, 012, 002, 000, 001, 003, 001, 000, 001, 003, 002, 004, 001, 015, 242 001, 000, 001, 016, 001, 000, 001, 016, 001, 017, 002, 000, 001, 016, 001, 000, 243 001, 012, 002, 000, 001, 004, 001, 000, 002, 003, 002, 005, 002, 000, 002, 020, 244 001, 021, 002, 000, 001, 020, 001, 000, 001, 012, 002, 000, 001, 005, 003, 000, 245 001, 006, 001, 000, 001, 006, 003, 000, 001, 017, 007, 000, 001, 006, 001, 000, 246 002, 003, 001, 022, 001, 005, 001, 023, 003, 000, 001, 022, 004, 000, 001, 012, 247 002, 000, 001, 022, 003, 000, 001, 010, 015, 000, 001, 010, 003, 000, 001, 011, 248 015, 000, 001, 011, 001, 000, 002, 003, 001, 012, 001, 015, 001, 000, 001, 016, 249 001, 000, 001, 016, 001, 017, 002, 000, 001, 024, 001, 025, 001, 012, 002, 000, 250 001, 012, 003, 000, 001, 026, 013, 000, 001, 027, 001, 000, 001, 026, 003, 000, 251 001, 014, 014, 000, 002, 014, 001, 000, 002, 003, 002, 015, 002, 000, 002, 030, 252 001, 017, 002, 000, 001, 030, 001, 000, 001, 012, 002, 000, 001, 015, 001, 000, 253 002, 003, 001, 016, 012, 000, 001, 003, 002, 000, 001, 016, 001, 000, 002, 003, 254 001, 017, 001, 015, 001, 023, 003, 000, 001, 017, 004, 000, 001, 012, 002, 000, 255 001, 017, 003, 000, 001, 020, 001, 005, 014, 000, 001, 020, 001, 000, 002, 003, 256 001, 021, 001, 005, 001, 023, 003, 000, 001, 021, 004, 000, 001, 012, 002, 000, 257 001, 021, 003, 000, 001, 023, 001, 000, 001, 023, 003, 000, 001, 017, 007, 000, 258 001, 023, 001, 000, 002, 003, 001, 024, 001, 015, 004, 000, 001, 017, 004, 000, 259 001, 012, 002, 000, 001, 024, 003, 000, 001, 025, 012, 000, 001, 024, 002, 000, 260 001, 025, 003, 000, 001, 027, 013, 000, 001, 027, 001, 000, 001, 027, 003, 000, 261 001, 030, 001, 015, 014, 000, 001, 030, 262 }) 263 264 func zzUnpackTrans(packed []int) []int { 265 m := make([]int, 396) 266 j := 0 267 for i, l := 0, len(packed); i < l; i += 2 { 268 count, value := packed[i], packed[i+1]-1 269 m[j] = value 270 j++ 271 count-- 272 for count > 0 { 273 m[j] = value 274 j++ 275 count-- 276 } 277 } 278 return m 279 } 280 281 /* error codes */ 282 const ( 283 ZZ_UNKNOWN_ERROR = 0 284 ZZ_NO_MATCH = 1 285 ) 286 287 /* error messages for the codes above */ 288 var ZZ_ERROR_MSG = [3]string{ 289 "Unkown internal scanner error", 290 "Error: could not match input", 291 "Error: pushback value was too large", 292 } 293 294 /* ZZ_ATTRIBUTE[aState] contains the attributes of state aState */ 295 var ZZ_ATTRIBUTE = zzUnpackAttribute([]int{ 296 001, 000, 001, 011, 013, 001, 001, 000, 001, 001, 001, 000, 001, 001, 001, 000, 297 002, 001, 002, 000, 001, 001, 001, 0, 298 }) 299 300 func zzUnpackAttribute(packed []int) []int { 301 m := make([]int, 24) 302 j := 0 303 for i, l := 0, len(packed); i < l; i += 2 { 304 count, value := packed[i], packed[i+1] 305 m[j] = value 306 j++ 307 count-- 308 for count > 0 { 309 m[j] = value 310 j++ 311 count-- 312 } 313 i += 2 314 } 315 return m 316 } 317 318 const ( 319 WORD_TYPE = ALPHANUM 320 NUMERIC_TYPE = NUM 321 SOUTH_EAST_ASIAN_TYPE = SOUTHEAST_ASIAN 322 IDEOGRAPHIC_TYPE = IDEOGRAPHIC 323 HIRAGANA_TYPE = HIRAGANA 324 KATAKANA_TYPE = KATAKANA 325 HANGUL_TYPE = HANGUL 326 ) 327 328 /* 329 This class implements Word Break rules from the Unicode Text 330 Segmentation algorithm, as specified in Unicode Standard Annex #29. 331 332 Tokens produced are of the following types: 333 334 - <ALPHANUM>: A sequence of alphabetic and numeric characters 335 - <NUM>: A number 336 - <SOUTHEAST_ASIAN>: A sequence of characters from South and Southeast Asian languages, including Thai, Lao, Myanmar, and Khmer 337 - IDEOGRAPHIC>: A single CJKV ideographic character 338 - <HIRAGANA>: A single hiragana character 339 340 Technically it should auto generated by JFlex but there is no GoFlex 341 yet. So it's a line-by-line port. 342 */ 343 type StandardTokenizerImpl struct { 344 // the input device 345 zzReader io.RuneReader 346 347 // the current state of the DFA 348 zzState int 349 350 // the current lexical state 351 zzLexicalState int 352 353 // this buffer contains the current text to be matched and is the 354 // source of yytext() string 355 zzBuffer []rune 356 357 // the text position at the last accepting state 358 zzMarkedPos int 359 360 // the current text position in the buffer 361 zzCurrentPos int 362 363 // startRead marks the beginning of the yytext() string in the buffer 364 zzStartRead int 365 366 // endRead marks the last character in the buffer, that has been read from input 367 zzEndRead int 368 369 // number of newlines encountered up to the start of the matched text 370 yyline int 371 372 // the number of characters up to the start of the matched text 373 _yychar int 374 375 // the number of characters from the last newline up to the start of the matched text 376 yycolumn int 377 378 // zzAtBOL == true <=> the scanner is currently at the beginning of a line 379 zzAtBOL bool 380 381 // zzAtEOF == true <=> the scanner is at the EOF 382 zzAtEOF bool 383 384 // denotes if the user-EOF-code has already been executed 385 zzEOFDone bool 386 387 // The number of occupied positions in zzBuffer beyond zzEndRead. 388 // When a lead/high surrogate has been read from the input stream 389 // into the final zzBuffer position, this will have a value of 1; 390 // otherwise, it will have a value of 0. 391 zzFinalHighSurrogate int 392 } 393 394 func newStandardTokenizerImpl(in io.RuneReader) *StandardTokenizerImpl { 395 return &StandardTokenizerImpl{ 396 zzReader: in, 397 zzLexicalState: YYINITIAL, 398 zzBuffer: make([]rune, ZZ_BUFFERSIZE), 399 zzAtBOL: true, 400 } 401 } 402 403 func (t *StandardTokenizerImpl) yychar() int { 404 return t._yychar 405 } 406 407 /* Fills CharTermAttribute with the current token text. */ 408 func (t *StandardTokenizerImpl) text(tt CharTermAttribute) { 409 tt.CopyBuffer(t.zzBuffer[t.zzStartRead:t.zzMarkedPos]) 410 } 411 412 /* Refills the input buffer. */ 413 func (t *StandardTokenizerImpl) zzRefill() (bool, error) { 414 // first: make room (if you can) 415 if t.zzStartRead > 0 { 416 t.zzEndRead += t.zzFinalHighSurrogate 417 t.zzFinalHighSurrogate = 0 418 copy(t.zzBuffer, t.zzBuffer[t.zzStartRead:t.zzEndRead]) 419 420 // translate stored positions 421 t.zzEndRead -= t.zzStartRead 422 t.zzCurrentPos -= t.zzStartRead 423 t.zzMarkedPos -= t.zzStartRead 424 t.zzStartRead = 0 425 } 426 427 // fill the buffer with new input 428 var requested = len(t.zzBuffer) - t.zzEndRead - t.zzFinalHighSurrogate 429 var totalRead = 0 430 var err error 431 for totalRead < requested && err != io.EOF { 432 var numRead int 433 if numRead, err = readRunes(t.zzReader.(io.RuneReader), 434 t.zzBuffer[t.zzEndRead+totalRead:]); err != nil && err != io.EOF { 435 return false, err 436 } 437 totalRead += numRead 438 } 439 440 if totalRead > 0 { 441 t.zzEndRead += totalRead 442 if totalRead == requested { // possibly more input available 443 panic("niy") 444 } 445 return false, nil 446 } 447 448 assert(totalRead == 0 && err == io.EOF) 449 return true, nil 450 } 451 452 func readRunes(r io.RuneReader, buffer []rune) (int, error) { 453 for i, _ := range buffer { 454 ch, _, err := r.ReadRune() 455 if err != nil { 456 return i, err 457 } 458 buffer[i] = ch 459 } 460 return len(buffer), nil 461 } 462 463 /* 464 Resets the scanner to read from a new input stream. 465 Does not close the old reader. 466 467 All internal variables are reset, the old input stream 468 cannot be reused (internal buffer is discarded and lost). 469 Lexical state is set to ZZ_INITIAL. 470 471 Internal scan buffer is resized down to its initial length, if it has grown. 472 */ 473 func (t *StandardTokenizerImpl) yyreset(reader io.RuneReader) { 474 t.zzReader = reader 475 t.zzAtBOL = true 476 t.zzAtEOF = false 477 t.zzEOFDone = false 478 t.zzEndRead, t.zzStartRead = 0, 0 479 t.zzCurrentPos, t.zzMarkedPos = 0, 0 480 t.zzFinalHighSurrogate = 0 481 t.yyline, t._yychar, t.yycolumn = 0, 0, 0 482 t.zzLexicalState = YYINITIAL 483 if len(t.zzBuffer) > ZZ_BUFFERSIZE { 484 t.zzBuffer = make([]rune, ZZ_BUFFERSIZE) 485 } 486 } 487 488 /* Returns the length of the matched text region. */ 489 func (t *StandardTokenizerImpl) yylength() int { 490 return t.zzMarkedPos - t.zzStartRead 491 } 492 493 /* 494 Reports an error that occurred while scanning. 495 496 In a wellcormed scanner (no or only correct usage of yypushack(int) 497 and a match-all fallback rule) this method will only be called with 498 things that "can't possibly happen". If thismethod is called, 499 something is seriously wrong (e.g. a JFlex bug producing a faulty 500 scanner etc.). 501 502 Usual syntax/scanner level error handling should be done in error 503 fallback rules. 504 */ 505 func (t *StandardTokenizerImpl) zzScanError(errorCode int) { 506 var msg string 507 if errorCode >= 0 && errorCode < len(ZZ_ERROR_MSG) { 508 msg = ZZ_ERROR_MSG[errorCode] 509 } else { 510 msg = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR] 511 } 512 panic(msg) 513 } 514 515 /* 516 Resumes scanning until the next regular expression is matched, the 517 end of input is encountered or an I/O-Error occurs. 518 */ 519 func (t *StandardTokenizerImpl) nextToken() (int, error) { 520 var zzInput, zzAction int 521 522 // cached fields: 523 var zzCurrentPosL, zzMarkedPosL int 524 zzEndReadL := t.zzEndRead 525 zzBufferL := t.zzBuffer 526 zzCMapL := ZZ_CMAP 527 528 zzTransL := ZZ_TRANS 529 zzRowMapL := ZZ_ROWMAP 530 zzAttrL := ZZ_ATTRIBUTE 531 532 for { 533 zzMarkedPosL = t.zzMarkedPos 534 535 t._yychar += zzMarkedPosL - t.zzStartRead 536 537 zzAction = -1 538 539 zzCurrentPosL = zzMarkedPosL 540 t.zzCurrentPos = zzMarkedPosL 541 t.zzStartRead = zzMarkedPosL 542 543 t.zzState = ZZ_LEXSTATE[t.zzLexicalState] 544 545 // set up zzAction for empty match case: 546 if zzAttributes := zzAttrL[t.zzState]; (zzAttributes & 1) == 1 { 547 zzAction = t.zzState 548 } 549 550 for { 551 if zzCurrentPosL < zzEndReadL { 552 zzInput = int(zzBufferL[zzCurrentPosL]) 553 zzCurrentPosL++ 554 } else if t.zzAtEOF { 555 zzInput = YYEOF 556 break 557 } else { 558 // store back cached positions 559 t.zzCurrentPos = zzCurrentPosL 560 t.zzMarkedPos = zzMarkedPosL 561 eof, err := t.zzRefill() 562 if err != nil { 563 return 0, err 564 } 565 // get translated positions and possibly new buffer 566 zzCurrentPosL = t.zzCurrentPos 567 zzMarkedPosL = t.zzMarkedPos 568 zzBufferL = t.zzBuffer 569 zzEndReadL = t.zzEndRead 570 if eof { 571 zzInput = YYEOF 572 break 573 } else { 574 zzInput = int(zzBufferL[zzCurrentPosL]) 575 zzCurrentPosL++ 576 } 577 } 578 zzNext := zzTransL[zzRowMapL[t.zzState]+int(zzCMapL[zzInput])] 579 if zzNext == -1 { 580 break 581 } 582 t.zzState = zzNext 583 584 if zzAttributes := zzAttrL[t.zzState]; (zzAttributes & 1) == 1 { 585 zzAction = t.zzState 586 zzMarkedPosL = zzCurrentPosL 587 if (zzAttributes & 8) == 8 { 588 break 589 } 590 } 591 } 592 593 // store back cached position 594 t.zzMarkedPos = zzMarkedPosL 595 596 cond := zzAction 597 if zzAction >= 0 { 598 cond = ZZ_ACTION[zzAction] 599 } 600 switch cond { 601 case 1, 9, 10, 11, 12, 13, 14, 15, 16: 602 // break so we don't hit fall-through warning: 603 // not numeric, word, ideographic, hiragana, or SE Asian -- ignore it. 604 case 2: 605 return WORD_TYPE, nil 606 case 3: 607 return HANGUL_TYPE, nil 608 case 4: 609 return NUMERIC_TYPE, nil 610 case 5: 611 return KATAKANA_TYPE, nil 612 case 6: 613 return IDEOGRAPHIC_TYPE, nil 614 case 7: 615 return HIRAGANA_TYPE, nil 616 case 8: 617 return SOUTH_EAST_ASIAN_TYPE, nil 618 default: 619 if zzInput == YYEOF && t.zzStartRead == t.zzCurrentPos { 620 t.zzAtEOF = true 621 return YYEOF, nil 622 } else { 623 t.zzScanError(ZZ_NO_MATCH) 624 panic("should not be here") 625 } 626 } 627 } 628 }