File Coverage

third_party/modest/source/mycss/tokenizer.c
Criterion Covered Total %
statement 328 696 47.1
branch 43 270 15.9
condition n/a
subroutine n/a
pod n/a
total 371 966 38.4


line stmt bran cond sub pod time code
1             /*
2             Copyright (C) 2016-2017 Alexander Borisov
3            
4             This library is free software; you can redistribute it and/or
5             modify it under the terms of the GNU Lesser General Public
6             License as published by the Free Software Foundation; either
7             version 2.1 of the License, or (at your option) any later version.
8            
9             This library is distributed in the hope that it will be useful,
10             but WITHOUT ANY WARRANTY; without even the implied warranty of
11             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12             Lesser General Public License for more details.
13            
14             You should have received a copy of the GNU Lesser General Public
15             License along with this library; if not, write to the Free Software
16             Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17            
18             Author: lex.borisov@gmail.com (Alexander Borisov)
19             */
20              
21             #include "mycss/tokenizer.h"
22             #include "mycss/tokenizer_resource.h"
23             #include "mycore/utils/resources.h"
24              
25 129           mystatus_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length)
26             {
27 129           entry->current_buffer = mycore_incoming_buffer_add(entry->current_buffer, entry->mcobject_incoming_buffer,
28             css, css_length);
29            
30 129 50         if(entry->current_buffer == NULL)
31 0           return MyCSS_STATUS_ERROR_TOKENIZER_INCOMING_BUFFER_ADD;
32            
33             // first init
34 129 50         if(entry->first_buffer == NULL)
35 129           entry->first_buffer = entry->current_buffer;
36            
37 129 100         if(entry->token == NULL) {
38 74           entry->token = (mycss_token_t*)mycore_calloc(1, sizeof(mycss_token_t));
39            
40 74 50         if(entry->token == NULL)
41 0           return MyCSS_STATUS_ERROR_TOKENIZER_TOKEN_ALLOCATION;
42             }
43            
44 129           return mycss_tokenizer_process(entry, css, css_length);
45             }
46              
47 129           mystatus_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length)
48             {
49             /*
50             Why use utf-8 when the declaration says utf-16?
51             The bytes of the encoding declaration spell out “@charset "…";” in ASCII,
52             but UTF-16 is not ASCII-compatible. Either you’ve typed in complete gibberish (like 䁣桡牳整•utf-16be∻)
53             to get the right bytes in the document, which we don’t want to encourage,
54             or your document is actually in an ASCII-compatible encoding and your encoding declaration is lying.
55            
56             Either way, defaulting to UTF-8 is a decent answer.
57            
58             As well, this mimics the behavior of HTML’s attribute.
59             */
60 129 50         if(entry->encoding == MyENCODING_UTF_16LE || entry->encoding == MyENCODING_UTF_16BE)
    50          
61 0           entry->encoding = MyENCODING_UTF_8;
62            
63 129           mycss_t* mycss = entry->mycss;
64 129           mycss_tokenizer_state_f* state_f = mycss->parse_state_func;
65            
66 129           mycore_incoming_buffer_t *current = entry->current_buffer;
67            
68             do {
69 129           mycore_incoming_buffer_t *mt = entry->current_buffer;
70 129           mt->length = 0;
71            
72 847 100         while (mt->length < mt->size) {
73 718           mt->length = state_f[entry->state](entry, entry->token, mt->data, mt->length, mt->size);
74             }
75            
76 129           entry->current_buffer = mt->next;
77             }
78 129 50         while(entry->current_buffer);
79            
80 129           entry->current_buffer = current;
81            
82 129           return MyCSS_STATUS_OK;
83             }
84              
85 129           mystatus_t mycss_tokenizer_end(mycss_entry_t* entry)
86             {
87 129           mycss_t* mycss = entry->mycss;
88 129           mycss_tokenizer_state_f* state_f = mycss->parse_state_func;
89            
90 129 100         if(entry->state != MyCSS_TOKENIZER_STATE_DATA)
91             {
92 128           mycore_incoming_buffer_t *mt = entry->current_buffer;
93 128           size_t end_state = (MyCSS_TOKENIZER_STATE_LAST_ENTRY + entry->state);
94            
95 128           mt->length = state_f[end_state](entry, entry->token, mt->data, mt->length, mt->size);
96             }
97            
98 129           entry->type |= MyCSS_ENTRY_TYPE_END;
99            
100 129           return MyCSS_STATUS_OK;
101             }
102              
103 0           size_t mycss_tokenizer_run_state_single(mycss_entry_t* entry, mycss_tokenizer_state_t state, const char* css, size_t css_offset, size_t css_size)
104             {
105 0           mycss_t* mycss = entry->mycss;
106 0           mycss_tokenizer_state_f* state_f = mycss->parse_state_func;
107            
108 0           return state_f[state](entry, entry->token, css, css_offset, css_size);
109             }
110              
111 0           size_t mycss_tokenizer_state_set_current_buffer_for_continue(mycss_entry_t* entry, size_t css_offset, size_t css_minus_offset)
112             {
113 0 0         if(css_minus_offset == 0)
114 0           return css_offset;
115            
116 0 0         if(css_offset >= css_minus_offset)
117 0           return css_offset;
118            
119 0           mycore_incoming_buffer_t *buffer = entry->current_buffer;
120            
121 0           size_t need = (css_minus_offset - css_offset);
122 0           size_t position = buffer->offset - need;
123            
124 0 0         while(buffer && buffer->offset > position)
    0          
125 0           buffer = buffer->prev;
126            
127 0 0         if(buffer == NULL)
128 0           return 0;
129            
130 0           entry->current_buffer = buffer;
131            
132 0           return (position - buffer->offset);
133             }
134              
135 1           size_t mycss_tokenizer_token_strcasecmp(mycss_entry_t* entry, mycss_token_t* token, const char* to, size_t to_length)
136             {
137 1           mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
138            
139 1           size_t token_offset = token->begin - buffer->offset;
140            
141 1           return mycore_incoming_buffer_escaped_case_cmp(&buffer, to, to_length, &token_offset);
142             }
143              
144             //////////////////////
145             // Begin All State
146             //
147 268           size_t mycss_tokenizer_state_data(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
148             {
149 268           token->begin = entry->current_buffer->offset + css_offset;
150 268           token->data = &css[css_offset];
151            
152 268           entry->state = mycss_begin_chars_state_map[ (const unsigned char)css[css_offset] ];
153            
154 268           css_offset++;
155 268           return css_offset;
156             }
157              
158             /////////////////////////////////////////////////////////
159             //// whitespace
160             ////
161             /////////////////////////////////////////////////////////
162 22           size_t mycss_tokenizer_state_whitespace(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
163             {
164 22           const unsigned char *u_css = (const unsigned char*)css;
165            
166 22 50         while(css_offset < css_size)
167             {
168 22 50         if(mycss_begin_chars_state_map[ u_css[css_offset] ] != MyCSS_TOKENIZER_STATE_WHITESPACE)
169             {
170 22           token->length = (entry->current_buffer->offset + css_offset) - token->begin;
171 22           token->type = MyCSS_TOKEN_TYPE_WHITESPACE;
172            
173 22 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
174            
175 22           entry->state = MyCSS_TOKENIZER_STATE_DATA;
176 22           break;
177             }
178            
179 0           css_offset++;
180             }
181            
182 22           return css_offset;
183             }
184              
185             /////////////////////////////////////////////////////////
186             //// U+0022 QUOTATION MARK (")
187             ////
188             /////////////////////////////////////////////////////////
189 7           size_t mycss_tokenizer_state_quotation_mark(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
190             {
191             // skip QUOTATION MARK (")
192 7           token->begin += 1;
193            
194 7           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED;
195 7           entry->state_back = MyCSS_TOKENIZER_STATE_QUOTATION_MARK_BACK;
196            
197 7           return css_offset;
198             }
199              
200 7           size_t mycss_tokenizer_state_quotation_mark_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
201             {
202 7 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
203            
204 7           entry->state = MyCSS_TOKENIZER_STATE_DATA;
205 7           return css_offset;
206             }
207              
208             /////////////////////////////////////////////////////////
209             //// U+0023 NUMBER SIGN (#)
210             ////
211             /////////////////////////////////////////////////////////
212 39           size_t mycss_tokenizer_state_number_sign(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
213             {
214 39           const unsigned char *u_css = (const unsigned char*)css;
215            
216 39 50         if(mycss_chars_name_code_point_map[ u_css[css_offset] ] != 0xff)
217             {
218 39           token->begin++;
219 39           css_offset++;
220            
221 39           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
222 39           entry->state_back = MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_BACK;
223             }
224 0 0         else if(css[css_offset] == '\\') {
225 0           css_offset++;
226            
227 0 0         if(css_offset >= css_size) {
228 0           entry->state = MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_RSOLIDUS;
229 0           return css_offset;
230             }
231            
232 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
233 0           css_offset--;
234            
235 0           token->length = 1;
236 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
237            
238 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
239            
240 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
241             }
242             else {
243 0           token->begin++;
244 0           css_offset++;
245            
246 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
247 0           entry->state_back = MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_BACK;
248             }
249             }
250             else {
251 0           token->length = 1;
252 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
253            
254 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
255            
256 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
257             }
258            
259 39           return css_offset;
260             }
261              
262 0           size_t mycss_tokenizer_state_number_sign_name_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
263             {
264 0           token->type = MyCSS_TOKEN_TYPE_HASH;
265            
266 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
267            
268 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
269 0           return css_offset;
270             }
271              
272 0           size_t mycss_tokenizer_state_number_sign_name_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
273             {
274 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
275 0           token->length = 1;
276 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
277            
278 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
279            
280 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
281 0           return mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
282             }
283            
284 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
285 0           entry->state_back = MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_BACK;
286            
287 0           token->begin++;
288 0           css_offset++;
289            
290 0           return css_offset;
291             }
292              
293             /////////////////////////////////////////////////////////
294             //// U+0024 DOLLAR SIGN ($)
295             ////
296             /////////////////////////////////////////////////////////
297 0           size_t mycss_tokenizer_state_dollar_sign(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
298             {
299 0 0         if(css[css_offset] == '=') {
300 0           css_offset++;
301            
302 0           token->length = 2;
303 0           token->type = MyCSS_TOKEN_TYPE_SUFFIX_MATCH;
304             }
305             else {
306 0           token->length = 1;
307 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
308             }
309            
310 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
311            
312 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
313 0           return css_offset;
314             }
315              
316             /////////////////////////////////////////////////////////
317             //// U+0027 APOSTROPHE (')
318             ////
319             /////////////////////////////////////////////////////////
320 0           size_t mycss_tokenizer_state_apostrophe(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
321             {
322             // skip APOSTROPHE (')
323 0           token->begin += 1;
324            
325 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED;
326 0           entry->state_back = MyCSS_TOKENIZER_STATE_QUOTATION_MARK_BACK;
327            
328 0           return css_offset;
329             }
330              
331 0           size_t mycss_tokenizer_state_apostrophe_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
332             {
333 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
334            
335 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
336 0           return css_offset;
337             }
338              
339             /////////////////////////////////////////////////////////
340             //// U+0028 LEFT PARENTHESIS (()
341             ////
342             /////////////////////////////////////////////////////////
343 1           size_t mycss_tokenizer_state_left_parenthesis(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
344             {
345 1           token->length = 1;
346 1           token->type = MyCSS_TOKEN_TYPE_LEFT_PARENTHESIS;
347            
348 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
349            
350 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
351 1           return css_offset;
352             }
353              
354             /////////////////////////////////////////////////////////
355             //// U+0029 RIGHT PARENTHESIS ())
356             ////
357             /////////////////////////////////////////////////////////
358 1           size_t mycss_tokenizer_state_right_parenthesis(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
359             {
360 1           token->length = 1;
361 1           token->type = MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS;
362            
363 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
364            
365 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
366 1           return css_offset;
367             }
368              
369             /////////////////////////////////////////////////////////
370             //// U+002A ASTERISK (*)
371             ////
372             /////////////////////////////////////////////////////////
373 5           size_t mycss_tokenizer_state_asterisk(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
374             {
375 5 50         if(css[css_offset] == '=') {
376 0           css_offset++;
377            
378 0           token->length = 2;
379 0           token->type = MyCSS_TOKEN_TYPE_SUBSTRING_MATCH;
380             }
381             else {
382 5           token->length = 1;
383 5           token->type = MyCSS_TOKEN_TYPE_DELIM;
384             }
385            
386 5 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
387            
388 5           entry->state = MyCSS_TOKENIZER_STATE_DATA;
389 5           return css_offset;
390             }
391              
392             /////////////////////////////////////////////////////////
393             //// U+002B PLUS SIGN (+)
394             ////
395             /////////////////////////////////////////////////////////
396 2           size_t mycss_tokenizer_state_plus_sign(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
397             {
398 2 100         if(css[css_offset] >= '0' && css[css_offset] <= '9') {
    50          
399 1           css_offset++;
400            
401 1           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DIGIT;
402 1           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
403             }
404 1 50         else if(css[css_offset] == '.') {
405 0           css_offset++;
406            
407 0           entry->state = MyCSS_TOKENIZER_STATE_PLUS_SIGN_FULL_STOP;
408             }
409             else {
410 1           token->length = 1;
411 1           token->type = MyCSS_TOKEN_TYPE_DELIM;
412            
413 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
414            
415 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
416             }
417            
418 2           return css_offset;
419             }
420              
421 0           size_t mycss_tokenizer_state_plus_sign_full_stop(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
422             {
423 0 0         if(css[css_offset] >= '0' && css[css_offset] <= '9') {
    0          
424 0           css_offset++;
425            
426 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL;
427 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
428             }
429             else {
430 0           token->length = 1;
431 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
432            
433 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
434            
435 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
436 0           return mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
437             }
438            
439 0           return css_offset;
440             }
441              
442             /////////////////////////////////////////////////////////
443             //// U+002C COMMA (,)
444             ////
445             /////////////////////////////////////////////////////////
446 4           size_t mycss_tokenizer_state_comma(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
447             {
448 4           token->length = 1;
449 4           token->type = MyCSS_TOKEN_TYPE_COMMA;
450            
451 4 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
452            
453 4           entry->state = MyCSS_TOKENIZER_STATE_DATA;
454 4           return css_offset;
455             }
456              
457             /////////////////////////////////////////////////////////
458             //// U+002D HYPHEN-MINUS (-)
459             ////
460             /////////////////////////////////////////////////////////
461 0           size_t mycss_tokenizer_state_hyphen_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
462             {
463 0           const unsigned char *u_css = (const unsigned char*)css;
464            
465             // If the input stream starts with a number, reconsume the current input code point,
466             // consume a numeric token, and return it.
467 0 0         if(css[css_offset] >= '0' && css[css_offset] <= '9') {
    0          
468 0           css_offset++;
469            
470 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DIGIT;
471 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
472             }
473 0 0         else if(css[css_offset] == '.') {
474 0           css_offset++;
475            
476 0           entry->state = MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_FULL_STOP;
477             }
478            
479             // Otherwise, if the input stream starts with an identifier,
480             // reconsume the current input code point, consume an ident-like token, and return it.
481             // and check
482             // Otherwise, if the next 2 input code points are U+002D HYPHEN-MINUS
483             // U+003E GREATER-THAN SIGN (->), consume them and return a .
484 0 0         else if(css[css_offset] == '-') {
485 0           css_offset++;
486            
487 0           entry->state = MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS;
488             }
489            
490             // Otherwise, if the input stream starts with an identifier,
491             // reconsume the current input code point, consume an ident-like token, and return it.
492 0 0         else if(mycss_begin_chars_state_map[ u_css[css_offset] ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) {
493 0           css_offset++;
494            
495 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
496 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
497             }
498 0 0         else if(css[css_offset] == '\\') {
499 0           css_offset++;
500            
501 0           entry->state = MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_RSOLIDUS;
502             }
503            
504             // Otherwise, return a with its value set to the current input code point.
505             else {
506 0           token->length = 1;
507 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
508            
509 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
510            
511 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
512             }
513            
514 0           return css_offset;
515             }
516              
517 0           size_t mycss_tokenizer_state_hyphen_minus_full_stop(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
518             {
519 0 0         if(css[css_offset] >= '0' && css[css_offset] <= '9') {
    0          
520 0           css_offset++;
521            
522 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL;
523 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
524             }
525             else {
526 0           token->length = 1;
527 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
528            
529 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
530            
531 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
532 0           return mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
533             }
534            
535 0           return css_offset;
536             }
537              
538 0           size_t mycss_tokenizer_state_hyphen_minus_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
539             {
540 0 0         if(css[css_offset] == '>') {
541 0           css_offset++;
542            
543 0           token->length = 3;
544 0           token->type = MyCSS_TOKEN_TYPE_CDC;
545            
546 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
547            
548 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
549             }
550 0 0         else if(mycss_begin_chars_state_map[ ((const unsigned char *)css)[css_offset] ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) {
551 0           css_offset++;
552            
553 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
554 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
555             }
556 0 0         else if(css[css_offset] == '\\') {
557 0           css_offset++;
558            
559 0           entry->state = MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS_RSOLIDUS;
560             }
561             else {
562 0           token->length = 1; // only '-'
563 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
564            
565 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
566            
567 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
568 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
569             }
570            
571 0           return css_offset;
572             }
573              
574 0           size_t mycss_tokenizer_state_hyphen_minus_minus_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
575             {
576 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
577 0           token->length = 1;
578 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
579            
580 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
581            
582 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
583 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 2);
584             }
585             else {
586 0           css_offset++;
587            
588 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
589 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
590             }
591            
592 0           return css_offset;
593             }
594              
595 0           size_t mycss_tokenizer_state_hyphen_minus_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
596             {
597 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
598 0           token->length = 1; // only '-'
599 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
600            
601 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
602            
603 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
604 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
605             }
606             else {
607 0           css_offset++;
608            
609 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
610 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
611             }
612            
613 0           return css_offset;
614             }
615              
616             /////////////////////////////////////////////////////////
617             //// U+002E FULL STOP (.)
618             ////
619             /////////////////////////////////////////////////////////
620 27           size_t mycss_tokenizer_state_full_stop(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
621             {
622 27 50         if(css[css_offset] >= '0' && css[css_offset] <= '9') {
    50          
623 0           css_offset++;
624            
625 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL;
626 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
627             }
628             else {
629 27           token->length = 1;
630 27           token->type = MyCSS_TOKEN_TYPE_DELIM;
631            
632 27 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
633            
634 27           entry->state = MyCSS_TOKENIZER_STATE_DATA;
635             }
636            
637 27           return css_offset;
638             }
639              
640             /////////////////////////////////////////////////////////
641             //// U+002F SOLIDUS (/)
642             ////
643             /////////////////////////////////////////////////////////
644 0           size_t mycss_tokenizer_state_solidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
645             {
646 0 0         if(css[css_offset] == '*') {
647 0           css_offset++;
648            
649 0           entry->state = MyCSS_TOKENIZER_STATE_SOLIDUS_COMMENT_END;
650             }
651             else {
652 0           token->length = 1;
653 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
654            
655 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
656            
657 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
658             }
659            
660            
661 0           return css_offset;
662             }
663              
664 0           size_t mycss_tokenizer_state_solidus_comment_end(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
665             {
666 0 0         while(css_offset < css_size)
667             {
668 0 0         if(css[css_offset] == '/') {
669 0 0         if(css_offset == 0)
670             {
671 0           mycore_incoming_buffer_t *buffer = entry->current_buffer->prev;
672            
673 0 0         while(buffer && buffer->size == 0)
    0          
674 0           buffer = buffer->prev;
675            
676 0 0         if(buffer == NULL) {
677             // panic!, this in not normal, something is very wrong
678 0           entry->state = MyCSS_TOKENIZER_STATE_SOLIDUS;
679 0           break;
680             }
681            
682 0 0         if(buffer->data[ (buffer->size - 1) ] == '*') {
683 0           css_offset++;
684            
685 0           token->length = (entry->current_buffer->offset + css_offset) - token->begin;
686 0           token->type = MyCSS_TOKEN_TYPE_COMMENT;
687            
688 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
689            
690 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
691 0           break;
692             }
693             }
694 0 0         else if(css[ (css_offset - 1) ] == '*') {
695 0           css_offset++;
696            
697 0           token->length = (entry->current_buffer->offset + css_offset) - token->begin;
698 0           token->type = MyCSS_TOKEN_TYPE_COMMENT;
699            
700 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
701            
702 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
703 0           break;
704             }
705             }
706            
707 0           ++css_offset;
708             }
709            
710 0           return css_offset;
711             }
712              
713             /////////////////////////////////////////////////////////
714             //// U+003A COLON (:)
715             ////
716             /////////////////////////////////////////////////////////
717 7           size_t mycss_tokenizer_state_colon(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
718             {
719 7           token->length = 1;
720 7           token->type = MyCSS_TOKEN_TYPE_COLON;
721            
722 7 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
723            
724 7           entry->state = MyCSS_TOKENIZER_STATE_DATA;
725 7           return css_offset;
726             }
727              
728             /////////////////////////////////////////////////////////
729             //// U+003B SEMICOLON (;)
730             ////
731             /////////////////////////////////////////////////////////
732 0           size_t mycss_tokenizer_state_semicolon(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
733             {
734 0           token->length = 1;
735 0           token->type = MyCSS_TOKEN_TYPE_SEMICOLON;
736            
737 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
738            
739 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
740 0           return css_offset;
741             }
742              
743             /////////////////////////////////////////////////////////
744             //// U+003C LESS-THAN SIGN (<)
745             ////
746             /////////////////////////////////////////////////////////
747 0           size_t mycss_tokenizer_state_less_than_sign(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
748             {
749 0 0         if(css[css_offset] == '!') {
750 0           css_offset++;
751            
752 0           entry->state = MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS;
753             }
754             else {
755 0           token->length = 1;
756 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
757            
758 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
759            
760 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
761             }
762            
763 0           return css_offset;
764             }
765              
766 0           size_t mycss_tokenizer_state_less_than_sign_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
767             {
768 0 0         if(css[css_offset] == '-') {
769 0           css_offset++;
770 0           entry->state = MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS_MINUS;
771             }
772             else {
773 0           token->length = 1;
774 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
775            
776 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
777            
778 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
779 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
780             }
781            
782 0           return css_offset;
783             }
784              
785 0           size_t mycss_tokenizer_state_less_than_sign_minus_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
786             {
787 0 0         if(css[css_offset] == '-') {
788 0           css_offset++;
789            
790 0           token->length = 3;
791 0           token->type = MyCSS_TOKEN_TYPE_CDO;
792            
793 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
794            
795 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
796             }
797             else {
798 0           token->length = 1;
799 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
800            
801 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
802            
803 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
804 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 2);
805             }
806            
807 0           return css_offset;
808             }
809              
810             /////////////////////////////////////////////////////////
811             //// U+0040 COMMERCIAL AT (@)
812             ////
813             /////////////////////////////////////////////////////////
814 0           size_t mycss_tokenizer_state_commercial_at(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
815             {
816 0 0         if(css[css_offset] == '-') {
817 0           css_offset++;
818            
819 0           entry->state = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS;
820             }
821 0 0         else if(css[css_offset] == '\\') {
822 0           css_offset++;
823            
824 0           entry->state = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_RSOLIDUS;
825             }
826 0 0         else if(mycss_begin_chars_state_map[ ((const unsigned char *)css)[css_offset] ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) {
827 0           css_offset++;
828            
829 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
830 0           entry->state_back = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK;
831             }
832             else {
833 0           token->length = 1;
834 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
835            
836 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
837            
838 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
839             }
840            
841 0           return css_offset;
842             }
843              
844 0           size_t mycss_tokenizer_state_commercial_at_minus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
845             {
846 0 0         if(mycss_begin_chars_state_map[ ((const unsigned char *)css)[css_offset] ] == MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT) {
847 0           css_offset++;
848            
849 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
850 0           entry->state_back = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK;
851             }
852 0 0         else if(css[css_offset] == '\\') {
853 0           css_offset++;
854            
855 0           entry->state = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS_RSOLIDUS;
856             }
857             else {
858 0           token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1;
859 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
860            
861 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
862            
863 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
864 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
865             }
866            
867 0           return css_offset;
868             }
869              
870 0           size_t mycss_tokenizer_state_commercial_at_minus_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
871             {
872 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
873 0           token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 2;
874 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
875            
876 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
877            
878 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
879 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 2);
880             }
881             else {
882 0           css_offset++;
883            
884 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
885 0           entry->state_back = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK;
886             }
887            
888 0           return css_offset;
889             }
890              
891 0           size_t mycss_tokenizer_state_commercial_at_rsolidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
892             {
893 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
894 0           token->length = ((entry->current_buffer->offset + css_offset) - token->begin) - 1;
895 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
896            
897 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
898            
899 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
900 0           css_offset = mycss_tokenizer_state_set_current_buffer_for_continue(entry, css_offset, 1);
901             }
902             else {
903 0           css_offset++;
904            
905 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
906 0           entry->state_back = MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK;
907             }
908            
909 0           return css_offset;
910             }
911              
912 0           size_t mycss_tokenizer_state_commercial_at_back(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
913             {
914 0           token->type = MyCSS_TOKEN_TYPE_AT_KEYWORD;
915 0           token->begin += 1;
916 0           token->length -= 1;
917            
918 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
919            
920 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
921 0           return css_offset;
922             }
923              
924             /////////////////////////////////////////////////////////
925             //// U+005B LEFT SQUARE BRACKET ([)
926             ////
927             /////////////////////////////////////////////////////////
928 10           size_t mycss_tokenizer_state_left_square_bracket(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
929             {
930 10           token->length = 1;
931 10           token->type = MyCSS_TOKEN_TYPE_LEFT_SQUARE_BRACKET;
932            
933 10 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
934            
935 10           entry->state = MyCSS_TOKENIZER_STATE_DATA;
936 10           return css_offset;
937             }
938              
939             /////////////////////////////////////////////////////////
940             //// U+005C REVERSE SOLIDUS (\)
941             ////
942             /////////////////////////////////////////////////////////
943 0           size_t mycss_tokenizer_state_reverse_solidus(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
944             {
945 0 0         if(css[css_offset] == '\n' || css[css_offset] == '\r' || css[css_offset] == 0x0C) {
    0          
    0          
946 0           token->length = 1;
947 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
948            
949 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
950            
951 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
952             }
953             else {
954 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
955 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
956             }
957            
958 0           return css_offset;
959             }
960              
961             /////////////////////////////////////////////////////////
962             //// U+005D RIGHT SQUARE BRACKET (])
963             ////
964             /////////////////////////////////////////////////////////
965 1           size_t mycss_tokenizer_state_right_square_bracket(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
966             {
967 1           token->length = 1;
968 1           token->type = MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET;
969            
970 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
971            
972 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
973 1           return css_offset;
974             }
975              
976             /////////////////////////////////////////////////////////
977             //// U+005E CIRCUMFLEX ACCENT (^)
978             ////
979             /////////////////////////////////////////////////////////
980 1           size_t mycss_tokenizer_state_circumflex_accent(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
981             {
982 1 50         if(css[css_offset] == '=') {
983 0           css_offset++;
984            
985 0           token->length = 2;
986 0           token->type = MyCSS_TOKEN_TYPE_PREFIX_MATCH;
987             }
988             else {
989 1           token->length = 1;
990 1           token->type = MyCSS_TOKEN_TYPE_DELIM;
991             }
992            
993 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
994            
995 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
996 1           return css_offset;
997             }
998              
999             /////////////////////////////////////////////////////////
1000             //// U+007B LEFT CURLY BRACKET ({)
1001             ////
1002             /////////////////////////////////////////////////////////
1003 0           size_t mycss_tokenizer_state_left_curly_bracket(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1004             {
1005 0           token->length = 1;
1006 0           token->type = MyCSS_TOKEN_TYPE_LEFT_CURLY_BRACKET;
1007            
1008 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
1009            
1010 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
1011 0           return css_offset;
1012             }
1013              
1014             /////////////////////////////////////////////////////////
1015             //// U+007D RIGHT CURLY BRACKET (})
1016             ////
1017             /////////////////////////////////////////////////////////
1018 0           size_t mycss_tokenizer_state_right_curly_bracket(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1019             {
1020 0           token->length = 1;
1021 0           token->type = MyCSS_TOKEN_TYPE_RIGHT_CURLY_BRACKET;
1022            
1023 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
1024            
1025 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
1026 0           return css_offset;
1027             }
1028              
1029             /////////////////////////////////////////////////////////
1030             //// Digit
1031             ////
1032             /////////////////////////////////////////////////////////
1033 1           size_t mycss_tokenizer_state_digit(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1034             {
1035 1           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DIGIT;
1036 1           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC;
1037            
1038 1           return css_offset;
1039             }
1040              
1041             /////////////////////////////////////////////////////////
1042             //// U+0055 LATIN CAPITAL LETTER U (U) || U+0075 LATIN SMALL LETTER U (u)
1043             ////
1044             /////////////////////////////////////////////////////////
1045 23           size_t mycss_tokenizer_state_letter_u(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1046             {
1047 23 50         if(css[css_offset] == '+') {
1048 0           ++css_offset;
1049            
1050 0 0         if(css_offset >= css_size) {
1051 0           entry->state = MyCSS_TOKENIZER_STATE_LETTER_U_NEXT;
1052 0           return css_offset;
1053             }
1054            
1055 0 0         if(mycore_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
    0          
1056 0           css[css_offset] == '?')
1057             {
1058 0           token->begin += 2;
1059            
1060 0           ++css_offset;
1061 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_BEFORE;
1062             }
1063             else {
1064 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
1065 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
1066             }
1067             }
1068             else {
1069 23           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
1070 23           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
1071             }
1072            
1073 23           return css_offset;
1074             }
1075              
1076 0           size_t mycss_tokenizer_state_letter_u_next(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1077             {
1078 0 0         if(mycore_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
    0          
1079 0           css[css_offset] == '?')
1080             {
1081 0           token->begin += 2;
1082            
1083 0           ++css_offset;
1084 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_BEFORE;
1085             }
1086             else {
1087 0           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
1088 0           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
1089             }
1090            
1091 0           return css_offset;
1092             }
1093              
1094             /////////////////////////////////////////////////////////
1095             //// name-start code point
1096             ////
1097             /////////////////////////////////////////////////////////
1098 83           size_t mycss_tokenizer_state_name_start_code_point(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1099             {
1100 83           entry->state = MyCSS_TOKENIZER_GLOBAL_STATE_NAME;
1101 83           entry->state_back = MyCSS_TOKENIZER_GLOBAL_STATE_IDENT;
1102            
1103 83           return css_offset;
1104             }
1105              
1106             /////////////////////////////////////////////////////////
1107             //// U+007C VERTICAL LINE (|)
1108             ////
1109             /////////////////////////////////////////////////////////
1110 0           size_t mycss_tokenizer_state_vertical_line(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1111             {
1112 0 0         if(css[css_offset] == '=') {
1113 0           css_offset++;
1114            
1115 0           token->length = 2;
1116 0           token->type = MyCSS_TOKEN_TYPE_DASH_MATCH;
1117             }
1118 0 0         else if(css[css_offset] == '|') {
1119 0           css_offset++;
1120            
1121 0           token->length = 2;
1122 0           token->type = MyCSS_TOKEN_TYPE_COLUMN;
1123             }
1124             else {
1125 0           token->length = 1;
1126 0           token->type = MyCSS_TOKEN_TYPE_DELIM;
1127             }
1128            
1129 0 0         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
1130            
1131 0           entry->state = MyCSS_TOKENIZER_STATE_DATA;
1132 0           return css_offset;
1133             }
1134              
1135             /////////////////////////////////////////////////////////
1136             //// U+007E TILDE (~)
1137             ////
1138             /////////////////////////////////////////////////////////
1139 1           size_t mycss_tokenizer_state_tilde(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1140             {
1141 1 50         if(css[css_offset] == '=') {
1142 0           css_offset++;
1143            
1144 0           token->length = 2;
1145 0           token->type = MyCSS_TOKEN_TYPE_INCLUDE_MATCH;
1146             }
1147             else {
1148 1           token->length = 1;
1149 1           token->type = MyCSS_TOKEN_TYPE_DELIM;
1150             }
1151            
1152 1 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
1153            
1154 1           entry->state = MyCSS_TOKENIZER_STATE_DATA;
1155 1           return css_offset;
1156             }
1157              
1158             /////////////////////////////////////////////////////////
1159             //// anything else
1160             ////
1161             /////////////////////////////////////////////////////////
1162 14           size_t mycss_tokenizer_state_delim_single_code_point(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
1163             {
1164 14           const unsigned char *u_css = (const unsigned char*)css;
1165            
1166 14 50         while (css_offset < css_size)
1167             {
1168 14 50         if(u_css[css_offset] < 128)
1169             {
1170 14           token->length = (entry->current_buffer->offset + css_offset) - token->begin;
1171 14           token->type = MyCSS_TOKEN_TYPE_DELIM;
1172            
1173 14 50         MyCSS_TOKEN_READY_CALLBACK_FUNCTION(entry, token);
1174            
1175 14           entry->state = MyCSS_TOKENIZER_STATE_DATA;
1176 14           break;
1177             }
1178            
1179 0           css_offset++;
1180             }
1181            
1182 14           return css_offset;
1183             }
1184              
1185             /////////////////////////////////////////////////////////
1186             //// init tokenizer
1187             ////
1188             /////////////////////////////////////////////////////////
1189 74           mystatus_t mycss_tokenizer_state_init(mycss_t* mycss)
1190             {
1191 74           mycss->parse_state_func = (mycss_tokenizer_state_f*)mycore_calloc((MyCSS_TOKENIZER_STATE_LAST_ENTRY * 2), sizeof(mycss_tokenizer_state_f));
1192            
1193 74 50         if(mycss->parse_state_func == NULL)
1194 0           return MyCSS_STATUS_ERROR_TOKENIZER_STATE_ALLOCATION;
1195            
1196 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_DATA] = mycss_tokenizer_state_data;
1197            
1198 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_WHITESPACE] = mycss_tokenizer_state_whitespace;
1199 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_QUOTATION_MARK] = mycss_tokenizer_state_quotation_mark;
1200 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_QUOTATION_MARK_BACK] = mycss_tokenizer_state_quotation_mark_back;
1201 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_NUMBER_SIGN] = mycss_tokenizer_state_number_sign;
1202 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_BACK] = mycss_tokenizer_state_number_sign_name_back;
1203 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_RSOLIDUS] = mycss_tokenizer_state_number_sign_name_rsolidus;
1204 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_DOLLAR_SIGN] = mycss_tokenizer_state_dollar_sign;
1205 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_APOSTROPHE] = mycss_tokenizer_state_apostrophe;
1206 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_APOSTROPHE_BACK] = mycss_tokenizer_state_apostrophe_back;
1207 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LEFT_PARENTHESIS] = mycss_tokenizer_state_left_parenthesis;
1208 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_RIGHT_PARENTHESIS] = mycss_tokenizer_state_right_parenthesis;
1209 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_ASTERISK] = mycss_tokenizer_state_asterisk;
1210 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_PLUS_SIGN] = mycss_tokenizer_state_plus_sign;
1211 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_PLUS_SIGN_FULL_STOP] = mycss_tokenizer_state_plus_sign_full_stop;
1212 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMA] = mycss_tokenizer_state_comma;
1213 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_HYPHEN_MINUS] = mycss_tokenizer_state_hyphen_minus;
1214 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_FULL_STOP] = mycss_tokenizer_state_hyphen_minus_full_stop;
1215 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS] = mycss_tokenizer_state_hyphen_minus_minus;
1216 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS_RSOLIDUS] = mycss_tokenizer_state_hyphen_minus_minus_rsolidus;
1217 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_RSOLIDUS] = mycss_tokenizer_state_hyphen_minus_rsolidus;
1218 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_FULL_STOP] = mycss_tokenizer_state_full_stop;
1219 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_SOLIDUS] = mycss_tokenizer_state_solidus;
1220 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_SOLIDUS_COMMENT_END] = mycss_tokenizer_state_solidus_comment_end;
1221 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COLON] = mycss_tokenizer_state_colon;
1222 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_SEMICOLON] = mycss_tokenizer_state_semicolon;
1223 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN] = mycss_tokenizer_state_less_than_sign;
1224 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS] = mycss_tokenizer_state_less_than_sign_minus;
1225 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS_MINUS] = mycss_tokenizer_state_less_than_sign_minus_minus;
1226 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMERCIAL_AT] = mycss_tokenizer_state_commercial_at;
1227 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS] = mycss_tokenizer_state_commercial_at_minus;
1228 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS_RSOLIDUS] = mycss_tokenizer_state_commercial_at_minus_rsolidus;
1229 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_RSOLIDUS] = mycss_tokenizer_state_commercial_at_rsolidus;
1230 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK] = mycss_tokenizer_state_commercial_at_back;
1231 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LEFT_SQUARE_BRACKET] = mycss_tokenizer_state_left_square_bracket;
1232 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_REVERSE_SOLIDUS] = mycss_tokenizer_state_reverse_solidus;
1233 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_RIGHT_SQUARE_BRACKET] = mycss_tokenizer_state_right_square_bracket;
1234 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_CIRCUMFLEX_ACCENT] = mycss_tokenizer_state_circumflex_accent;
1235 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LEFT_CURLY_BRACKET] = mycss_tokenizer_state_left_curly_bracket;
1236 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_RIGHT_CURLY_BRACKET] = mycss_tokenizer_state_right_curly_bracket;
1237 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_DIGIT] = mycss_tokenizer_state_digit;
1238 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LETTER_U] = mycss_tokenizer_state_letter_u;
1239 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LETTER_U_NEXT] = mycss_tokenizer_state_letter_u_next;
1240 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT] = mycss_tokenizer_state_name_start_code_point;
1241 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_VERTICAL_LINE] = mycss_tokenizer_state_vertical_line;
1242 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_TILDE] = mycss_tokenizer_state_tilde;
1243 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_DELIM_SINGLE_CODE_POINT] = mycss_tokenizer_state_delim_single_code_point;
1244            
1245             // global
1246 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_BACK] = mycss_tokenizer_global_back;
1247 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC] = mycss_tokenizer_global_state_numeric;
1248 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS] = mycss_tokenizer_global_state_numeric_minus;
1249 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS_RSOLIDUS] = mycss_tokenizer_global_state_numeric_minus_rsolidus;
1250 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_RSOLIDUS] = mycss_tokenizer_global_state_numeric_rsolidus;
1251 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DIGIT] = mycss_tokenizer_global_state_number_digit;
1252 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DOT] = mycss_tokenizer_global_state_number_dot;
1253 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL] = mycss_tokenizer_global_state_number_decimal;
1254 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E] = mycss_tokenizer_global_state_number_e;
1255 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_PLUS_MINUS] = mycss_tokenizer_global_state_number_e_plus_minus;
1256 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_DECIMAL] = mycss_tokenizer_global_state_number_e_decimal;
1257 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_IDENT] = mycss_tokenizer_global_state_ident;
1258 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_URL] = mycss_tokenizer_global_state_url;
1259 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_URL_STRING_BACK] = mycss_tokenizer_global_state_url_string_back;
1260 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER] = mycss_tokenizer_global_state_url_after;
1261 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER_WHITESPACE] = mycss_tokenizer_global_state_url_after_whitespace;
1262 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_URL_RSOLIDUS] = mycss_tokenizer_global_state_url_rsolidus;
1263 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL] = mycss_tokenizer_global_state_bad_url;
1264 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NAME] = mycss_tokenizer_global_state_name;
1265 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_NAME_RSOLIDUS] = mycss_tokenizer_global_state_name_rsolidus;
1266 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED] = mycss_tokenizer_global_state_string_double_quoted;
1267 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS] = mycss_tokenizer_global_state_string_double_quoted_rsolidus;
1268 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS_R] = mycss_tokenizer_global_state_string_double_quoted_rsolidus_r;
1269 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED] = mycss_tokenizer_global_state_string_single_quoted;
1270 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS] = mycss_tokenizer_global_state_string_single_quoted_rsolidus;
1271 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS_R] = mycss_tokenizer_global_state_string_single_quoted_rsolidus_r;
1272 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_BEFORE] = mycss_tokenizer_global_state_unicode_range_before;
1273 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE] = mycss_tokenizer_global_state_unicode_range;
1274 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_QUESTION] = mycss_tokenizer_global_state_unicode_range_question;
1275 74           mycss->parse_state_func[MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_MINUS] = mycss_tokenizer_global_state_unicode_range_minus;
1276            
1277             // end
1278 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_WHITESPACE] = mycss_tokenizer_end_state_whitespace;
1279 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_QUOTATION_MARK] = mycss_tokenizer_end_state_quotation_mark;
1280 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_QUOTATION_MARK_BACK] = mycss_tokenizer_end_state_quotation_mark_back;
1281 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_NUMBER_SIGN] = mycss_tokenizer_end_state_number_sign;
1282 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_BACK] = mycss_tokenizer_end_state_number_sign_name_back;
1283 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_NUMBER_SIGN_NAME_RSOLIDUS] = mycss_tokenizer_end_state_number_sign_name_rsolidus;
1284 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_DOLLAR_SIGN] = mycss_tokenizer_end_state_dollar_sign;
1285 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_APOSTROPHE] = mycss_tokenizer_end_state_apostrophe;
1286 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_APOSTROPHE_BACK] = mycss_tokenizer_end_state_apostrophe_back;
1287 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LEFT_PARENTHESIS] = mycss_tokenizer_end_state_left_parenthesis;
1288 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_RIGHT_PARENTHESIS] = mycss_tokenizer_end_state_right_parenthesis;
1289 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_ASTERISK] = mycss_tokenizer_end_state_asterisk;
1290 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_PLUS_SIGN] = mycss_tokenizer_end_state_plus_sign;
1291 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_PLUS_SIGN_FULL_STOP] = mycss_tokenizer_end_state_plus_sign_full_stop;
1292 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMA] = mycss_tokenizer_end_state_comma;
1293 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_HYPHEN_MINUS] = mycss_tokenizer_end_state_hyphen_minus;
1294 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_FULL_STOP] = mycss_tokenizer_end_state_hyphen_minus_full_stop;
1295 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS] = mycss_tokenizer_end_state_hyphen_minus_minus;
1296 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_MINUS_RSOLIDUS] = mycss_tokenizer_end_state_hyphen_minus_minus_rsolidus;
1297 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_HYPHEN_MINUS_RSOLIDUS] = mycss_tokenizer_end_state_hyphen_minus_rsolidus;
1298 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_FULL_STOP] = mycss_tokenizer_end_state_full_stop;
1299 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_SOLIDUS] = mycss_tokenizer_end_state_solidus;
1300 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_SOLIDUS_COMMENT_END] = mycss_tokenizer_end_state_solidus_comment_end;
1301 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COLON] = mycss_tokenizer_end_state_colon;
1302 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_SEMICOLON] = mycss_tokenizer_end_state_semicolon;
1303 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN] = mycss_tokenizer_end_state_less_than_sign;
1304 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS] = mycss_tokenizer_end_state_less_than_sign_minus;
1305 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LESS_THAN_SIGN_MINUS_MINUS] = mycss_tokenizer_end_state_less_than_sign_minus_minus;
1306 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMERCIAL_AT] = mycss_tokenizer_end_state_commercial_at;
1307 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS] = mycss_tokenizer_end_state_commercial_at_minus;
1308 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_MINUS_RSOLIDUS] = mycss_tokenizer_end_state_commercial_at_minus_rsolidus;
1309 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_RSOLIDUS] = mycss_tokenizer_end_state_commercial_at_rsolidus;
1310 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_COMMERCIAL_AT_BACK] = mycss_tokenizer_end_state_commercial_at_back;
1311 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LEFT_SQUARE_BRACKET] = mycss_tokenizer_end_state_left_square_bracket;
1312 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_REVERSE_SOLIDUS] = mycss_tokenizer_end_state_reverse_solidus;
1313 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_RIGHT_SQUARE_BRACKET] = mycss_tokenizer_end_state_right_square_bracket;
1314 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_CIRCUMFLEX_ACCENT] = mycss_tokenizer_end_state_circumflex_accent;
1315 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LEFT_CURLY_BRACKET] = mycss_tokenizer_end_state_left_curly_bracket;
1316 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_RIGHT_CURLY_BRACKET] = mycss_tokenizer_end_state_right_curly_bracket;
1317 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_DIGIT] = mycss_tokenizer_end_state_digit;
1318 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LETTER_U] = mycss_tokenizer_end_state_letter_u;
1319 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_LETTER_U_NEXT] = mycss_tokenizer_end_state_letter_u_next;
1320 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_NAME_START_CODE_POINT] = mycss_tokenizer_end_state_name_start_code_point;
1321 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_VERTICAL_LINE] = mycss_tokenizer_end_state_vertical_line;
1322 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_TILDE] = mycss_tokenizer_end_state_tilde;
1323 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_STATE_DELIM_SINGLE_CODE_POINT] = mycss_tokenizer_end_state_delim_single_code_point;
1324            
1325             // global end
1326 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_BACK] = mycss_tokenizer_end_global_back;
1327 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC] = mycss_tokenizer_end_global_state_numeric;
1328 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS] = mycss_tokenizer_end_global_state_numeric_minus;
1329 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_MINUS_RSOLIDUS] = mycss_tokenizer_end_global_state_numeric_minus_rsolidus;
1330 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMERIC_RSOLIDUS] = mycss_tokenizer_end_global_state_numeric_rsolidus;
1331 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DIGIT] = mycss_tokenizer_end_global_state_number_digit;
1332 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DOT] = mycss_tokenizer_end_global_state_number_dot;
1333 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_DECIMAL] = mycss_tokenizer_end_global_state_number_decimal;
1334 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E] = mycss_tokenizer_end_global_state_number_e;
1335 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_PLUS_MINUS] = mycss_tokenizer_end_global_state_number_e_plus_minus;
1336 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NUMBER_E_DECIMAL] = mycss_tokenizer_end_global_state_number_e_decimal;
1337 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_IDENT] = mycss_tokenizer_end_global_state_ident;
1338 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_URL] = mycss_tokenizer_end_global_state_url;
1339 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_URL_STRING_BACK] = mycss_tokenizer_end_global_state_url_string_back;
1340 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER] = mycss_tokenizer_end_global_state_url_after;
1341 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_URL_AFTER_WHITESPACE] = mycss_tokenizer_end_global_state_url_after_whitespace;
1342 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_URL_RSOLIDUS] = mycss_tokenizer_end_global_state_url_rsolidus;
1343 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_BAD_URL] = mycss_tokenizer_end_global_state_bad_url;
1344 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NAME] = mycss_tokenizer_end_global_state_name;
1345 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_NAME_RSOLIDUS] = mycss_tokenizer_end_global_state_name_rsolidus;
1346 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED] = mycss_tokenizer_end_global_state_string_double_quoted;
1347 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS] = mycss_tokenizer_end_global_state_string_double_quoted_rsolidus;
1348 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_DOUBLE_QUOTED_RSOLIDUS_R] = mycss_tokenizer_end_global_state_string_double_quoted_rsolidus;
1349 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED] = mycss_tokenizer_end_global_state_string_single_quoted;
1350 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS] = mycss_tokenizer_end_global_state_string_single_quoted_rsolidus;
1351 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_STRING_SINGLE_QUOTED_RSOLIDUS_R] = mycss_tokenizer_end_global_state_string_single_quoted_rsolidus;
1352 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_BEFORE] = mycss_tokenizer_end_global_state_unicode_range_before;
1353 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE] = mycss_tokenizer_end_global_state_unicode_range;
1354 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_QUESTION] = mycss_tokenizer_end_global_state_unicode_range_question;
1355 74           mycss->parse_state_func[MyCSS_TOKENIZER_STATE_LAST_ENTRY + MyCSS_TOKENIZER_GLOBAL_STATE_UNICODE_RANGE_MINUS] = mycss_tokenizer_end_global_state_unicode_range_minus;
1356              
1357            
1358 74           return MyCSS_STATUS_OK;
1359             }
1360              
1361 74           void mycss_tokenizer_state_destroy(mycss_t* mycss)
1362             {
1363 74 50         if(mycss->parse_state_func) {
1364 74           mycore_free(mycss->parse_state_func);
1365 74           mycss->parse_state_func = NULL;
1366             }
1367 74           }
1368              
1369