| 1 | |
| 2 | #line 1 "emoji_presentation_scanner.rl" |
| 3 | /* Copyright 2019 Google LLC |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <stdbool.h> |
| 19 | |
| 20 | #ifndef EMOJI_LINKAGE |
| 21 | #define EMOJI_LINKAGE static |
| 22 | #endif |
| 23 | |
| 24 | |
| 25 | #line 23 "emoji_presentation_scanner.c" |
| 26 | static const unsigned char _emoji_presentation_trans_keys[] = { |
| 27 | 0u, 13u, 14u, 15u, 0u, 13u, 9u, 12u, 10u, 12u, 10u, 10u, 4u, 12u, 4u, 12u, |
| 28 | 6u, 6u, 9u, 12u, 8u, 8u, 8u, 10u, 9u, 14u, 0 |
| 29 | }; |
| 30 | |
| 31 | static const char _emoji_presentation_key_spans[] = { |
| 32 | 14, 2, 14, 4, 3, 1, 9, 9, |
| 33 | 1, 4, 1, 3, 6 |
| 34 | }; |
| 35 | |
| 36 | static const char _emoji_presentation_index_offsets[] = { |
| 37 | 0, 15, 18, 33, 38, 42, 44, 54, |
| 38 | 64, 66, 71, 73, 77 |
| 39 | }; |
| 40 | |
| 41 | static const char _emoji_presentation_indicies[] = { |
| 42 | 1, 1, 1, 2, 0, 0, 0, 1, |
| 43 | 0, 0, 0, 0, 0, 1, 0, 4, |
| 44 | 5, 3, 6, 6, 7, 8, 9, 9, |
| 45 | 10, 11, 9, 9, 9, 9, 9, 12, |
| 46 | 9, 5, 13, 14, 15, 0, 13, 16, |
| 47 | 17, 16, 13, 0, 17, 16, 16, 16, |
| 48 | 16, 16, 13, 16, 17, 16, 17, 16, |
| 49 | 16, 16, 16, 5, 13, 14, 15, 16, |
| 50 | 5, 18, 5, 13, 19, 20, 18, 14, |
| 51 | 21, 23, 22, 13, 22, 5, 13, 14, |
| 52 | 15, 16, 4, 16, 0 |
| 53 | }; |
| 54 | |
| 55 | static const char _emoji_presentation_trans_targs[] = { |
| 56 | 2, 4, 6, 2, 1, 2, 3, 3, |
| 57 | 7, 2, 8, 9, 12, 0, 2, 5, |
| 58 | 2, 5, 2, 10, 11, 2, 2, 2 |
| 59 | }; |
| 60 | |
| 61 | static const char _emoji_presentation_trans_actions[] = { |
| 62 | 1, 2, 2, 3, 0, 4, 7, 2, |
| 63 | 2, 8, 0, 7, 2, 0, 9, 10, |
| 64 | 11, 2, 12, 0, 10, 13, 14, 15 |
| 65 | }; |
| 66 | |
| 67 | static const char _emoji_presentation_to_state_actions[] = { |
| 68 | 0, 0, 5, 0, 0, 0, 0, 0, |
| 69 | 0, 0, 0, 0, 0 |
| 70 | }; |
| 71 | |
| 72 | static const char _emoji_presentation_from_state_actions[] = { |
| 73 | 0, 0, 6, 0, 0, 0, 0, 0, |
| 74 | 0, 0, 0, 0, 0 |
| 75 | }; |
| 76 | |
| 77 | static const char _emoji_presentation_eof_trans[] = { |
| 78 | 1, 4, 0, 1, 17, 1, 17, 17, |
| 79 | 19, 19, 22, 23, 17 |
| 80 | }; |
| 81 | |
| 82 | static const int emoji_presentation_start = 2; |
| 83 | |
| 84 | static const int emoji_presentation_en_text_and_emoji_run = 2; |
| 85 | |
| 86 | |
| 87 | #line 26 "emoji_presentation_scanner.rl" |
| 88 | |
| 89 | |
| 90 | |
| 91 | #line 100 "emoji_presentation_scanner.rl" |
| 92 | |
| 93 | |
| 94 | EMOJI_LINKAGE emoji_text_iter_t |
| 95 | scan_emoji_presentation (emoji_text_iter_t p, |
| 96 | const emoji_text_iter_t pe, |
| 97 | bool* is_emoji, |
| 98 | bool* has_vs) |
| 99 | { |
| 100 | emoji_text_iter_t ts; |
| 101 | emoji_text_iter_t te; |
| 102 | const emoji_text_iter_t eof = pe; |
| 103 | |
| 104 | (void)ts; |
| 105 | |
| 106 | unsigned act; |
| 107 | int cs; |
| 108 | |
| 109 | |
| 110 | #line 100 "emoji_presentation_scanner.c" |
| 111 | { |
| 112 | cs = emoji_presentation_start; |
| 113 | ts = 0; |
| 114 | te = 0; |
| 115 | act = 0; |
| 116 | } |
| 117 | |
| 118 | #line 106 "emoji_presentation_scanner.c" |
| 119 | { |
| 120 | int _slen; |
| 121 | int _trans; |
| 122 | const unsigned char *_keys; |
| 123 | const char *_inds; |
| 124 | if ( p == pe ) |
| 125 | goto _test_eof; |
| 126 | _resume: |
| 127 | switch ( _emoji_presentation_from_state_actions[cs] ) { |
| 128 | case 6: |
| 129 | #line 1 "NONE" |
| 130 | {ts = p;} |
| 131 | break; |
| 132 | #line 118 "emoji_presentation_scanner.c" |
| 133 | } |
| 134 | |
| 135 | _keys = _emoji_presentation_trans_keys + (cs<<1); |
| 136 | _inds = _emoji_presentation_indicies + _emoji_presentation_index_offsets[cs]; |
| 137 | |
| 138 | _slen = _emoji_presentation_key_spans[cs]; |
| 139 | _trans = _inds[ _slen > 0 && _keys[0] <=(*p) && |
| 140 | (*p) <= _keys[1] ? |
| 141 | (*p) - _keys[0] : _slen ]; |
| 142 | |
| 143 | _eof_trans: |
| 144 | cs = _emoji_presentation_trans_targs[_trans]; |
| 145 | |
| 146 | if ( _emoji_presentation_trans_actions[_trans] == 0 ) |
| 147 | goto _again; |
| 148 | |
| 149 | switch ( _emoji_presentation_trans_actions[_trans] ) { |
| 150 | case 9: |
| 151 | #line 94 "emoji_presentation_scanner.rl" |
| 152 | {te = p+1;{ *is_emoji = false; *has_vs = true; return te; }} |
| 153 | break; |
| 154 | case 15: |
| 155 | #line 95 "emoji_presentation_scanner.rl" |
| 156 | {te = p+1;{ *is_emoji = true; *has_vs = true; return te; }} |
| 157 | break; |
| 158 | case 4: |
| 159 | #line 96 "emoji_presentation_scanner.rl" |
| 160 | {te = p+1;{ *is_emoji = true; *has_vs = false; return te; }} |
| 161 | break; |
| 162 | case 8: |
| 163 | #line 97 "emoji_presentation_scanner.rl" |
| 164 | {te = p+1;{ *is_emoji = false; *has_vs = false; return te; }} |
| 165 | break; |
| 166 | case 13: |
| 167 | #line 94 "emoji_presentation_scanner.rl" |
| 168 | {te = p;p--;{ *is_emoji = false; *has_vs = true; return te; }} |
| 169 | break; |
| 170 | case 14: |
| 171 | #line 95 "emoji_presentation_scanner.rl" |
| 172 | {te = p;p--;{ *is_emoji = true; *has_vs = true; return te; }} |
| 173 | break; |
| 174 | case 11: |
| 175 | #line 96 "emoji_presentation_scanner.rl" |
| 176 | {te = p;p--;{ *is_emoji = true; *has_vs = false; return te; }} |
| 177 | break; |
| 178 | case 12: |
| 179 | #line 97 "emoji_presentation_scanner.rl" |
| 180 | {te = p;p--;{ *is_emoji = false; *has_vs = false; return te; }} |
| 181 | break; |
| 182 | case 3: |
| 183 | #line 96 "emoji_presentation_scanner.rl" |
| 184 | {{p = ((te))-1;}{ *is_emoji = true; *has_vs = false; return te; }} |
| 185 | break; |
| 186 | case 1: |
| 187 | #line 1 "NONE" |
| 188 | { switch( act ) { |
| 189 | case 2: |
| 190 | {{p = ((te))-1;} *is_emoji = true; *has_vs = true; return te; } |
| 191 | break; |
| 192 | case 3: |
| 193 | {{p = ((te))-1;} *is_emoji = true; *has_vs = false; return te; } |
| 194 | break; |
| 195 | case 4: |
| 196 | {{p = ((te))-1;} *is_emoji = false; *has_vs = false; return te; } |
| 197 | break; |
| 198 | } |
| 199 | } |
| 200 | break; |
| 201 | case 10: |
| 202 | #line 1 "NONE" |
| 203 | {te = p+1;} |
| 204 | #line 95 "emoji_presentation_scanner.rl" |
| 205 | {act = 2;} |
| 206 | break; |
| 207 | case 2: |
| 208 | #line 1 "NONE" |
| 209 | {te = p+1;} |
| 210 | #line 96 "emoji_presentation_scanner.rl" |
| 211 | {act = 3;} |
| 212 | break; |
| 213 | case 7: |
| 214 | #line 1 "NONE" |
| 215 | {te = p+1;} |
| 216 | #line 97 "emoji_presentation_scanner.rl" |
| 217 | {act = 4;} |
| 218 | break; |
| 219 | #line 188 "emoji_presentation_scanner.c" |
| 220 | } |
| 221 | |
| 222 | _again: |
| 223 | switch ( _emoji_presentation_to_state_actions[cs] ) { |
| 224 | case 5: |
| 225 | #line 1 "NONE" |
| 226 | {ts = 0;} |
| 227 | break; |
| 228 | #line 195 "emoji_presentation_scanner.c" |
| 229 | } |
| 230 | |
| 231 | if ( ++p != pe ) |
| 232 | goto _resume; |
| 233 | _test_eof: {} |
| 234 | if ( p == eof ) |
| 235 | { |
| 236 | if ( _emoji_presentation_eof_trans[cs] > 0 ) { |
| 237 | _trans = _emoji_presentation_eof_trans[cs] - 1; |
| 238 | goto _eof_trans; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | } |
| 243 | |
| 244 | #line 118 "emoji_presentation_scanner.rl" |
| 245 | |
| 246 | |
| 247 | /* Should not be reached. */ |
| 248 | *is_emoji = false; |
| 249 | *has_vs = false; |
| 250 | return p; |
| 251 | } |
| 252 | |