File Coverage

third_party/modest/source/mycss/selectors/function_parser.c
Criterion Covered Total %
statement 12 369 3.2
branch 4 218 1.8
condition n/a
subroutine n/a
pod n/a
total 16 587 2.7


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/selectors/function_parser.h"
22              
23             /* */
24 0           bool mycss_selectors_function_parser_state_drop_component_value(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
25             {
26 0 0         if(token->type == entry->parser_ending_token) {
27 0 0         if(mycss_entry_parser_list_current_is_local(entry) == false) {
28 0           mycss_entry_parser_list_pop(entry);
29 0           return false;
30             }
31             }
32            
33 0           switch (token->type) {
34             case MyCSS_TOKEN_TYPE_WHITESPACE:
35 0           break;
36            
37             case MyCSS_TOKEN_TYPE_FUNCTION: {
38 0           mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_state_drop_component_value, NULL, entry->parser_ending_token, true);
39 0           entry->parser_ending_token = MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS;
40            
41 0           break;
42             }
43             case MyCSS_TOKEN_TYPE_LEFT_CURLY_BRACKET: {
44 0           mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_state_drop_component_value, NULL, entry->parser_ending_token, true);
45 0           entry->parser_ending_token = MyCSS_TOKEN_TYPE_RIGHT_CURLY_BRACKET;
46            
47 0           break;
48             }
49             case MyCSS_TOKEN_TYPE_LEFT_SQUARE_BRACKET: {
50 0           mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_state_drop_component_value, NULL, entry->parser_ending_token, true);
51 0           entry->parser_ending_token = MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET;
52            
53 0           break;
54             }
55             case MyCSS_TOKEN_TYPE_LEFT_PARENTHESIS: {
56 0           mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_state_drop_component_value, NULL, entry->parser_ending_token, true);
57 0           entry->parser_ending_token = MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS;
58            
59 0           break;
60             }
61             default: {
62 0 0         if(mycss_entry_parser_list_current_is_local(entry) &&
    0          
63 0           token->type == entry->parser_ending_token)
64             {
65 0           mycss_entry_parser_list_pop(entry);
66             }
67            
68 0           break;
69             }
70             }
71            
72 0           return true;
73             }
74              
75 0           bool mycss_selectors_unknown_parser(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
76             {
77 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
78 0           return false;
79             }
80              
81 0           mycss_selectors_list_t * mycss_selectors_parser_check_selector_list(mycss_selectors_t* selectors, mycss_selectors_list_t *list)
82             {
83 0 0         if(list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD)
84 0           mycss_selectors_list_destroy_last_empty_selector(selectors, list, true);
85            
86 0 0         if(list->entries_list_length == 0 || list->entries_list[0].entry == NULL) {
    0          
87 0           return mycss_selectors_list_destroy(selectors, list, true);
88             }
89            
90 0           return list;
91             }
92              
93             ///////////////////////////////////////////////////////////
94             ////// NOT AND MATCHES AND CURRENT
95             //////
96             ///////////////////////////////////////////////////////////
97 0           void mycss_selectors_function_parser_not_or_matches_or_current_find_bad_selector(mycss_selectors_list_t* selectors_list)
98             {
99 0 0         for(size_t i = 0; i < selectors_list->entries_list_length; i++) {
100 0           mycss_selectors_entry_t* selector = selectors_list->entries_list[i].entry;
101            
102 0 0         while(selector) {
103 0 0         if(selector->sub_type == MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_MATCHES ||
    0          
104 0 0         selector->sub_type == MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_NOT ||
105 0 0         selector->sub_type == MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_CURRENT ||
106 0           selector->type == MyCSS_SELECTORS_TYPE_PSEUDO_ELEMENT)
107             {
108 0 0         if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
109 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
110            
111 0           return;
112             }
113            
114 0           selector = selector->next;
115             }
116             }
117             }
118              
119 0           bool mycss_selectors_function_parser_not_or_matches_or_current_parser(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
120             {
121 0           mycss_selectors_t *selectors = entry->selectors;
122 0           mycss_selectors_list_t *selectors_list = selectors->list_last;
123 0           mycss_selectors_list_t *parent_list = selectors->list_last->parent;
124            
125 0           selectors->entry_last = mycss_selectors_list_last_entry(parent_list);
126 0           selectors->list_last = parent_list;
127 0           selectors->specificity = &parent_list->entries_list[ (parent_list->entries_list_length - 1) ].specificity;
128            
129 0 0         if(selectors->specificity && selectors->entry_last && (
    0          
    0          
130 0 0         selectors->entry_last->sub_type == MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_MATCHES ||
131 0           selectors->entry_last->sub_type == MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_NOT))
132             {
133 0           selectors->specificity->b--;
134             }
135            
136 0           mycss_selectors_function_parser_not_or_matches_or_current_find_bad_selector(selectors_list);
137 0           selectors_list = mycss_selectors_parser_check_selector_list(selectors, selectors_list);
138            
139 0 0         if(selectors_list == NULL) {
140 0 0         if(selectors->entry_last) {
141 0           selectors->entry_last->value = NULL;
142 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
143             }
144             }
145 0 0         else if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) && selectors->entry_last) {
    0          
146 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
147             }
148            
149 0 0         if(token->type == entry->parser_ending_token) {
150 0           mycss_entry_parser_list_pop(entry);
151 0           return false;
152             }
153            
154 0 0         if(selectors_list)
155 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
156            
157 0 0         if(selectors->entry_last)
158 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
159            
160 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
161            
162 0           return false;
163             }
164              
165             ///////////////////////////////////////////////////////////
166             ////// HAS
167             //////
168             ///////////////////////////////////////////////////////////
169 0           void mycss_selectors_function_parser_has_find_bad_selector(mycss_selectors_list_t* selectors_list)
170             {
171 0 0         for(size_t i = 0; i < selectors_list->entries_list_length; i++) {
172 0           mycss_selectors_entry_t* selector = selectors_list->entries_list[i].entry;
173              
174 0 0         while(selector) {
175 0 0         if(selector->type == MyCSS_SELECTORS_TYPE_PSEUDO_ELEMENT) {
176 0 0         if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
177 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
178              
179 0           return;
180             }
181              
182 0           selector = selector->next;
183             }
184             }
185             }
186              
187 0           bool mycss_selectors_function_parser_has(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
188             {
189 0           mycss_selectors_t *selectors = entry->selectors;
190 0           mycss_selectors_list_t *selectors_list = selectors->list_last;
191 0           mycss_selectors_list_t *parent_list = selectors->list_last->parent;
192            
193 0           selectors->entry_last = mycss_selectors_list_last_entry(parent_list);
194 0           selectors->list_last = parent_list;
195 0           selectors->specificity = &parent_list->entries_list[ (parent_list->entries_list_length - 1) ].specificity;
196            
197 0           mycss_selectors_function_parser_has_find_bad_selector(selectors_list);
198 0           selectors_list = mycss_selectors_parser_check_selector_list(selectors, selectors_list);
199            
200 0 0         if(selectors_list == NULL) {
201 0 0         if(selectors->entry_last) {
202 0           selectors->entry_last->value = NULL;
203 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
204             }
205             }
206 0 0         else if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) && selectors->entry_last) {
    0          
207 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
208             }
209            
210 0 0         if(token->type == entry->parser_ending_token) {
211 0           mycss_entry_parser_list_pop(entry);
212 0           return false;
213             }
214            
215 0 0         if(selectors_list)
216 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
217            
218 0 0         if(selectors->entry_last)
219 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
220            
221 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
222            
223 0           return false;
224             }
225              
226             ///////////////////////////////////////////////////////////
227             ////// CONTAINS
228             //////
229             ///////////////////////////////////////////////////////////
230 0           void mycss_selectors_function_parser_contains_find_bad_selector(mycss_selectors_list_t* selectors_list)
231             {
232 0 0         for(size_t i = 0; i < selectors_list->entries_list_length; i++) {
233 0           mycss_selectors_entry_t* selector = selectors_list->entries_list[i].entry;
234              
235 0 0         while(selector) {
236 0 0         if(selector->type == MyCSS_SELECTORS_TYPE_PSEUDO_ELEMENT) {
237 0 0         if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
238 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
239              
240 0           return;
241             }
242              
243 0           selector = selector->next;
244             }
245             }
246             }
247              
248 0           bool mycss_selectors_function_parser_contains(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
249             {
250 0           mycss_selectors_t *selectors = entry->selectors;
251 0           mycss_selectors_list_t *selectors_list = selectors->list_last;
252 0           mycss_selectors_list_t *parent_list = selectors->list_last->parent;
253            
254 0           selectors->entry_last = mycss_selectors_list_last_entry(parent_list);
255 0           selectors->list_last = parent_list;
256 0           selectors->specificity = &parent_list->entries_list[ (parent_list->entries_list_length - 1) ].specificity;
257            
258 0           mycss_selectors_function_parser_contains_find_bad_selector(selectors_list);
259 0           selectors_list = mycss_selectors_parser_check_selector_list(selectors, selectors_list);
260            
261 0 0         if(selectors_list == NULL) {
262 0 0         if(selectors->entry_last) {
263 0           selectors->entry_last->value = NULL;
264 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
265             }
266             }
267 0 0         else if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) && selectors->entry_last) {
    0          
268 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
269             }
270            
271 0 0         if(token->type == entry->parser_ending_token) {
272 0           mycss_entry_parser_list_pop(entry);
273 0           return false;
274             }
275            
276 0 0         if(selectors_list)
277 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
278            
279 0 0         if(selectors->entry_last)
280 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
281            
282 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
283            
284 0           return false;
285             }
286              
287             ///////////////////////////////////////////////////////////
288             ////// NTH OF SELECTORS
289             //////
290             ///////////////////////////////////////////////////////////
291 1           bool mycss_selectors_function_parser_nth_with_selectors(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
292             {
293 1           mycss_selectors_t *selectors = entry->selectors;
294 1           mycss_selectors_entry_t *selector = selectors->entry_last;
295            
296 1 50         if(mycss_selector_value_an_plus_b(selector->value)->is_broken)
297             {
298 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
299 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
300            
301 0           selector->value = mycss_selectors_value_pseudo_class_function_nth_child_destroy(entry, selector->value, true);
302            
303 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
304 0           return false;
305             }
306            
307 1           entry->parser = mycss_selectors_function_parser_nth_with_selectors_need_of;
308            
309 1           return false;
310             }
311              
312 1           bool mycss_selectors_function_parser_nth_with_selectors_need_of(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
313             {
314 1 50         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
315 0           return true;
316             }
317 1 50         else if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
318 0           mycss_selectors_t *selectors = entry->selectors;
319 0           mycss_selectors_entry_t *selector = selectors->entry_last;
320            
321             mycore_string_t str;
322 0           mycss_token_data_to_string(entry, token, &str, true, false);
323            
324 0           mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
325            
326 0 0         if(mycore_strcasecmp(str.data, "of") != 0) {
327 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
328 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
329            
330 0           anb->of = NULL;
331            
332 0           mycore_string_destroy(&str, false);
333            
334 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
335 0           return true;
336             }
337            
338 0           mycore_string_destroy(&str, false);
339            
340             /* create and switch entry, and create selector */
341 0           mycss_selectors_list_t *current_list = selectors->list_last;
342            
343 0           selectors->list = &anb->of;
344 0           selectors->list_last = NULL;
345 0           selectors->ending_token = entry->parser_ending_token;
346            
347 0           mycss_selectors_state_compound_selector_list(entry, token, true);
348            
349 0           anb->of->parent = current_list;
350            
351 0           mycss_entry_parser_list_push(entry, mycss_selectors_function_parser_nth_with_selectors_need_of_after, entry->parser_switch, entry->parser_ending_token, false);
352             }
353 1 50         else if(token->type == entry->parser_ending_token) {
354 1           mycss_entry_parser_list_pop(entry);
355 1           return false;
356             }
357             else {
358             /* parse error */
359 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
360            
361 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
362 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
363            
364 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
365 0           return false;
366             }
367            
368 0           return true;
369             }
370              
371 0           bool mycss_selectors_function_parser_nth_with_selectors_need_of_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
372             {
373 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
374 0           return true;
375             }
376            
377 0           mycss_selectors_t *selectors = entry->selectors;
378 0           mycss_selectors_list_t *parent_list = selectors->list_last->parent;
379 0           mycss_selectors_list_t *selectors_list = mycss_selectors_parser_check_selector_list(selectors, selectors->list_last);
380            
381 0           selectors->list_last = parent_list;
382 0           selectors->entry_last = mycss_selectors_list_last_entry(parent_list);
383 0           selectors->specificity = &parent_list->entries_list[ (parent_list->entries_list_length - 1) ].specificity;
384            
385 0 0         if(selectors_list == NULL) {
386 0 0         if(selectors->entry_last) {
387 0           mycss_selector_value_an_plus_b(selectors->entry_last->value)->of = NULL;
388 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
389             }
390             }
391 0 0         else if((selectors_list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) && selectors->entry_last) {
    0          
392 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
393             }
394            
395 0 0         if(token->type == entry->parser_ending_token) {
396 0           mycss_entry_parser_list_pop(entry);
397 0           return false;
398             }
399            
400 0 0         if(selectors_list)
401 0           selectors_list->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
402            
403 0 0         if(selectors->entry_last)
404 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
405            
406 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
407            
408 0           return false;
409             }
410              
411             ///////////////////////////////////////////////////////////
412             ////// NTH
413             //////
414             ///////////////////////////////////////////////////////////
415 0           bool mycss_selectors_function_parser_nth_without_selectors(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
416             {
417 0           mycss_selectors_t *selectors = entry->selectors;
418 0           mycss_selectors_entry_t *selector = selectors->entry_last;
419            
420 0 0         if(mycss_selector_value_an_plus_b(selector->value)->is_broken)
421             {
422 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
423 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
424            
425 0           selector->value = mycss_selectors_value_pseudo_class_function_nth_child_destroy(entry, selector->value, true);
426            
427 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
428 0           return false;
429             }
430            
431 0           entry->parser = mycss_selectors_function_parser_nth_without_selectors_after;
432            
433 0           return false;
434             }
435              
436 0           bool mycss_selectors_function_parser_nth_without_selectors_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
437             {
438 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
439 0           return true;
440             }
441            
442 0           mycss_selectors_t *selectors = entry->selectors;
443            
444 0 0         if(token->type == entry->parser_ending_token) {
445 0           mycss_entry_parser_list_pop(entry);
446 0           return false;
447             }
448            
449 0 0         if((selectors->entry_last->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
450 0           selectors->entry_last->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
451            
452 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
453            
454 0           return false;
455             }
456              
457             ///////////////////////////////////////////////////////////
458             ////// DROP
459             //////
460             ///////////////////////////////////////////////////////////
461 0           bool mycss_selectors_function_parser_drop(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
462             {
463 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
464 0           return true;
465             }
466 0 0         else if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
467 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
468            
469 0           mycss_selectors_function_drop_type_t drop_val = mycss_selector_value_drop(selector->value);
470            
471             mycore_string_t str;
472 0           mycss_token_data_to_string(entry, token, &str, true, false);
473              
474 0 0         if(mycore_strcasecmp(str.data ,"active") == 0) {
475 0           drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_ACTIVE;
476             }
477 0 0         else if(mycore_strcasecmp(str.data ,"valid") == 0) {
478 0           drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_VALID;
479             }
480 0 0         else if(mycore_strcasecmp(str.data ,"invalid") == 0) {
481 0           drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_INVALID;
482             }
483             else {
484 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
485 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
486             }
487            
488 0           selector->value = (void*)drop_val;
489            
490 0           mycore_string_destroy(&str, false);
491            
492 0           entry->parser = mycss_selectors_function_parser_drop_after;
493             }
494 0 0         else if(token->type == entry->parser_ending_token) {
495             /* it may be empty? */
496             // mycss_selectors_t *selectors = entry->selectors;
497             // mycss_selectors_entry_t *selector = selectors->entry_last;
498             //
499             // mycss_selectors_function_drop_type_t drop_val = mycss_selector_value_drop(selector->value);
500             //
501             // if(drop_val == MyCSS_SELECTORS_FUNCTION_DROP_TYPE_UNDEF &&
502             // (selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
503             // {
504             // selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
505             // }
506            
507 0           mycss_entry_parser_list_pop(entry);
508 0           return false;
509             }
510             else {
511             /* parse error */
512 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
513            
514 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
515 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
516            
517 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
518 0           return false;
519             }
520              
521 0           return true;
522             }
523              
524 0           bool mycss_selectors_function_parser_drop_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
525             {
526 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
527 0           return true;
528             }
529 0 0         else if(token->type == MyCSS_TOKEN_TYPE_COLUMN) {
530 0           entry->parser = mycss_selectors_function_parser_drop_after_column;
531             }
532 0 0         else if(token->type == entry->parser_ending_token) {
533 0           entry->parser = mycss_selectors_function_parser_drop;
534 0           return false;
535             }
536             else {
537             /* parse error */
538 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
539              
540 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
541 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
542              
543 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
544 0           return false;
545             }
546              
547 0           return true;
548             }
549              
550 0           bool mycss_selectors_function_parser_drop_after_column(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
551             {
552 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
553 0           return true;
554             }
555 0 0         else if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
556 0           entry->parser = mycss_selectors_function_parser_drop;
557             }
558 0 0         else if(token->type == entry->parser_ending_token) {
559 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
560            
561 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
562 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
563            
564 0           entry->parser = mycss_selectors_function_parser_drop;
565             }
566             else {
567             /* parse error */
568 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
569            
570 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
571 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
572            
573 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
574             }
575            
576 0           return false;
577             }
578              
579             ///////////////////////////////////////////////////////////
580             ////// DIR
581             //////
582             ///////////////////////////////////////////////////////////
583 0           bool mycss_selectors_function_parser_dir(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
584             {
585 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
586 0           return true;
587             }
588 0 0         else if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
589 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
590            
591 0           selector->value = mycss_selectors_value_pseudo_class_function_dir_create(entry, true);
592 0           mycss_token_data_to_string(entry, token, selector->value, true, false);
593            
594 0           entry->parser = mycss_selectors_function_parser_dir_after;
595             }
596 0 0         else if(token->type == entry->parser_ending_token) {
597 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
598            
599 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
600 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
601            
602 0           entry->parser = mycss_selectors_function_parser_drop;
603 0           return false;
604             }
605             else {
606             /* parse error */
607 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
608            
609 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
610 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
611            
612 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
613 0           return false;
614             }
615            
616 0           return true;
617             }
618              
619 0           bool mycss_selectors_function_parser_dir_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
620             {
621 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
622 0           return true;
623             }
624 0 0         else if(token->type == entry->parser_ending_token) {
625 0           mycss_entry_parser_list_pop(entry);
626             }
627             else {
628 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
629            
630 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
631 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
632            
633 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
634             }
635            
636 0           return false;
637             }
638              
639             ///////////////////////////////////////////////////////////
640             ////// LANG
641             //////
642             ///////////////////////////////////////////////////////////
643 0           bool mycss_selectors_function_parser_lang(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
644             {
645 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
646 0           return true;
647             }
648 0 0         else if(token->type == MyCSS_TOKEN_TYPE_IDENT ||
    0          
649 0           token->type == MyCSS_TOKEN_TYPE_STRING)
650 0           {
651 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
652             mycss_selectors_value_lang_t *lang;
653            
654 0 0         if(selector->value) {
655 0           lang = mycss_selector_value_lang(selector->value);
656            
657 0 0         while(lang->next)
658 0           lang = lang->next;
659            
660 0           lang->next = mycss_selectors_value_pseudo_class_function_lang_create(entry, true);
661 0           mycss_token_data_to_string(entry, token, &lang->next->str, true, false);
662             }
663             else {
664 0           lang = mycss_selectors_value_pseudo_class_function_lang_create(entry, true);
665 0           mycss_token_data_to_string(entry, token, &lang->str, true, false);
666            
667 0           selector->value = lang;
668             }
669            
670 0           entry->parser = mycss_selectors_function_parser_lang_after;
671             }
672 0 0         else if(token->type == entry->parser_ending_token) {
673 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
674            
675 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
676 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
677            
678 0           mycss_entry_parser_list_pop(entry);
679 0           return false;
680             }
681             else {
682             /* parse error */
683 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
684            
685 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
686 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
687            
688 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
689 0           return false;
690             }
691            
692 0           return true;
693             }
694              
695 0           bool mycss_selectors_function_parser_lang_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
696             {
697 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
698 0           return true;
699             }
700 0 0         else if(token->type == MyCSS_TOKEN_TYPE_COMMA) {
701 0           entry->parser = mycss_selectors_function_parser_lang_comma;
702             }
703 0 0         else if(token->type == entry->parser_ending_token) {
704 0           mycss_entry_parser_list_pop(entry);
705 0           return false;
706             }
707             else {
708             /* parse error */
709 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
710            
711 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
712 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
713            
714 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
715 0           return false;
716             }
717            
718 0           return true;
719             }
720              
721 0           bool mycss_selectors_function_parser_lang_comma(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
722             {
723 0 0         if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) {
724 0           return true;
725             }
726 0 0         else if(token->type == MyCSS_TOKEN_TYPE_IDENT ||
    0          
727 0           token->type == MyCSS_TOKEN_TYPE_STRING)
728             {
729 0           entry->parser = mycss_selectors_function_parser_lang;
730 0           return false;
731             }
732             else {
733             /* parse error */
734 0           mycss_selectors_entry_t *selector = entry->selectors->entry_last;
735            
736 0 0         if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
737 0           selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
738            
739 0           entry->parser = mycss_selectors_function_parser_state_drop_component_value;
740 0           return false;
741             }
742             }
743              
744              
745