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/namespace/state.h" |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_AT_KEYWORD) { |
26
|
|
|
|
|
|
|
mycore_string_t str; |
27
|
0
|
|
|
|
|
|
mycss_token_data_to_string(entry, token, &str, true, true); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if(mycore_strcmp(str.data, "namespace") == 0) { |
30
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
34
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
mycore_string_destroy(&str, false); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
41
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return true; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
|
|
|
switch (token->type) { |
50
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_WHITESPACE: |
51
|
0
|
|
|
|
|
|
break; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_IDENT: { |
54
|
0
|
|
|
|
|
|
mycss_namespace_parser_begin(entry); |
55
|
0
|
|
|
|
|
|
mycss_namespace_parser_name(entry, token); |
56
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace_ident; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
break; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_STRING: { |
61
|
0
|
|
|
|
|
|
mycss_namespace_parser_begin(entry); |
62
|
0
|
|
|
|
|
|
mycss_namespace_parser_url(entry, token); |
63
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace_string; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
break; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
case MyCSS_TOKEN_TYPE_URL: { |
68
|
0
|
|
|
|
|
|
mycss_namespace_parser_begin(entry); |
69
|
0
|
|
|
|
|
|
mycss_namespace_parser_url(entry, token); |
70
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace_url; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
break; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
default: { |
75
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
76
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
77
|
0
|
|
|
|
|
|
return false; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return true; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace_ident(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
87
|
0
|
|
|
|
|
|
return true; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_STRING) { |
90
|
0
|
|
|
|
|
|
mycss_namespace_parser_url(entry, token); |
91
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace_ident_string; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
|
else if(token->type == MyCSS_TOKEN_TYPE_URL) { |
94
|
0
|
|
|
|
|
|
mycss_namespace_parser_url(entry, token); |
95
|
0
|
|
|
|
|
|
entry->parser = mycss_namespace_state_namespace_namespace_ident_url; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
99
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
100
|
0
|
|
|
|
|
|
return false; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return true; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace_ident_string(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
109
|
0
|
|
|
|
|
|
return true; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) { |
112
|
0
|
|
|
|
|
|
mycss_namespace_parser_end(entry, token); |
113
|
|
|
|
|
|
|
MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_ident_string_semicolon"); |
114
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
118
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
119
|
0
|
|
|
|
|
|
return false; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return true; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace_ident_url(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
128
|
0
|
|
|
|
|
|
return true; |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) { |
131
|
0
|
|
|
|
|
|
mycss_namespace_parser_end(entry, token); |
132
|
|
|
|
|
|
|
MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_ident_url_semicolon"); |
133
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
137
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
138
|
0
|
|
|
|
|
|
return false; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return true; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace_string(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
145
|
|
|
|
|
|
|
{ |
146
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
147
|
0
|
|
|
|
|
|
return true; |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) { |
150
|
0
|
|
|
|
|
|
mycss_namespace_parser_end(entry, token); |
151
|
|
|
|
|
|
|
MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_string_semicolon"); |
152
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
else { |
155
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
156
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
157
|
0
|
|
|
|
|
|
return false; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return true; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
bool mycss_namespace_state_namespace_namespace_url(mycss_entry_t* entry, mycss_token_t* token, bool last_response) |
164
|
|
|
|
|
|
|
{ |
165
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE) |
166
|
0
|
|
|
|
|
|
return true; |
167
|
|
|
|
|
|
|
|
168
|
0
|
0
|
|
|
|
|
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) { |
169
|
0
|
|
|
|
|
|
mycss_namespace_parser_end(entry, token); |
170
|
|
|
|
|
|
|
MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_url_semicolon"); |
171
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
else { |
174
|
0
|
|
|
|
|
|
mycss_namespace_parser_expectations_error(entry, token); |
175
|
0
|
|
|
|
|
|
entry->parser = mycss_parser_token_drop_at_rule; |
176
|
0
|
|
|
|
|
|
return false; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
return true; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|