1 | // This file was generated by qlalr - DO NOT EDIT!
|
---|
2 | /****************************************************************************
|
---|
3 | **
|
---|
4 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
5 | ** All rights reserved.
|
---|
6 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
7 | **
|
---|
8 | ** This file is part of the Qt Linguist of the Qt Toolkit.
|
---|
9 | **
|
---|
10 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
11 | ** Commercial Usage
|
---|
12 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
13 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
14 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
15 | ** a written agreement between you and Nokia.
|
---|
16 | **
|
---|
17 | ** GNU Lesser General Public License Usage
|
---|
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
19 | ** General Public License version 2.1 as published by the Free Software
|
---|
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
21 | ** packaging of this file. Please review the following information to
|
---|
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
24 | **
|
---|
25 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
26 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
28 | **
|
---|
29 | ** GNU General Public License Usage
|
---|
30 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
31 | ** General Public License version 3.0 as published by the Free Software
|
---|
32 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
33 | ** packaging of this file. Please review the following information to
|
---|
34 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
35 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
36 | **
|
---|
37 | ** If you have questions regarding the use of this file, please contact
|
---|
38 | ** Nokia at qt-info@nokia.com.
|
---|
39 | ** $QT_END_LICENSE$
|
---|
40 | **
|
---|
41 | ****************************************************************************/
|
---|
42 |
|
---|
43 |
|
---|
44 | #define Q_SCRIPT_REGEXPLITERAL_RULE1 7
|
---|
45 |
|
---|
46 | #define Q_SCRIPT_REGEXPLITERAL_RULE2 8
|
---|
47 |
|
---|
48 | #include <translator.h>
|
---|
49 |
|
---|
50 | #include <QtCore/QCoreApplication>
|
---|
51 | #include <QtCore/qdebug.h>
|
---|
52 | #include <QtCore/qnumeric.h>
|
---|
53 | #include <QtCore/qstring.h>
|
---|
54 | #include <QtCore/qtextcodec.h>
|
---|
55 | #include <QtCore/qvariant.h>
|
---|
56 |
|
---|
57 | #include <iostream>
|
---|
58 |
|
---|
59 | #include <ctype.h>
|
---|
60 | #include <stdlib.h>
|
---|
61 | #include <stdio.h>
|
---|
62 | #include <string.h>
|
---|
63 |
|
---|
64 | QT_BEGIN_NAMESPACE
|
---|
65 |
|
---|
66 | class LU {
|
---|
67 | Q_DECLARE_TR_FUNCTIONS(LUpdate)
|
---|
68 | };
|
---|
69 |
|
---|
70 | class QScriptGrammar
|
---|
71 | {
|
---|
72 | public:
|
---|
73 | enum {
|
---|
74 | EOF_SYMBOL = 0,
|
---|
75 | T_AND = 1,
|
---|
76 | T_AND_AND = 2,
|
---|
77 | T_AND_EQ = 3,
|
---|
78 | T_AUTOMATIC_SEMICOLON = 62,
|
---|
79 | T_BREAK = 4,
|
---|
80 | T_CASE = 5,
|
---|
81 | T_CATCH = 6,
|
---|
82 | T_COLON = 7,
|
---|
83 | T_COMMA = 8,
|
---|
84 | T_CONST = 81,
|
---|
85 | T_CONTINUE = 9,
|
---|
86 | T_DEBUGGER = 82,
|
---|
87 | T_DEFAULT = 10,
|
---|
88 | T_DELETE = 11,
|
---|
89 | T_DIVIDE_ = 12,
|
---|
90 | T_DIVIDE_EQ = 13,
|
---|
91 | T_DO = 14,
|
---|
92 | T_DOT = 15,
|
---|
93 | T_ELSE = 16,
|
---|
94 | T_EQ = 17,
|
---|
95 | T_EQ_EQ = 18,
|
---|
96 | T_EQ_EQ_EQ = 19,
|
---|
97 | T_FALSE = 80,
|
---|
98 | T_FINALLY = 20,
|
---|
99 | T_FOR = 21,
|
---|
100 | T_FUNCTION = 22,
|
---|
101 | T_GE = 23,
|
---|
102 | T_GT = 24,
|
---|
103 | T_GT_GT = 25,
|
---|
104 | T_GT_GT_EQ = 26,
|
---|
105 | T_GT_GT_GT = 27,
|
---|
106 | T_GT_GT_GT_EQ = 28,
|
---|
107 | T_IDENTIFIER = 29,
|
---|
108 | T_IF = 30,
|
---|
109 | T_IN = 31,
|
---|
110 | T_INSTANCEOF = 32,
|
---|
111 | T_LBRACE = 33,
|
---|
112 | T_LBRACKET = 34,
|
---|
113 | T_LE = 35,
|
---|
114 | T_LPAREN = 36,
|
---|
115 | T_LT = 37,
|
---|
116 | T_LT_LT = 38,
|
---|
117 | T_LT_LT_EQ = 39,
|
---|
118 | T_MINUS = 40,
|
---|
119 | T_MINUS_EQ = 41,
|
---|
120 | T_MINUS_MINUS = 42,
|
---|
121 | T_NEW = 43,
|
---|
122 | T_NOT = 44,
|
---|
123 | T_NOT_EQ = 45,
|
---|
124 | T_NOT_EQ_EQ = 46,
|
---|
125 | T_NULL = 78,
|
---|
126 | T_NUMERIC_LITERAL = 47,
|
---|
127 | T_OR = 48,
|
---|
128 | T_OR_EQ = 49,
|
---|
129 | T_OR_OR = 50,
|
---|
130 | T_PLUS = 51,
|
---|
131 | T_PLUS_EQ = 52,
|
---|
132 | T_PLUS_PLUS = 53,
|
---|
133 | T_QUESTION = 54,
|
---|
134 | T_RBRACE = 55,
|
---|
135 | T_RBRACKET = 56,
|
---|
136 | T_REMAINDER = 57,
|
---|
137 | T_REMAINDER_EQ = 58,
|
---|
138 | T_RESERVED_WORD = 83,
|
---|
139 | T_RETURN = 59,
|
---|
140 | T_RPAREN = 60,
|
---|
141 | T_SEMICOLON = 61,
|
---|
142 | T_STAR = 63,
|
---|
143 | T_STAR_EQ = 64,
|
---|
144 | T_STRING_LITERAL = 65,
|
---|
145 | T_SWITCH = 66,
|
---|
146 | T_THIS = 67,
|
---|
147 | T_THROW = 68,
|
---|
148 | T_TILDE = 69,
|
---|
149 | T_TRUE = 79,
|
---|
150 | T_TRY = 70,
|
---|
151 | T_TYPEOF = 71,
|
---|
152 | T_VAR = 72,
|
---|
153 | T_VOID = 73,
|
---|
154 | T_WHILE = 74,
|
---|
155 | T_WITH = 75,
|
---|
156 | T_XOR = 76,
|
---|
157 | T_XOR_EQ = 77,
|
---|
158 |
|
---|
159 | ACCEPT_STATE = 236,
|
---|
160 | RULE_COUNT = 267,
|
---|
161 | STATE_COUNT = 465,
|
---|
162 | TERMINAL_COUNT = 84,
|
---|
163 | NON_TERMINAL_COUNT = 88,
|
---|
164 |
|
---|
165 | GOTO_INDEX_OFFSET = 465,
|
---|
166 | GOTO_INFO_OFFSET = 1374,
|
---|
167 | GOTO_CHECK_OFFSET = 1374
|
---|
168 | };
|
---|
169 |
|
---|
170 | static const char *const spell [];
|
---|
171 | static const int lhs [];
|
---|
172 | static const int rhs [];
|
---|
173 | static const int goto_default [];
|
---|
174 | static const int action_default [];
|
---|
175 | static const int action_index [];
|
---|
176 | static const int action_info [];
|
---|
177 | static const int action_check [];
|
---|
178 |
|
---|
179 | static inline int nt_action (int state, int nt)
|
---|
180 | {
|
---|
181 | const int *const goto_index = &action_index [GOTO_INDEX_OFFSET];
|
---|
182 | const int *const goto_check = &action_check [GOTO_CHECK_OFFSET];
|
---|
183 |
|
---|
184 | const int yyn = goto_index [state] + nt;
|
---|
185 |
|
---|
186 | if (yyn < 0 || goto_check [yyn] != nt)
|
---|
187 | return goto_default [nt];
|
---|
188 |
|
---|
189 | const int *const goto_info = &action_info [GOTO_INFO_OFFSET];
|
---|
190 | return goto_info [yyn];
|
---|
191 | }
|
---|
192 |
|
---|
193 | static inline int t_action (int state, int token)
|
---|
194 | {
|
---|
195 | const int yyn = action_index [state] + token;
|
---|
196 |
|
---|
197 | if (yyn < 0 || action_check [yyn] != token)
|
---|
198 | return - action_default [state];
|
---|
199 |
|
---|
200 | return action_info [yyn];
|
---|
201 | }
|
---|
202 | };
|
---|
203 |
|
---|
204 | const char *const QScriptGrammar::spell [] = {
|
---|
205 | "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue",
|
---|
206 | "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
|
---|
207 | "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
|
---|
208 | "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
|
---|
209 | "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
|
---|
210 | "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
|
---|
211 | ")", ";", 0, "*", "*=", "string literal", "switch", "this", "throw", "~",
|
---|
212 | "try", "typeof", "var", "void", "while", "with", "^", "^=", "null", "true",
|
---|
213 | "false", "const", "debugger", "reserved word"};
|
---|
214 |
|
---|
215 | const int QScriptGrammar::lhs [] = {
|
---|
216 | 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
|
---|
217 | 85, 85, 85, 85, 87, 87, 91, 91, 86, 86,
|
---|
218 | 92, 92, 93, 93, 93, 93, 94, 94, 94, 94,
|
---|
219 | 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
|
---|
220 | 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
|
---|
221 | 94, 94, 94, 94, 94, 94, 94, 95, 95, 96,
|
---|
222 | 96, 96, 96, 96, 99, 99, 100, 100, 100, 100,
|
---|
223 | 98, 98, 101, 101, 102, 102, 103, 103, 103, 104,
|
---|
224 | 104, 104, 104, 104, 104, 104, 104, 104, 104, 105,
|
---|
225 | 105, 105, 105, 106, 106, 106, 107, 107, 107, 107,
|
---|
226 | 108, 108, 108, 108, 108, 108, 108, 109, 109, 109,
|
---|
227 | 109, 109, 109, 110, 110, 110, 110, 110, 111, 111,
|
---|
228 | 111, 111, 111, 112, 112, 113, 113, 114, 114, 115,
|
---|
229 | 115, 116, 116, 117, 117, 118, 118, 119, 119, 120,
|
---|
230 | 120, 121, 121, 122, 122, 123, 123, 90, 90, 124,
|
---|
231 | 124, 125, 125, 125, 125, 125, 125, 125, 125, 125,
|
---|
232 | 125, 125, 125, 89, 89, 126, 126, 127, 127, 128,
|
---|
233 | 128, 129, 129, 129, 129, 129, 129, 129, 129, 129,
|
---|
234 | 129, 129, 129, 129, 129, 129, 130, 146, 146, 145,
|
---|
235 | 145, 131, 131, 147, 147, 148, 148, 150, 150, 149,
|
---|
236 | 151, 154, 152, 152, 155, 153, 153, 132, 133, 133,
|
---|
237 | 134, 134, 135, 135, 135, 135, 135, 135, 135, 136,
|
---|
238 | 136, 136, 136, 137, 137, 137, 137, 138, 138, 139,
|
---|
239 | 141, 156, 156, 159, 159, 157, 157, 160, 158, 140,
|
---|
240 | 142, 142, 143, 143, 143, 161, 162, 144, 163, 97,
|
---|
241 | 167, 167, 164, 164, 165, 165, 168, 84, 169, 169,
|
---|
242 | 170, 170, 166, 166, 88, 88, 171};
|
---|
243 |
|
---|
244 | const int QScriptGrammar:: rhs[] = {
|
---|
245 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
|
---|
246 | 3, 5, 3, 3, 2, 4, 1, 2, 0, 1,
|
---|
247 | 3, 5, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
248 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
249 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
250 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
251 | 1, 4, 3, 3, 1, 2, 2, 2, 4, 3,
|
---|
252 | 2, 3, 1, 3, 1, 1, 1, 2, 2, 1,
|
---|
253 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
|
---|
254 | 3, 3, 3, 1, 3, 3, 1, 3, 3, 3,
|
---|
255 | 1, 3, 3, 3, 3, 3, 3, 1, 3, 3,
|
---|
256 | 3, 3, 3, 1, 3, 3, 3, 3, 1, 3,
|
---|
257 | 3, 3, 3, 1, 3, 1, 3, 1, 3, 1,
|
---|
258 | 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
|
---|
259 | 3, 1, 3, 1, 5, 1, 5, 1, 3, 1,
|
---|
260 | 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
261 | 1, 1, 1, 1, 3, 0, 1, 1, 3, 0,
|
---|
262 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
263 | 1, 1, 1, 1, 1, 1, 3, 1, 2, 0,
|
---|
264 | 1, 3, 3, 1, 1, 1, 3, 1, 3, 2,
|
---|
265 | 2, 2, 0, 1, 2, 0, 1, 1, 2, 2,
|
---|
266 | 7, 5, 7, 7, 5, 9, 10, 7, 8, 2,
|
---|
267 | 2, 3, 3, 2, 2, 3, 3, 3, 3, 5,
|
---|
268 | 5, 3, 5, 1, 2, 0, 1, 4, 3, 3,
|
---|
269 | 3, 3, 3, 3, 4, 5, 2, 1, 8, 8,
|
---|
270 | 1, 3, 0, 1, 0, 1, 1, 1, 1, 2,
|
---|
271 | 1, 1, 0, 1, 0, 1, 2};
|
---|
272 |
|
---|
273 | const int QScriptGrammar::action_default [] = {
|
---|
274 | 0, 97, 164, 128, 136, 132, 172, 179, 76, 148,
|
---|
275 | 178, 186, 174, 124, 0, 175, 262, 61, 176, 177,
|
---|
276 | 182, 77, 140, 144, 65, 94, 75, 80, 60, 0,
|
---|
277 | 114, 180, 101, 259, 258, 261, 183, 0, 194, 0,
|
---|
278 | 248, 0, 8, 9, 0, 5, 0, 263, 2, 0,
|
---|
279 | 265, 19, 0, 0, 0, 0, 0, 3, 6, 0,
|
---|
280 | 0, 166, 208, 7, 0, 1, 0, 0, 4, 0,
|
---|
281 | 0, 195, 0, 0, 0, 184, 185, 90, 0, 173,
|
---|
282 | 181, 0, 0, 77, 96, 263, 2, 265, 79, 78,
|
---|
283 | 0, 0, 0, 92, 93, 91, 0, 264, 253, 254,
|
---|
284 | 0, 251, 0, 252, 0, 255, 256, 0, 257, 250,
|
---|
285 | 260, 0, 266, 0, 26, 27, 28, 29, 30, 31,
|
---|
286 | 32, 33, 34, 35, 36, 37, 38, 39, 40, 23,
|
---|
287 | 41, 42, 43, 44, 45, 25, 46, 47, 24, 48,
|
---|
288 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 0,
|
---|
289 | 21, 0, 0, 0, 22, 13, 95, 0, 125, 0,
|
---|
290 | 0, 0, 0, 115, 0, 0, 0, 0, 0, 0,
|
---|
291 | 105, 0, 0, 0, 99, 100, 98, 103, 107, 106,
|
---|
292 | 104, 102, 117, 116, 118, 0, 133, 0, 129, 68,
|
---|
293 | 0, 0, 0, 70, 59, 58, 0, 0, 69, 165,
|
---|
294 | 0, 73, 71, 0, 72, 74, 209, 210, 0, 161,
|
---|
295 | 154, 152, 159, 160, 158, 157, 163, 156, 155, 153,
|
---|
296 | 162, 149, 0, 137, 0, 0, 141, 0, 0, 145,
|
---|
297 | 67, 0, 0, 63, 0, 62, 267, 224, 0, 225,
|
---|
298 | 226, 227, 220, 0, 221, 222, 223, 81, 0, 0,
|
---|
299 | 0, 0, 0, 213, 214, 170, 168, 130, 138, 134,
|
---|
300 | 150, 126, 171, 0, 77, 142, 146, 119, 108, 0,
|
---|
301 | 0, 127, 0, 0, 0, 0, 120, 0, 0, 0,
|
---|
302 | 0, 0, 112, 110, 113, 111, 109, 122, 121, 123,
|
---|
303 | 0, 135, 0, 131, 0, 169, 77, 0, 151, 166,
|
---|
304 | 167, 0, 166, 0, 0, 216, 0, 0, 0, 218,
|
---|
305 | 0, 139, 0, 0, 143, 0, 0, 147, 206, 0,
|
---|
306 | 198, 207, 201, 0, 205, 0, 166, 199, 0, 166,
|
---|
307 | 0, 0, 217, 0, 0, 0, 219, 264, 253, 0,
|
---|
308 | 0, 255, 0, 249, 0, 240, 0, 0, 0, 212,
|
---|
309 | 0, 211, 188, 191, 0, 27, 30, 31, 248, 34,
|
---|
310 | 35, 5, 39, 40, 2, 41, 44, 3, 6, 166,
|
---|
311 | 7, 48, 1, 50, 4, 52, 53, 54, 55, 56,
|
---|
312 | 57, 189, 187, 65, 66, 64, 0, 228, 229, 0,
|
---|
313 | 0, 0, 231, 236, 234, 237, 0, 0, 235, 236,
|
---|
314 | 0, 232, 0, 233, 190, 239, 0, 190, 238, 0,
|
---|
315 | 241, 242, 0, 190, 243, 244, 0, 0, 245, 0,
|
---|
316 | 0, 0, 246, 247, 83, 82, 0, 0, 0, 215,
|
---|
317 | 0, 0, 0, 230, 0, 20, 0, 17, 19, 11,
|
---|
318 | 0, 16, 12, 18, 15, 10, 0, 14, 87, 85,
|
---|
319 | 89, 86, 84, 88, 203, 196, 0, 204, 200, 0,
|
---|
320 | 202, 192, 0, 193, 197};
|
---|
321 |
|
---|
322 | const int QScriptGrammar::goto_default [] = {
|
---|
323 | 29, 28, 436, 434, 113, 14, 2, 435, 112, 111,
|
---|
324 | 114, 193, 24, 17, 189, 26, 8, 200, 21, 27,
|
---|
325 | 77, 25, 1, 32, 30, 267, 13, 261, 3, 257,
|
---|
326 | 5, 259, 4, 258, 22, 265, 23, 266, 9, 260,
|
---|
327 | 256, 297, 386, 262, 263, 35, 6, 79, 12, 15,
|
---|
328 | 18, 19, 10, 7, 31, 80, 20, 36, 75, 76,
|
---|
329 | 11, 354, 353, 78, 456, 455, 319, 320, 458, 322,
|
---|
330 | 457, 321, 392, 396, 399, 395, 394, 414, 415, 16,
|
---|
331 | 100, 107, 96, 99, 106, 108, 33, 0};
|
---|
332 |
|
---|
333 | const int QScriptGrammar::action_index [] = {
|
---|
334 | 1210, 59, -84, 71, 41, -1, -84, -84, 148, -84,
|
---|
335 | -84, -84, -84, 201, 130, -84, -84, -84, -84, -84,
|
---|
336 | -84, 343, 67, 62, 122, 109, -84, -84, -84, 85,
|
---|
337 | 273, -84, 184, -84, 1210, -84, -84, 119, -84, 112,
|
---|
338 | -84, 521, -84, -84, 1130, -84, 45, 54, 58, 38,
|
---|
339 | 1290, 50, 521, 521, 521, 376, 521, -84, -84, 521,
|
---|
340 | 521, 521, -84, -84, 25, -84, 521, 521, -84, 43,
|
---|
341 | 521, -84, 521, 18, 15, -84, -84, -84, 24, -84,
|
---|
342 | -84, 521, 521, 64, 153, 27, -84, 1050, -84, -84,
|
---|
343 | 521, 521, 521, -84, -84, -84, 28, -84, 37, 55,
|
---|
344 | 19, -84, 33, -84, 34, 1210, -84, 16, 1210, -84,
|
---|
345 | -84, 39, 52, -3, -84, -84, -84, -84, -84, -84,
|
---|
346 | -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
|
---|
347 | -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
|
---|
348 | -84, -84, -84, -84, -84, -84, -84, -84, -84, 521,
|
---|
349 | -84, 1050, 125, 521, -84, -84, 155, 521, 189, 521,
|
---|
350 | 521, 521, 521, 248, 521, 521, 521, 521, 521, 521,
|
---|
351 | 243, 521, 521, 521, 75, 82, 94, 177, 184, 184,
|
---|
352 | 184, 184, 263, 283, 298, 521, 44, 521, 77, -84,
|
---|
353 | 970, 521, 817, -84, -84, -84, 95, 521, -84, -84,
|
---|
354 | 93, -84, -84, 521, -84, -84, -84, -84, 521, -84,
|
---|
355 | -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
|
---|
356 | -84, -84, 521, 41, 521, 521, 68, 66, 521, -84,
|
---|
357 | -84, 970, 521, -84, 103, -84, -84, -84, 63, -84,
|
---|
358 | -84, -84, -84, 69, -84, -84, -84, -84, -27, 12,
|
---|
359 | 521, 92, 100, -84, -84, 890, -84, 31, -13, -45,
|
---|
360 | -84, 210, 32, -28, 387, 20, 73, 304, 117, -5,
|
---|
361 | 521, 212, 521, 521, 521, 521, 213, 521, 521, 521,
|
---|
362 | 521, 521, 151, 150, 176, 158, 168, 304, 304, 228,
|
---|
363 | 521, -72, 521, 4, 521, -84, 306, 521, -84, 521,
|
---|
364 | 8, -50, 521, -48, 1130, -84, 521, 80, 1130, -84,
|
---|
365 | 521, -33, 521, 521, 5, 48, 521, -84, 17, 88,
|
---|
366 | 11, -84, -84, 521, -84, -29, 521, -84, -41, 521,
|
---|
367 | -39, 1130, -84, 521, 87, 1130, -84, -8, -2, -35,
|
---|
368 | 10, 1210, -16, -84, 1130, -84, 521, 86, 1130, -14,
|
---|
369 | 1130, -84, -84, 1130, -36, 107, -21, 165, 3, 521,
|
---|
370 | 1130, 6, 14, 61, 7, -19, 448, -4, -6, 671,
|
---|
371 | 29, 13, 23, 521, 30, -10, 521, 9, 521, -30,
|
---|
372 | -18, -84, -84, 164, -84, -84, 46, -84, -84, 521,
|
---|
373 | 111, -24, -84, 36, -84, 40, 99, 521, -84, 21,
|
---|
374 | 22, -84, -11, -84, 1130, -84, 106, 1130, -84, 178,
|
---|
375 | -84, -84, 98, 1130, 57, -84, 56, 60, -84, 51,
|
---|
376 | 26, 35, -84, -84, -84, -84, 521, 97, 1130, -84,
|
---|
377 | 521, 90, 1130, -84, 79, 76, 744, -84, 49, -84,
|
---|
378 | 594, -84, -84, -84, -84, -84, 83, -84, -84, -84,
|
---|
379 | -84, -84, -84, -84, 42, -84, 162, -84, -84, 521,
|
---|
380 | -84, -84, 53, -84, -84,
|
---|
381 |
|
---|
382 | -61, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
383 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
384 | -88, -4, -88, -88, 22, -88, -88, -88, -88, -88,
|
---|
385 | -88, -88, -88, -88, -51, -88, -88, -88, -88, -88,
|
---|
386 | -88, 105, -88, -88, -12, -88, -88, -88, -88, -88,
|
---|
387 | -7, -88, 35, 132, 62, 154, 79, -88, -88, 100,
|
---|
388 | 75, 36, -88, -88, -88, -88, 37, 70, -88, -1,
|
---|
389 | 86, -88, 92, -88, -88, -88, -88, -88, -88, -88,
|
---|
390 | -88, 90, 95, -88, -88, -88, -88, -88, -88, -88,
|
---|
391 | 87, 82, 74, -88, -88, -88, -88, -88, -88, -88,
|
---|
392 | -88, -88, -88, -88, -88, -88, -88, -88, -47, -88,
|
---|
393 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
394 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
395 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
396 | -88, -88, -88, -88, -88, -88, -88, -88, -88, 28,
|
---|
397 | -88, 20, -88, 19, -88, -88, -88, 39, -88, 42,
|
---|
398 | 43, 106, 61, -88, 63, 55, 52, 53, 91, 125,
|
---|
399 | -88, 120, 123, 118, -88, -88, -88, -88, -88, -88,
|
---|
400 | -88, -88, -88, -88, -88, 116, -88, 59, -88, -88,
|
---|
401 | 16, 18, 15, -88, -88, -88, -88, 21, -88, -88,
|
---|
402 | -88, -88, -88, 24, -88, -88, -88, -88, 38, -88,
|
---|
403 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
404 | -88, -88, 97, -88, 115, 25, -88, -88, 26, -88,
|
---|
405 | -88, 111, 14, -88, -88, -88, -88, -88, -88, -88,
|
---|
406 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
407 | 23, -88, -88, -88, -88, 108, -88, -88, -88, -88,
|
---|
408 | -88, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
409 | 160, -88, 171, 163, 145, 179, -88, 135, 45, 41,
|
---|
410 | 66, 80, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
411 | 172, -88, 156, -88, 142, -88, -88, 144, -88, 122,
|
---|
412 | -88, -88, 114, -88, -23, -88, 48, -88, 29, -88,
|
---|
413 | 224, -88, 157, 175, -88, -88, 182, -88, -88, -88,
|
---|
414 | -88, -88, -88, 183, -88, -21, 134, -88, -88, 49,
|
---|
415 | -88, 3, -88, 44, -88, 2, -88, -88, -37, -88,
|
---|
416 | -88, -31, -88, -88, 10, -88, 47, -88, 17, -88,
|
---|
417 | 27, -88, -88, 13, -88, -88, -88, -88, -88, 117,
|
---|
418 | 6, -88, -88, -88, -88, -88, 154, -88, -88, 1,
|
---|
419 | -88, -88, -88, 7, -88, -35, 137, -88, 141, -88,
|
---|
420 | -88, -88, -88, -6, -88, -88, -88, -88, -88, 78,
|
---|
421 | -88, -88, -88, -88, -88, -69, -88, 11, -88, -59,
|
---|
422 | -88, -88, -88, -88, 83, -88, -88, 56, -88, -88,
|
---|
423 | -88, -88, -88, -40, -58, -88, -88, -29, -88, -88,
|
---|
424 | -88, -45, -88, -88, -88, -88, -3, -88, -42, -88,
|
---|
425 | -5, -88, -32, -88, -88, -88, 9, -88, 8, -88,
|
---|
426 | -2, -88, -88, -88, -88, -88, -88, -88, -88, -88,
|
---|
427 | -88, -88, -88, -88, -88, -88, -88, -88, -88, 12,
|
---|
428 | -88, -88, -56, -88, -88};
|
---|
429 |
|
---|
430 | const int QScriptGrammar::action_info [] = {
|
---|
431 | 318, -25, 350, -45, 292, 270, 426, 310, -194, 393,
|
---|
432 | -32, 302, 304, -37, 344, 290, 197, 346, 430, 382,
|
---|
433 | 329, 331, 310, 413, 318, 340, 397, 101, 338, 404,
|
---|
434 | -49, 292, 270, 299, 323, 290, -24, -51, -195, 343,
|
---|
435 | 294, 397, 333, 341, 403, 397, 149, 249, 250, 389,
|
---|
436 | 255, 430, 155, 454, 426, 316, 97, 437, 437, 459,
|
---|
437 | 151, 389, 103, 102, 98, 344, 101, 105, 413, 222,
|
---|
438 | 222, 109, 157, 228, 346, 187, 413, 417, 157, 104,
|
---|
439 | 420, 255, 454, 337, 443, 236, 421, 438, 197, 185,
|
---|
440 | 97, 197, 419, 413, 197, 197, 325, -263, 197, 81,
|
---|
441 | 197, 203, 0, 197, 416, 197, 88, 388, 387, 400,
|
---|
442 | 82, 197, 224, 407, 197, 81, 225, 89, 417, 197,
|
---|
443 | 187, 90, 81, 312, 241, 240, 82, 313, 0, 0,
|
---|
444 | 246, 245, 153, 82, 81, 439, 238, 231, 197, 0,
|
---|
445 | 308, 243, 171, 447, 172, 82, 348, 335, 238, 326,
|
---|
446 | 432, 198, 252, 204, 401, 173, 232, 428, 192, 235,
|
---|
447 | 0, 254, 253, 190, 0, 90, 91, 90, 239, 237,
|
---|
448 | 462, 391, 92, 244, 242, 171, 171, 172, 172, 231,
|
---|
449 | 239, 237, 191, 171, 192, 172, 197, 0, 173, 173,
|
---|
450 | 0, 207, 206, 171, 243, 172, 173, 0, 232, 0,
|
---|
451 | 192, 171, 171, 172, 172, 0, 173, 159, 160, 171,
|
---|
452 | 91, 172, 91, 0, 173, 173, 92, 0, 92, 159,
|
---|
453 | 160, 0, 173, 463, 461, 0, 244, 242, 272, 273,
|
---|
454 | 272, 273, 0, 0, 161, 162, 277, 278, 0, 411,
|
---|
455 | 410, 0, 0, 0, 0, 279, 161, 162, 280, 0,
|
---|
456 | 281, 277, 278, 0, 0, 274, 275, 274, 275, 0,
|
---|
457 | 279, 0, 0, 280, 0, 281, 0, 0, 171, 0,
|
---|
458 | 172, 164, 165, 0, 0, 0, 0, 0, 0, 166,
|
---|
459 | 167, 173, 0, 168, 0, 169, 164, 165, 0, 0,
|
---|
460 | 0, 0, 0, 0, 166, 167, 164, 165, 168, 0,
|
---|
461 | 169, 0, 0, 0, 166, 167, 164, 165, 168, 209,
|
---|
462 | 169, 0, 0, 0, 166, 167, 0, 0, 168, 210,
|
---|
463 | 169, 164, 165, 211, 0, 0, 0, 277, 278, 166,
|
---|
464 | 167, 0, 212, 168, 213, 169, 279, 0, 0, 280,
|
---|
465 | 0, 281, 0, 0, 0, 214, 209, 215, 88, 0,
|
---|
466 | 0, 0, 0, 0, 0, 216, 210, 0, 217, 89,
|
---|
467 | 211, 0, 0, 0, 218, 0, 0, 0, 0, 212,
|
---|
468 | 219, 213, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
469 | 0, 0, 214, 220, 215, 88, 0, 0, 42, 43,
|
---|
470 | 209, 0, 216, 0, 0, 217, 89, 0, 85, 0,
|
---|
471 | 210, 218, 0, 0, 211, 86, 0, 219, 0, 87,
|
---|
472 | 51, 0, 52, 212, 0, 213, 0, 0, 306, 55,
|
---|
473 | 220, 0, 0, 58, 0, 0, 214, 0, 215, 88,
|
---|
474 | 0, 0, 0, 0, 0, 0, 216, 0, 0, 217,
|
---|
475 | 89, 63, 0, 65, 0, 218, 0, 0, 0, 0,
|
---|
476 | 0, 219, 0, 0, 57, 68, 45, 0, 0, 0,
|
---|
477 | 42, 43, 0, 0, 220, 0, 0, 0, 0, 0,
|
---|
478 | 85, 0, 0, 0, 0, 0, 0, 86, 0, 0,
|
---|
479 | 0, 87, 51, 0, 52, 0, 0, 0, 0, 0,
|
---|
480 | 0, 55, 0, 0, 0, 58, 0, 0, 0, 0,
|
---|
481 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
482 | 0, 0, 0, 63, 0, 65, 0, 0, 0, 0,
|
---|
483 | 0, 0, 0, 0, 0, 0, 57, 68, 45, 0,
|
---|
484 | 0, 0, 41, 42, 43, 0, 0, 0, 0, 0,
|
---|
485 | 0, 0, 0, 85, 0, 0, 0, 0, 0, 0,
|
---|
486 | 86, 0, 0, 0, 87, 51, 0, 52, 0, 0,
|
---|
487 | 0, 53, 0, 54, 55, 56, 0, 0, 58, 0,
|
---|
488 | 0, 0, 59, 0, 60, 0, 0, 0, 0, 0,
|
---|
489 | 0, 0, 0, 0, 0, 0, 63, 0, 65, 0,
|
---|
490 | 67, 0, 70, 0, 72, 0, 0, 0, 0, 57,
|
---|
491 | 68, 45, 0, 0, 0, 41, 42, 43, 0, 0,
|
---|
492 | 0, 0, 0, 0, 0, 0, 85, 0, 0, 0,
|
---|
493 | 0, 0, 0, 86, 0, 0, 0, 87, 51, 0,
|
---|
494 | 52, 0, 0, 0, 53, 0, 54, 55, 56, 0,
|
---|
495 | 0, 58, 0, 0, 0, 59, 0, 60, 0, 0,
|
---|
496 | 442, 0, 0, 0, 0, 0, 0, 0, 0, 63,
|
---|
497 | 0, 65, 0, 67, 0, 70, 0, 72, 0, 0,
|
---|
498 | 0, 0, 57, 68, 45, 0, 0, 0, -47, 0,
|
---|
499 | 0, 0, 41, 42, 43, 0, 0, 0, 0, 0,
|
---|
500 | 0, 0, 0, 85, 0, 0, 0, 0, 0, 0,
|
---|
501 | 86, 0, 0, 0, 87, 51, 0, 52, 0, 0,
|
---|
502 | 0, 53, 0, 54, 55, 56, 0, 0, 58, 0,
|
---|
503 | 0, 0, 59, 0, 60, 0, 0, 0, 0, 0,
|
---|
504 | 0, 0, 0, 0, 0, 0, 63, 0, 65, 0,
|
---|
505 | 67, 0, 70, 0, 72, 0, 0, 0, 0, 57,
|
---|
506 | 68, 45, 0, 0, 0, 41, 42, 43, 0, 0,
|
---|
507 | 0, 0, 0, 0, 0, 0, 85, 0, 0, 0,
|
---|
508 | 0, 0, 0, 86, 0, 0, 0, 87, 51, 0,
|
---|
509 | 52, 0, 0, 0, 53, 0, 54, 55, 56, 0,
|
---|
510 | 0, 58, 0, 0, 0, 59, 0, 60, 0, 0,
|
---|
511 | 445, 0, 0, 0, 0, 0, 0, 0, 0, 63,
|
---|
512 | 0, 65, 0, 67, 0, 70, 0, 72, 0, 0,
|
---|
513 | 0, 0, 57, 68, 45, 0, 0, 0, 41, 42,
|
---|
514 | 43, 0, 0, 0, 0, 0, 0, 0, 0, 85,
|
---|
515 | 0, 0, 0, 0, 0, 0, 86, 0, 0, 0,
|
---|
516 | 87, 51, 0, 52, 0, 0, 0, 53, 0, 54,
|
---|
517 | 55, 56, 0, 0, 58, 0, 0, 0, 59, 0,
|
---|
518 | 60, 0, 0, 0, 0, 0, 0, 202, 0, 0,
|
---|
519 | 0, 0, 63, 0, 65, 0, 67, 0, 70, 0,
|
---|
520 | 72, 0, 0, 0, 0, 57, 68, 45, 0, 0,
|
---|
521 | 0, 41, 42, 43, 0, 0, 0, 0, 0, 0,
|
---|
522 | 0, 0, 85, 0, 0, 0, 0, 0, 0, 86,
|
---|
523 | 0, 0, 0, 87, 51, 0, 52, 0, 0, 0,
|
---|
524 | 53, 0, 54, 55, 56, 0, 0, 58, 0, 0,
|
---|
525 | 0, 59, 0, 60, 0, 0, 0, 0, 0, 0,
|
---|
526 | 0, 0, 0, 0, 0, 63, 0, 65, 0, 67,
|
---|
527 | 0, 70, 269, 72, 0, 0, 0, 0, 57, 68,
|
---|
528 | 45, 0, 0, 0, 115, 116, 117, 0, 0, 119,
|
---|
529 | 121, 122, 0, 0, 123, 0, 124, 0, 0, 0,
|
---|
530 | 126, 127, 128, 0, 0, 0, 0, 0, 0, 195,
|
---|
531 | 130, 131, 132, 0, 0, 0, 0, 0, 0, 0,
|
---|
532 | 0, 0, 0, 133, 0, 0, 0, 0, 0, 0,
|
---|
533 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 137,
|
---|
534 | 0, 0, 0, 0, 0, 0, 139, 140, 141, 0,
|
---|
535 | 143, 144, 145, 146, 147, 148, 0, 0, 134, 142,
|
---|
536 | 125, 118, 120, 136, 115, 116, 117, 0, 0, 119,
|
---|
537 | 121, 122, 0, 0, 123, 0, 124, 0, 0, 0,
|
---|
538 | 126, 127, 128, 0, 0, 0, 0, 0, 0, 129,
|
---|
539 | 130, 131, 132, 0, 0, 0, 0, 0, 0, 0,
|
---|
540 | 0, 0, 0, 133, 0, 0, 0, 135, 0, 0,
|
---|
541 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 137,
|
---|
542 | 0, 0, 0, 0, 0, 138, 139, 140, 141, 0,
|
---|
543 | 143, 144, 145, 146, 147, 148, 0, 0, 134, 142,
|
---|
544 | 125, 118, 120, 136, 37, 0, 0, 0, 0, 39,
|
---|
545 | 0, 41, 42, 43, 44, 0, 0, 0, 0, 0,
|
---|
546 | 0, 46, 85, 0, 0, 0, 0, 0, 0, 48,
|
---|
547 | 49, 0, 0, 50, 51, 0, 52, 0, 0, 0,
|
---|
548 | 53, 0, 54, 55, 56, 0, 0, 58, 0, 0,
|
---|
549 | 0, 59, 0, 60, 0, 0, 0, 0, 0, 61,
|
---|
550 | 0, 62, 0, 0, 0, 63, 64, 65, 66, 67,
|
---|
551 | 69, 70, 71, 72, 73, 74, 0, 0, 57, 68,
|
---|
552 | 45, 38, 40, 0, 37, 0, 0, 0, 0, 39,
|
---|
553 | 0, 41, 42, 43, 44, 0, 0, 0, 0, 0,
|
---|
554 | 0, 46, 47, 0, 0, 0, 0, 0, 0, 48,
|
---|
555 | 49, 0, 0, 50, 51, 0, 52, 0, 0, 0,
|
---|
556 | 53, 0, 54, 55, 56, 0, 0, 58, 0, 0,
|
---|
557 | 0, 59, 0, 60, 0, 0, 0, 0, 0, 61,
|
---|
558 | 0, 62, 0, 0, 0, 63, 64, 65, 66, 67,
|
---|
559 | 69, 70, 71, 72, 73, 74, 0, 0, 57, 68,
|
---|
560 | 45, 38, 40, 0, 355, 116, 117, 0, 0, 357,
|
---|
561 | 121, 359, 42, 43, 360, 0, 124, 0, 0, 0,
|
---|
562 | 126, 362, 363, 0, 0, 0, 0, 0, 0, 364,
|
---|
563 | 365, 131, 132, 50, 51, 0, 52, 0, 0, 0,
|
---|
564 | 53, 0, 54, 366, 56, 0, 0, 368, 0, 0,
|
---|
565 | 0, 59, 0, 60, 0, -190, 0, 0, 0, 369,
|
---|
566 | 0, 62, 0, 0, 0, 370, 371, 372, 373, 67,
|
---|
567 | 375, 376, 377, 378, 379, 380, 0, 0, 367, 374,
|
---|
568 | 361, 356, 358, 136,
|
---|
569 |
|
---|
570 | 431, 422, 427, 429, 441, 352, 300, 398, 385, 464,
|
---|
571 | 440, 412, 409, 433, 402, 444, 406, 423, 460, 234,
|
---|
572 | 418, 201, 305, 196, 34, 154, 194, 199, 251, 152,
|
---|
573 | 205, 227, 229, 248, 150, 110, 230, 208, 352, 110,
|
---|
574 | 446, 300, 409, 339, 221, 412, 327, 336, 332, 334,
|
---|
575 | 342, 248, 347, 307, 300, 345, 0, 83, 381, 83,
|
---|
576 | 83, 83, 349, 83, 284, 158, 163, 182, 283, 0,
|
---|
577 | 83, 83, 351, 83, 309, 178, 179, 83, 177, 83,
|
---|
578 | 83, 83, 449, 390, 83, 184, 170, 188, 83, 285,
|
---|
579 | 453, 330, 83, 83, 95, 452, 0, 83, 83, 450,
|
---|
580 | 83, 352, 94, 286, 83, 83, 424, 93, 83, 83,
|
---|
581 | 83, 84, 425, 83, 180, 83, 156, 408, 83, 300,
|
---|
582 | 451, 194, 233, 83, 83, 247, 264, 300, 352, 223,
|
---|
583 | 183, 268, 0, 83, 83, 83, 83, 247, 83, 300,
|
---|
584 | 176, 83, 174, 83, 405, 175, 186, 0, 181, 226,
|
---|
585 | 83, 0, 448, 83, 0, 83, 303, 424, 282, 83,
|
---|
586 | 296, 425, 296, 83, 301, 268, 383, 268, 268, 384,
|
---|
587 | 288, 0, 0, 0, 83, 83, 328, 0, 83, 268,
|
---|
588 | 268, 83, 295, 268, 298, 293, 268, 271, 287, 83,
|
---|
589 | 83, 0, 314, 296, 268, 268, 276, 83, 268, 0,
|
---|
590 | 296, 296, 268, 291, 289, 268, 268, 0, 0, 0,
|
---|
591 | 0, 0, 0, 0, 0, 315, 0, 0, 0, 0,
|
---|
592 | 0, 0, 317, 324, 0, 0, 0, 0, 0, 0,
|
---|
593 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
594 | 0, 0, 83, 0, 0, 0, 0, 268, 0, 0,
|
---|
595 | 0, 0, 0, 0, 0, 0, 0, 311, 0, 0,
|
---|
596 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
597 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
598 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
599 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
600 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
601 | 0, 0};
|
---|
602 |
|
---|
603 | const int QScriptGrammar::action_check [] = {
|
---|
604 | 29, 7, 16, 7, 76, 1, 36, 2, 29, 33,
|
---|
605 | 7, 61, 60, 7, 7, 48, 8, 36, 36, 55,
|
---|
606 | 61, 60, 2, 33, 29, 60, 5, 29, 36, 7,
|
---|
607 | 7, 76, 1, 61, 17, 48, 7, 7, 29, 55,
|
---|
608 | 8, 5, 31, 33, 55, 5, 7, 74, 36, 36,
|
---|
609 | 36, 36, 55, 29, 36, 7, 29, 8, 8, 17,
|
---|
610 | 8, 36, 29, 8, 36, 7, 29, 33, 33, 2,
|
---|
611 | 2, 55, 1, 7, 36, 76, 33, 20, 1, 60,
|
---|
612 | 29, 36, 29, 29, 8, 0, 60, 8, 8, 48,
|
---|
613 | 29, 8, 36, 33, 8, 8, 8, 36, 8, 40,
|
---|
614 | 8, 8, -1, 8, 6, 8, 42, 61, 62, 10,
|
---|
615 | 51, 8, 50, 7, 8, 40, 54, 53, 20, 8,
|
---|
616 | 76, 12, 40, 50, 61, 62, 51, 54, -1, -1,
|
---|
617 | 61, 62, 7, 51, 40, 56, 29, 15, 8, -1,
|
---|
618 | 60, 29, 25, 60, 27, 51, 60, 60, 29, 61,
|
---|
619 | 60, 56, 60, 60, 55, 38, 34, 60, 36, 56,
|
---|
620 | -1, 61, 62, 15, -1, 12, 57, 12, 61, 62,
|
---|
621 | 8, 60, 63, 61, 62, 25, 25, 27, 27, 15,
|
---|
622 | 61, 62, 34, 25, 36, 27, 8, -1, 38, 38,
|
---|
623 | -1, 61, 62, 25, 29, 27, 38, -1, 34, -1,
|
---|
624 | 36, 25, 25, 27, 27, -1, 38, 18, 19, 25,
|
---|
625 | 57, 27, 57, -1, 38, 38, 63, -1, 63, 18,
|
---|
626 | 19, -1, 38, 61, 62, -1, 61, 62, 18, 19,
|
---|
627 | 18, 19, -1, -1, 45, 46, 23, 24, -1, 61,
|
---|
628 | 62, -1, -1, -1, -1, 32, 45, 46, 35, -1,
|
---|
629 | 37, 23, 24, -1, -1, 45, 46, 45, 46, -1,
|
---|
630 | 32, -1, -1, 35, -1, 37, -1, -1, 25, -1,
|
---|
631 | 27, 23, 24, -1, -1, -1, -1, -1, -1, 31,
|
---|
632 | 32, 38, -1, 35, -1, 37, 23, 24, -1, -1,
|
---|
633 | -1, -1, -1, -1, 31, 32, 23, 24, 35, -1,
|
---|
634 | 37, -1, -1, -1, 31, 32, 23, 24, 35, 3,
|
---|
635 | 37, -1, -1, -1, 31, 32, -1, -1, 35, 13,
|
---|
636 | 37, 23, 24, 17, -1, -1, -1, 23, 24, 31,
|
---|
637 | 32, -1, 26, 35, 28, 37, 32, -1, -1, 35,
|
---|
638 | -1, 37, -1, -1, -1, 39, 3, 41, 42, -1,
|
---|
639 | -1, -1, -1, -1, -1, 49, 13, -1, 52, 53,
|
---|
640 | 17, -1, -1, -1, 58, -1, -1, -1, -1, 26,
|
---|
641 | 64, 28, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
642 | -1, -1, 39, 77, 41, 42, -1, -1, 12, 13,
|
---|
643 | 3, -1, 49, -1, -1, 52, 53, -1, 22, -1,
|
---|
644 | 13, 58, -1, -1, 17, 29, -1, 64, -1, 33,
|
---|
645 | 34, -1, 36, 26, -1, 28, -1, -1, 31, 43,
|
---|
646 | 77, -1, -1, 47, -1, -1, 39, -1, 41, 42,
|
---|
647 | -1, -1, -1, -1, -1, -1, 49, -1, -1, 52,
|
---|
648 | 53, 65, -1, 67, -1, 58, -1, -1, -1, -1,
|
---|
649 | -1, 64, -1, -1, 78, 79, 80, -1, -1, -1,
|
---|
650 | 12, 13, -1, -1, 77, -1, -1, -1, -1, -1,
|
---|
651 | 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
|
---|
652 | -1, 33, 34, -1, 36, -1, -1, -1, -1, -1,
|
---|
653 | -1, 43, -1, -1, -1, 47, -1, -1, -1, -1,
|
---|
654 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
655 | -1, -1, -1, 65, -1, 67, -1, -1, -1, -1,
|
---|
656 | -1, -1, -1, -1, -1, -1, 78, 79, 80, -1,
|
---|
657 | -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
|
---|
658 | -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
|
---|
659 | 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
|
---|
660 | -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
|
---|
661 | -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
|
---|
662 | -1, -1, -1, -1, -1, -1, 65, -1, 67, -1,
|
---|
663 | 69, -1, 71, -1, 73, -1, -1, -1, -1, 78,
|
---|
664 | 79, 80, -1, -1, -1, 11, 12, 13, -1, -1,
|
---|
665 | -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
|
---|
666 | -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
|
---|
667 | 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
|
---|
668 | -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
|
---|
669 | 56, -1, -1, -1, -1, -1, -1, -1, -1, 65,
|
---|
670 | -1, 67, -1, 69, -1, 71, -1, 73, -1, -1,
|
---|
671 | -1, -1, 78, 79, 80, -1, -1, -1, 7, -1,
|
---|
672 | -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
|
---|
673 | -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
|
---|
674 | 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
|
---|
675 | -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
|
---|
676 | -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
|
---|
677 | -1, -1, -1, -1, -1, -1, 65, -1, 67, -1,
|
---|
678 | 69, -1, 71, -1, 73, -1, -1, -1, -1, 78,
|
---|
679 | 79, 80, -1, -1, -1, 11, 12, 13, -1, -1,
|
---|
680 | -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
|
---|
681 | -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
|
---|
682 | 36, -1, -1, -1, 40, -1, 42, 43, 44, -1,
|
---|
683 | -1, 47, -1, -1, -1, 51, -1, 53, -1, -1,
|
---|
684 | 56, -1, -1, -1, -1, -1, -1, -1, -1, 65,
|
---|
685 | -1, 67, -1, 69, -1, 71, -1, 73, -1, -1,
|
---|
686 | -1, -1, 78, 79, 80, -1, -1, -1, 11, 12,
|
---|
687 | 13, -1, -1, -1, -1, -1, -1, -1, -1, 22,
|
---|
688 | -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
|
---|
689 | 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
|
---|
690 | 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
|
---|
691 | 53, -1, -1, -1, -1, -1, -1, 60, -1, -1,
|
---|
692 | -1, -1, 65, -1, 67, -1, 69, -1, 71, -1,
|
---|
693 | 73, -1, -1, -1, -1, 78, 79, 80, -1, -1,
|
---|
694 | -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
|
---|
695 | -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
696 | -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
|
---|
697 | 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
|
---|
698 | -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
|
---|
699 | -1, -1, -1, -1, -1, 65, -1, 67, -1, 69,
|
---|
700 | -1, 71, 72, 73, -1, -1, -1, -1, 78, 79,
|
---|
701 | 80, -1, -1, -1, 4, 5, 6, -1, -1, 9,
|
---|
702 | 10, 11, -1, -1, 14, -1, 16, -1, -1, -1,
|
---|
703 | 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
704 | 30, 31, 32, -1, -1, -1, -1, -1, -1, -1,
|
---|
705 | -1, -1, -1, 43, -1, -1, -1, -1, -1, -1,
|
---|
706 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
|
---|
707 | -1, -1, -1, -1, -1, -1, 66, 67, 68, -1,
|
---|
708 | 70, 71, 72, 73, 74, 75, -1, -1, 78, 79,
|
---|
709 | 80, 81, 82, 83, 4, 5, 6, -1, -1, 9,
|
---|
710 | 10, 11, -1, -1, 14, -1, 16, -1, -1, -1,
|
---|
711 | 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
712 | 30, 31, 32, -1, -1, -1, -1, -1, -1, -1,
|
---|
713 | -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
|
---|
714 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
|
---|
715 | -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
|
---|
716 | 70, 71, 72, 73, 74, 75, -1, -1, 78, 79,
|
---|
717 | 80, 81, 82, 83, 4, -1, -1, -1, -1, 9,
|
---|
718 | -1, 11, 12, 13, 14, -1, -1, -1, -1, -1,
|
---|
719 | -1, 21, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
720 | 30, -1, -1, 33, 34, -1, 36, -1, -1, -1,
|
---|
721 | 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
|
---|
722 | -1, 51, -1, 53, -1, -1, -1, -1, -1, 59,
|
---|
723 | -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
|
---|
724 | 70, 71, 72, 73, 74, 75, -1, -1, 78, 79,
|
---|
725 | 80, 81, 82, -1, 4, -1, -1, -1, -1, 9,
|
---|
726 | -1, 11, 12, 13, 14, -1, -1, -1, -1, -1,
|
---|
727 | -1, 21, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
728 | 30, -1, -1, 33, 34, -1, 36, -1, -1, -1,
|
---|
729 | 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
|
---|
730 | -1, 51, -1, 53, -1, -1, -1, -1, -1, 59,
|
---|
731 | -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
|
---|
732 | 70, 71, 72, 73, 74, 75, -1, -1, 78, 79,
|
---|
733 | 80, 81, 82, -1, 4, 5, 6, -1, -1, 9,
|
---|
734 | 10, 11, 12, 13, 14, -1, 16, -1, -1, -1,
|
---|
735 | 20, 21, 22, -1, -1, -1, -1, -1, -1, 29,
|
---|
736 | 30, 31, 32, 33, 34, -1, 36, -1, -1, -1,
|
---|
737 | 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
|
---|
738 | -1, 51, -1, 53, -1, 55, -1, -1, -1, 59,
|
---|
739 | -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
|
---|
740 | 70, 71, 72, 73, 74, 75, -1, -1, 78, 79,
|
---|
741 | 80, 81, 82, 83,
|
---|
742 |
|
---|
743 | 5, 46, 5, 45, 6, 45, 5, 76, 14, 65,
|
---|
744 | 2, 46, 5, 45, 73, 6, 5, 46, 6, 5,
|
---|
745 | 78, 6, 45, 5, 85, 6, 10, 6, 5, 9,
|
---|
746 | 6, 6, 6, 45, 6, 86, 14, 41, 45, 86,
|
---|
747 | 5, 5, 5, 80, 6, 46, 67, 45, 45, 5,
|
---|
748 | 81, 45, 5, 5, 5, 45, -1, 18, 45, 18,
|
---|
749 | 18, 18, 45, 18, 23, 26, 24, 24, 23, -1,
|
---|
750 | 18, 18, 45, 18, 45, 23, 23, 18, 23, 18,
|
---|
751 | 18, 18, 20, 5, 18, 24, 23, 28, 18, 23,
|
---|
752 | 20, 42, 18, 18, 20, 20, -1, 18, 18, 20,
|
---|
753 | 18, 45, 20, 23, 18, 18, 20, 20, 18, 18,
|
---|
754 | 18, 21, 20, 18, 23, 18, 21, 61, 18, 5,
|
---|
755 | 20, 10, 11, 18, 18, 20, 18, 5, 45, 32,
|
---|
756 | 24, 23, -1, 18, 18, 18, 18, 20, 18, 5,
|
---|
757 | 22, 18, 22, 18, 61, 22, 30, -1, 23, 34,
|
---|
758 | 18, -1, 20, 18, -1, 18, 42, 20, 23, 18,
|
---|
759 | 18, 20, 18, 18, 42, 23, 12, 23, 23, 15,
|
---|
760 | 25, -1, -1, -1, 18, 18, 42, -1, 18, 23,
|
---|
761 | 23, 18, 40, 23, 40, 29, 23, 27, 25, 18,
|
---|
762 | 18, -1, 35, 18, 23, 23, 25, 18, 23, -1,
|
---|
763 | 18, 18, 23, 31, 25, 23, 23, -1, -1, -1,
|
---|
764 | -1, -1, -1, -1, -1, 40, -1, -1, -1, -1,
|
---|
765 | -1, -1, 40, 40, -1, -1, -1, -1, -1, -1,
|
---|
766 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
767 | -1, -1, 18, -1, -1, -1, -1, 23, -1, -1,
|
---|
768 | -1, -1, -1, -1, -1, -1, -1, 33, -1, -1,
|
---|
769 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
770 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
771 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
772 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
773 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
774 | -1, -1};
|
---|
775 |
|
---|
776 | static void recordMessage(
|
---|
777 | Translator *tor, const QString &context, const QString &text, const QString &comment,
|
---|
778 | const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra,
|
---|
779 | bool plural, const QString &fileName, int lineNo)
|
---|
780 | {
|
---|
781 | TranslatorMessage msg(
|
---|
782 | context, text, comment, QString(),
|
---|
783 | fileName, lineNo, QStringList(),
|
---|
784 | TranslatorMessage::Unfinished, plural);
|
---|
785 | msg.setExtraComment(extracomment.simplified());
|
---|
786 | msg.setId(msgid);
|
---|
787 | msg.setExtras(extra);
|
---|
788 | tor->extend(msg);
|
---|
789 | }
|
---|
790 |
|
---|
791 |
|
---|
792 | namespace QScript
|
---|
793 | {
|
---|
794 |
|
---|
795 | class CommentProcessor
|
---|
796 | {
|
---|
797 | public:
|
---|
798 | virtual ~CommentProcessor() {}
|
---|
799 | virtual void processComment(const QChar *chars, int length) = 0;
|
---|
800 | };
|
---|
801 |
|
---|
802 | class Lexer
|
---|
803 | {
|
---|
804 | public:
|
---|
805 | Lexer(CommentProcessor *);
|
---|
806 | ~Lexer();
|
---|
807 |
|
---|
808 | void setCode(const QString &c, const QString &fileName, int lineno);
|
---|
809 | int lex();
|
---|
810 |
|
---|
811 | QString fileName() const { return yyfilename; }
|
---|
812 | int currentLineNo() const { return yylineno; }
|
---|
813 | int currentColumnNo() const { return yycolumn; }
|
---|
814 |
|
---|
815 | int startLineNo() const { return startlineno; }
|
---|
816 | int startColumnNo() const { return startcolumn; }
|
---|
817 |
|
---|
818 | int endLineNo() const { return currentLineNo(); }
|
---|
819 | int endColumnNo() const
|
---|
820 | { int col = currentColumnNo(); return (col > 0) ? col - 1 : col; }
|
---|
821 |
|
---|
822 | bool prevTerminator() const { return terminator; }
|
---|
823 |
|
---|
824 | enum State { Start,
|
---|
825 | Identifier,
|
---|
826 | InIdentifier,
|
---|
827 | InSingleLineComment,
|
---|
828 | InMultiLineComment,
|
---|
829 | InNum,
|
---|
830 | InNum0,
|
---|
831 | InHex,
|
---|
832 | InOctal,
|
---|
833 | InDecimal,
|
---|
834 | InExponentIndicator,
|
---|
835 | InExponent,
|
---|
836 | Hex,
|
---|
837 | Octal,
|
---|
838 | Number,
|
---|
839 | String,
|
---|
840 | Eof,
|
---|
841 | InString,
|
---|
842 | InEscapeSequence,
|
---|
843 | InHexEscape,
|
---|
844 | InUnicodeEscape,
|
---|
845 | Other,
|
---|
846 | Bad };
|
---|
847 |
|
---|
848 | enum Error {
|
---|
849 | NoError,
|
---|
850 | IllegalCharacter,
|
---|
851 | UnclosedStringLiteral,
|
---|
852 | IllegalEscapeSequence,
|
---|
853 | IllegalUnicodeEscapeSequence,
|
---|
854 | UnclosedComment,
|
---|
855 | IllegalExponentIndicator,
|
---|
856 | IllegalIdentifier
|
---|
857 | };
|
---|
858 |
|
---|
859 | enum ParenthesesState {
|
---|
860 | IgnoreParentheses,
|
---|
861 | CountParentheses,
|
---|
862 | BalancedParentheses
|
---|
863 | };
|
---|
864 |
|
---|
865 | enum RegExpBodyPrefix {
|
---|
866 | NoPrefix,
|
---|
867 | EqualPrefix
|
---|
868 | };
|
---|
869 |
|
---|
870 | bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
|
---|
871 |
|
---|
872 | QString pattern;
|
---|
873 | int flags;
|
---|
874 |
|
---|
875 | State lexerState() const
|
---|
876 | { return state; }
|
---|
877 |
|
---|
878 | QString errorMessage() const
|
---|
879 | { return errmsg; }
|
---|
880 | void setErrorMessage(const QString &err)
|
---|
881 | { errmsg = err; }
|
---|
882 | void setErrorMessage(const char *err)
|
---|
883 | { setErrorMessage(QString::fromLatin1(err)); }
|
---|
884 |
|
---|
885 | Error error() const
|
---|
886 | { return err; }
|
---|
887 | void clearError()
|
---|
888 | { err = NoError; }
|
---|
889 |
|
---|
890 | private:
|
---|
891 | QString yyfilename;
|
---|
892 | int yylineno;
|
---|
893 | bool done;
|
---|
894 | char *buffer8;
|
---|
895 | QChar *buffer16;
|
---|
896 | uint size8, size16;
|
---|
897 | uint pos8, pos16;
|
---|
898 | bool terminator;
|
---|
899 | bool restrKeyword;
|
---|
900 | // encountered delimiter like "'" and "}" on last run
|
---|
901 | bool delimited;
|
---|
902 | int stackToken;
|
---|
903 |
|
---|
904 | State state;
|
---|
905 | void setDone(State s);
|
---|
906 | uint pos;
|
---|
907 | void shift(uint p);
|
---|
908 | int lookupKeyword(const char *);
|
---|
909 |
|
---|
910 | bool isWhiteSpace() const;
|
---|
911 | bool isLineTerminator() const;
|
---|
912 | bool isHexDigit(ushort c) const;
|
---|
913 | bool isOctalDigit(ushort c) const;
|
---|
914 |
|
---|
915 | int matchPunctuator(ushort c1, ushort c2,
|
---|
916 | ushort c3, ushort c4);
|
---|
917 | ushort singleEscape(ushort c) const;
|
---|
918 | ushort convertOctal(ushort c1, ushort c2,
|
---|
919 | ushort c3) const;
|
---|
920 | public:
|
---|
921 | static unsigned char convertHex(ushort c1);
|
---|
922 | static unsigned char convertHex(ushort c1, ushort c2);
|
---|
923 | static QChar convertUnicode(ushort c1, ushort c2,
|
---|
924 | ushort c3, ushort c4);
|
---|
925 | static bool isIdentLetter(ushort c);
|
---|
926 | static bool isDecimalDigit(ushort c);
|
---|
927 |
|
---|
928 | inline int ival() const { return qsyylval.toInt(); }
|
---|
929 | inline double dval() const { return qsyylval.toDouble(); }
|
---|
930 | inline QString ustr() const { return qsyylval.toString(); }
|
---|
931 | inline QVariant val() const { return qsyylval; }
|
---|
932 |
|
---|
933 | const QChar *characterBuffer() const { return buffer16; }
|
---|
934 | int characterCount() const { return pos16; }
|
---|
935 |
|
---|
936 | private:
|
---|
937 | void record8(ushort c);
|
---|
938 | void record16(QChar c);
|
---|
939 | void recordStartPos();
|
---|
940 |
|
---|
941 | int findReservedWord(const QChar *buffer, int size) const;
|
---|
942 |
|
---|
943 | void syncProhibitAutomaticSemicolon();
|
---|
944 |
|
---|
945 | void processComment(const QChar *, int);
|
---|
946 |
|
---|
947 | const QChar *code;
|
---|
948 | uint length;
|
---|
949 | int yycolumn;
|
---|
950 | int startlineno;
|
---|
951 | int startcolumn;
|
---|
952 | int bol; // begin of line
|
---|
953 |
|
---|
954 | QVariant qsyylval;
|
---|
955 |
|
---|
956 | // current and following unicode characters
|
---|
957 | ushort current, next1, next2, next3;
|
---|
958 |
|
---|
959 | struct keyword {
|
---|
960 | const char *name;
|
---|
961 | int token;
|
---|
962 | };
|
---|
963 |
|
---|
964 | QString errmsg;
|
---|
965 | Error err;
|
---|
966 |
|
---|
967 | bool wantRx;
|
---|
968 | bool check_reserved;
|
---|
969 |
|
---|
970 | ParenthesesState parenthesesState;
|
---|
971 | int parenthesesCount;
|
---|
972 | bool prohibitAutomaticSemicolon;
|
---|
973 |
|
---|
974 | CommentProcessor *commentProcessor;
|
---|
975 | };
|
---|
976 |
|
---|
977 | } // namespace QScript
|
---|
978 |
|
---|
979 | extern double qstrtod(const char *s00, char const **se, bool *ok);
|
---|
980 |
|
---|
981 | #define shiftWindowsLineBreak() if(current == '\r' && next1 == '\n') shift(1);
|
---|
982 |
|
---|
983 | namespace QScript {
|
---|
984 |
|
---|
985 | static int toDigit(char c)
|
---|
986 | {
|
---|
987 | if ((c >= '0') && (c <= '9'))
|
---|
988 | return c - '0';
|
---|
989 | else if ((c >= 'a') && (c <= 'z'))
|
---|
990 | return 10 + c - 'a';
|
---|
991 | else if ((c >= 'A') && (c <= 'Z'))
|
---|
992 | return 10 + c - 'A';
|
---|
993 | return -1;
|
---|
994 | }
|
---|
995 |
|
---|
996 | double integerFromString(const char *buf, int size, int radix)
|
---|
997 | {
|
---|
998 | if (size == 0)
|
---|
999 | return qSNaN();
|
---|
1000 |
|
---|
1001 | double sign = 1.0;
|
---|
1002 | int i = 0;
|
---|
1003 | if (buf[0] == '+') {
|
---|
1004 | ++i;
|
---|
1005 | } else if (buf[0] == '-') {
|
---|
1006 | sign = -1.0;
|
---|
1007 | ++i;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | if (((size-i) >= 2) && (buf[i] == '0')) {
|
---|
1011 | if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
|
---|
1012 | && (radix < 34)) {
|
---|
1013 | if ((radix != 0) && (radix != 16))
|
---|
1014 | return 0;
|
---|
1015 | radix = 16;
|
---|
1016 | i += 2;
|
---|
1017 | } else {
|
---|
1018 | if (radix == 0) {
|
---|
1019 | radix = 8;
|
---|
1020 | ++i;
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 | } else if (radix == 0) {
|
---|
1024 | radix = 10;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | int j = i;
|
---|
1028 | for ( ; i < size; ++i) {
|
---|
1029 | int d = toDigit(buf[i]);
|
---|
1030 | if ((d == -1) || (d >= radix))
|
---|
1031 | break;
|
---|
1032 | }
|
---|
1033 | double result;
|
---|
1034 | if (j == i) {
|
---|
1035 | if (!qstrcmp(buf, "Infinity"))
|
---|
1036 | result = qInf();
|
---|
1037 | else
|
---|
1038 | result = qSNaN();
|
---|
1039 | } else {
|
---|
1040 | result = 0;
|
---|
1041 | double multiplier = 1;
|
---|
1042 | for (--i ; i >= j; --i, multiplier *= radix)
|
---|
1043 | result += toDigit(buf[i]) * multiplier;
|
---|
1044 | }
|
---|
1045 | result *= sign;
|
---|
1046 | return result;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | } // namespace QScript
|
---|
1050 |
|
---|
1051 | QScript::Lexer::Lexer(QScript::CommentProcessor *proc)
|
---|
1052 | :
|
---|
1053 | yylineno(0),
|
---|
1054 | size8(128), size16(128), restrKeyword(false),
|
---|
1055 | stackToken(-1), pos(0),
|
---|
1056 | code(0), length(0),
|
---|
1057 | bol(true),
|
---|
1058 | current(0), next1(0), next2(0), next3(0),
|
---|
1059 | err(NoError),
|
---|
1060 | check_reserved(true),
|
---|
1061 | parenthesesState(IgnoreParentheses),
|
---|
1062 | prohibitAutomaticSemicolon(false),
|
---|
1063 | commentProcessor(proc)
|
---|
1064 | {
|
---|
1065 | // allocate space for read buffers
|
---|
1066 | buffer8 = new char[size8];
|
---|
1067 | buffer16 = new QChar[size16];
|
---|
1068 | flags = 0;
|
---|
1069 |
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | QScript::Lexer::~Lexer()
|
---|
1073 | {
|
---|
1074 | delete [] buffer8;
|
---|
1075 | delete [] buffer16;
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | void QScript::Lexer::setCode(const QString &c, const QString &fileName, int lineno)
|
---|
1079 | {
|
---|
1080 | errmsg = QString();
|
---|
1081 | yyfilename = fileName;
|
---|
1082 | yylineno = lineno;
|
---|
1083 | yycolumn = 1;
|
---|
1084 | restrKeyword = false;
|
---|
1085 | delimited = false;
|
---|
1086 | stackToken = -1;
|
---|
1087 | pos = 0;
|
---|
1088 | code = c.unicode();
|
---|
1089 | length = c.length();
|
---|
1090 | bol = true;
|
---|
1091 |
|
---|
1092 | // read first characters
|
---|
1093 | current = (length > 0) ? code[0].unicode() : 0;
|
---|
1094 | next1 = (length > 1) ? code[1].unicode() : 0;
|
---|
1095 | next2 = (length > 2) ? code[2].unicode() : 0;
|
---|
1096 | next3 = (length > 3) ? code[3].unicode() : 0;
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | void QScript::Lexer::shift(uint p)
|
---|
1100 | {
|
---|
1101 | while (p--) {
|
---|
1102 | ++pos;
|
---|
1103 | ++yycolumn;
|
---|
1104 | current = next1;
|
---|
1105 | next1 = next2;
|
---|
1106 | next2 = next3;
|
---|
1107 | next3 = (pos + 3 < length) ? code[pos+3].unicode() : 0;
|
---|
1108 | }
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | void QScript::Lexer::setDone(State s)
|
---|
1112 | {
|
---|
1113 | state = s;
|
---|
1114 | done = true;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | int QScript::Lexer::findReservedWord(const QChar *c, int size) const
|
---|
1118 | {
|
---|
1119 | switch (size) {
|
---|
1120 | case 2: {
|
---|
1121 | if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o'))
|
---|
1122 | return QScriptGrammar::T_DO;
|
---|
1123 | else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('f'))
|
---|
1124 | return QScriptGrammar::T_IF;
|
---|
1125 | else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n'))
|
---|
1126 | return QScriptGrammar::T_IN;
|
---|
1127 | } break;
|
---|
1128 |
|
---|
1129 | case 3: {
|
---|
1130 | if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('r'))
|
---|
1131 | return QScriptGrammar::T_FOR;
|
---|
1132 | else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('w'))
|
---|
1133 | return QScriptGrammar::T_NEW;
|
---|
1134 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('y'))
|
---|
1135 | return QScriptGrammar::T_TRY;
|
---|
1136 | else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('r'))
|
---|
1137 | return QScriptGrammar::T_VAR;
|
---|
1138 | else if (check_reserved) {
|
---|
1139 | if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('t'))
|
---|
1140 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1141 | }
|
---|
1142 | } break;
|
---|
1143 |
|
---|
1144 | case 4: {
|
---|
1145 | if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
|
---|
1146 | && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
|
---|
1147 | return QScriptGrammar::T_CASE;
|
---|
1148 | else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('l')
|
---|
1149 | && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e'))
|
---|
1150 | return QScriptGrammar::T_ELSE;
|
---|
1151 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
|
---|
1152 | && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('s'))
|
---|
1153 | return QScriptGrammar::T_THIS;
|
---|
1154 | else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
|
---|
1155 | && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('d'))
|
---|
1156 | return QScriptGrammar::T_VOID;
|
---|
1157 | else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('i')
|
---|
1158 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('h'))
|
---|
1159 | return QScriptGrammar::T_WITH;
|
---|
1160 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
|
---|
1161 | && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('e'))
|
---|
1162 | return QScriptGrammar::T_TRUE;
|
---|
1163 | else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('u')
|
---|
1164 | && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('l'))
|
---|
1165 | return QScriptGrammar::T_NULL;
|
---|
1166 | else if (check_reserved) {
|
---|
1167 | if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('n')
|
---|
1168 | && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('m'))
|
---|
1169 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1170 | else if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('y')
|
---|
1171 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e'))
|
---|
1172 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1173 | else if (c[0] == QLatin1Char('l') && c[1] == QLatin1Char('o')
|
---|
1174 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('g'))
|
---|
1175 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1176 | else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('h')
|
---|
1177 | && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('r'))
|
---|
1178 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1179 | else if (c[0] == QLatin1Char('g') && c[1] == QLatin1Char('o')
|
---|
1180 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('o'))
|
---|
1181 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1182 | }
|
---|
1183 | } break;
|
---|
1184 |
|
---|
1185 | case 5: {
|
---|
1186 | if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('r')
|
---|
1187 | && c[2] == QLatin1Char('e') && c[3] == QLatin1Char('a')
|
---|
1188 | && c[4] == QLatin1Char('k'))
|
---|
1189 | return QScriptGrammar::T_BREAK;
|
---|
1190 | else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a')
|
---|
1191 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('c')
|
---|
1192 | && c[4] == QLatin1Char('h'))
|
---|
1193 | return QScriptGrammar::T_CATCH;
|
---|
1194 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
|
---|
1195 | && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
|
---|
1196 | && c[4] == QLatin1Char('w'))
|
---|
1197 | return QScriptGrammar::T_THROW;
|
---|
1198 | else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('h')
|
---|
1199 | && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('l')
|
---|
1200 | && c[4] == QLatin1Char('e'))
|
---|
1201 | return QScriptGrammar::T_WHILE;
|
---|
1202 | else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
|
---|
1203 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('s')
|
---|
1204 | && c[4] == QLatin1Char('t'))
|
---|
1205 | return QScriptGrammar::T_CONST;
|
---|
1206 | else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('a')
|
---|
1207 | && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('s')
|
---|
1208 | && c[4] == QLatin1Char('e'))
|
---|
1209 | return QScriptGrammar::T_FALSE;
|
---|
1210 | else if (check_reserved) {
|
---|
1211 | if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('h')
|
---|
1212 | && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('r')
|
---|
1213 | && c[4] == QLatin1Char('t'))
|
---|
1214 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1215 | else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('u')
|
---|
1216 | && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
|
---|
1217 | && c[4] == QLatin1Char('r'))
|
---|
1218 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1219 | else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
|
---|
1220 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
|
---|
1221 | && c[4] == QLatin1Char('l'))
|
---|
1222 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1223 | else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('l')
|
---|
1224 | && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('s')
|
---|
1225 | && c[4] == QLatin1Char('s'))
|
---|
1226 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1227 | else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('l')
|
---|
1228 | && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('a')
|
---|
1229 | && c[4] == QLatin1Char('t'))
|
---|
1230 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1231 | }
|
---|
1232 | } break;
|
---|
1233 |
|
---|
1234 | case 6: {
|
---|
1235 | if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
|
---|
1236 | && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('e')
|
---|
1237 | && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('e'))
|
---|
1238 | return QScriptGrammar::T_DELETE;
|
---|
1239 | else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e')
|
---|
1240 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('u')
|
---|
1241 | && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('n'))
|
---|
1242 | return QScriptGrammar::T_RETURN;
|
---|
1243 | else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('w')
|
---|
1244 | && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('t')
|
---|
1245 | && c[4] == QLatin1Char('c') && c[5] == QLatin1Char('h'))
|
---|
1246 | return QScriptGrammar::T_SWITCH;
|
---|
1247 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('y')
|
---|
1248 | && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e')
|
---|
1249 | && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('f'))
|
---|
1250 | return QScriptGrammar::T_TYPEOF;
|
---|
1251 | else if (check_reserved) {
|
---|
1252 | if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
|
---|
1253 | && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
|
---|
1254 | && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
|
---|
1255 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1256 | else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('t')
|
---|
1257 | && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('t')
|
---|
1258 | && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
|
---|
1259 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1260 | else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o')
|
---|
1261 | && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('b')
|
---|
1262 | && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('e'))
|
---|
1263 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1264 | else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
|
---|
1265 | && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o')
|
---|
1266 | && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t'))
|
---|
1267 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1268 | else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('u')
|
---|
1269 | && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('l')
|
---|
1270 | && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c'))
|
---|
1271 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1272 | else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('a')
|
---|
1273 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('i')
|
---|
1274 | && c[4] == QLatin1Char('v') && c[5] == QLatin1Char('e'))
|
---|
1275 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1276 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h')
|
---|
1277 | && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o')
|
---|
1278 | && c[4] == QLatin1Char('w') && c[5] == QLatin1Char('s'))
|
---|
1279 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1280 | }
|
---|
1281 | } break;
|
---|
1282 |
|
---|
1283 | case 7: {
|
---|
1284 | if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
|
---|
1285 | && c[2] == QLatin1Char('f') && c[3] == QLatin1Char('a')
|
---|
1286 | && c[4] == QLatin1Char('u') && c[5] == QLatin1Char('l')
|
---|
1287 | && c[6] == QLatin1Char('t'))
|
---|
1288 | return QScriptGrammar::T_DEFAULT;
|
---|
1289 | else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i')
|
---|
1290 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a')
|
---|
1291 | && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('l')
|
---|
1292 | && c[6] == QLatin1Char('y'))
|
---|
1293 | return QScriptGrammar::T_FINALLY;
|
---|
1294 | else if (check_reserved) {
|
---|
1295 | if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('o')
|
---|
1296 | && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('l')
|
---|
1297 | && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('a')
|
---|
1298 | && c[6] == QLatin1Char('n'))
|
---|
1299 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1300 | else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x')
|
---|
1301 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
|
---|
1302 | && c[4] == QLatin1Char('n') && c[5] == QLatin1Char('d')
|
---|
1303 | && c[6] == QLatin1Char('s'))
|
---|
1304 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1305 | else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('a')
|
---|
1306 | && c[2] == QLatin1Char('c') && c[3] == QLatin1Char('k')
|
---|
1307 | && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('g')
|
---|
1308 | && c[6] == QLatin1Char('e'))
|
---|
1309 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1310 | else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
|
---|
1311 | && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('v')
|
---|
1312 | && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('t')
|
---|
1313 | && c[6] == QLatin1Char('e'))
|
---|
1314 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1315 | }
|
---|
1316 | } break;
|
---|
1317 |
|
---|
1318 | case 8: {
|
---|
1319 | if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o')
|
---|
1320 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('t')
|
---|
1321 | && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('n')
|
---|
1322 | && c[6] == QLatin1Char('u') && c[7] == QLatin1Char('e'))
|
---|
1323 | return QScriptGrammar::T_CONTINUE;
|
---|
1324 | else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('u')
|
---|
1325 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
|
---|
1326 | && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
|
---|
1327 | && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n'))
|
---|
1328 | return QScriptGrammar::T_FUNCTION;
|
---|
1329 | else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e')
|
---|
1330 | && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('u')
|
---|
1331 | && c[4] == QLatin1Char('g') && c[5] == QLatin1Char('g')
|
---|
1332 | && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('r'))
|
---|
1333 | return QScriptGrammar::T_DEBUGGER;
|
---|
1334 | else if (check_reserved) {
|
---|
1335 | if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('b')
|
---|
1336 | && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
|
---|
1337 | && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('a')
|
---|
1338 | && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('t'))
|
---|
1339 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1340 | else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o')
|
---|
1341 | && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('a')
|
---|
1342 | && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i')
|
---|
1343 | && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('e'))
|
---|
1344 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1345 | }
|
---|
1346 | } break;
|
---|
1347 |
|
---|
1348 | case 9: {
|
---|
1349 | if (check_reserved) {
|
---|
1350 | if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
|
---|
1351 | && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')
|
---|
1352 | && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('f')
|
---|
1353 | && c[6] == QLatin1Char('a') && c[7] == QLatin1Char('c')
|
---|
1354 | && c[8] == QLatin1Char('e'))
|
---|
1355 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1356 | else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r')
|
---|
1357 | && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('n')
|
---|
1358 | && c[4] == QLatin1Char('s') && c[5] == QLatin1Char('i')
|
---|
1359 | && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
|
---|
1360 | && c[8] == QLatin1Char('t'))
|
---|
1361 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1362 | else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r')
|
---|
1363 | && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('t')
|
---|
1364 | && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('c')
|
---|
1365 | && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('e')
|
---|
1366 | && c[8] == QLatin1Char('d'))
|
---|
1367 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1368 | }
|
---|
1369 | } break;
|
---|
1370 |
|
---|
1371 | case 10: {
|
---|
1372 | if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')
|
---|
1373 | && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t')
|
---|
1374 | && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('n')
|
---|
1375 | && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('e')
|
---|
1376 | && c[8] == QLatin1Char('o') && c[9] == QLatin1Char('f'))
|
---|
1377 | return QScriptGrammar::T_INSTANCEOF;
|
---|
1378 | else if (check_reserved) {
|
---|
1379 | if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m')
|
---|
1380 | && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('l')
|
---|
1381 | && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('m')
|
---|
1382 | && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n')
|
---|
1383 | && c[8] == QLatin1Char('t') && c[9] == QLatin1Char('s'))
|
---|
1384 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1385 | }
|
---|
1386 | } break;
|
---|
1387 |
|
---|
1388 | case 12: {
|
---|
1389 | if (check_reserved) {
|
---|
1390 | if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('y')
|
---|
1391 | && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c')
|
---|
1392 | && c[4] == QLatin1Char('h') && c[5] == QLatin1Char('r')
|
---|
1393 | && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n')
|
---|
1394 | && c[8] == QLatin1Char('i') && c[9] == QLatin1Char('z')
|
---|
1395 | && c[10] == QLatin1Char('e') && c[11] == QLatin1Char('d'))
|
---|
1396 | return QScriptGrammar::T_RESERVED_WORD;
|
---|
1397 | }
|
---|
1398 | } break;
|
---|
1399 |
|
---|
1400 | } // switch
|
---|
1401 |
|
---|
1402 | return -1;
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 | int QScript::Lexer::lex()
|
---|
1406 | {
|
---|
1407 | int token = 0;
|
---|
1408 | state = Start;
|
---|
1409 | ushort stringType = 0; // either single or double quotes
|
---|
1410 | pos8 = pos16 = 0;
|
---|
1411 | done = false;
|
---|
1412 | terminator = false;
|
---|
1413 |
|
---|
1414 | // did we push a token on the stack previously ?
|
---|
1415 | // (after an automatic semicolon insertion)
|
---|
1416 | if (stackToken >= 0) {
|
---|
1417 | setDone(Other);
|
---|
1418 | token = stackToken;
|
---|
1419 | stackToken = -1;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | while (!done) {
|
---|
1423 | switch (state) {
|
---|
1424 | case Start:
|
---|
1425 | if (isWhiteSpace()) {
|
---|
1426 | // do nothing
|
---|
1427 | } else if (current == '/' && next1 == '/') {
|
---|
1428 | recordStartPos();
|
---|
1429 | shift(1);
|
---|
1430 | Q_ASSERT(pos16 == 0);
|
---|
1431 | state = InSingleLineComment;
|
---|
1432 | } else if (current == '/' && next1 == '*') {
|
---|
1433 | recordStartPos();
|
---|
1434 | shift(1);
|
---|
1435 | Q_ASSERT(pos16 == 0);
|
---|
1436 | state = InMultiLineComment;
|
---|
1437 | } else if (current == 0) {
|
---|
1438 | syncProhibitAutomaticSemicolon();
|
---|
1439 | if (!terminator && !delimited && !prohibitAutomaticSemicolon) {
|
---|
1440 | // automatic semicolon insertion if program incomplete
|
---|
1441 | token = QScriptGrammar::T_SEMICOLON;
|
---|
1442 | stackToken = 0;
|
---|
1443 | setDone(Other);
|
---|
1444 | } else {
|
---|
1445 | setDone(Eof);
|
---|
1446 | }
|
---|
1447 | } else if (isLineTerminator()) {
|
---|
1448 | shiftWindowsLineBreak();
|
---|
1449 | yylineno++;
|
---|
1450 | yycolumn = 0;
|
---|
1451 | bol = true;
|
---|
1452 | terminator = true;
|
---|
1453 | syncProhibitAutomaticSemicolon();
|
---|
1454 | if (restrKeyword) {
|
---|
1455 | token = QScriptGrammar::T_SEMICOLON;
|
---|
1456 | setDone(Other);
|
---|
1457 | }
|
---|
1458 | } else if (current == '"' || current == '\'') {
|
---|
1459 | recordStartPos();
|
---|
1460 | state = InString;
|
---|
1461 | stringType = current;
|
---|
1462 | } else if (isIdentLetter(current)) {
|
---|
1463 | recordStartPos();
|
---|
1464 | record16(current);
|
---|
1465 | state = InIdentifier;
|
---|
1466 | } else if (current == '0') {
|
---|
1467 | recordStartPos();
|
---|
1468 | record8(current);
|
---|
1469 | state = InNum0;
|
---|
1470 | } else if (isDecimalDigit(current)) {
|
---|
1471 | recordStartPos();
|
---|
1472 | record8(current);
|
---|
1473 | state = InNum;
|
---|
1474 | } else if (current == '.' && isDecimalDigit(next1)) {
|
---|
1475 | recordStartPos();
|
---|
1476 | record8(current);
|
---|
1477 | state = InDecimal;
|
---|
1478 | } else {
|
---|
1479 | recordStartPos();
|
---|
1480 | token = matchPunctuator(current, next1, next2, next3);
|
---|
1481 | if (token != -1) {
|
---|
1482 | if (terminator && !delimited && !prohibitAutomaticSemicolon
|
---|
1483 | && (token == QScriptGrammar::T_PLUS_PLUS
|
---|
1484 | || token == QScriptGrammar::T_MINUS_MINUS)) {
|
---|
1485 | // automatic semicolon insertion
|
---|
1486 | stackToken = token;
|
---|
1487 | token = QScriptGrammar::T_SEMICOLON;
|
---|
1488 | }
|
---|
1489 | setDone(Other);
|
---|
1490 | }
|
---|
1491 | else {
|
---|
1492 | setDone(Bad);
|
---|
1493 | err = IllegalCharacter;
|
---|
1494 | errmsg = LU::tr("Illegal character");
|
---|
1495 | }
|
---|
1496 | }
|
---|
1497 | break;
|
---|
1498 | case InString:
|
---|
1499 | if (current == stringType) {
|
---|
1500 | shift(1);
|
---|
1501 | setDone(String);
|
---|
1502 | } else if (current == 0 || isLineTerminator()) {
|
---|
1503 | setDone(Bad);
|
---|
1504 | err = UnclosedStringLiteral;
|
---|
1505 | errmsg = LU::tr("Unclosed string at end of line");
|
---|
1506 | } else if (current == '\\') {
|
---|
1507 | state = InEscapeSequence;
|
---|
1508 | } else {
|
---|
1509 | record16(current);
|
---|
1510 | }
|
---|
1511 | break;
|
---|
1512 | // Escape Sequences inside of strings
|
---|
1513 | case InEscapeSequence:
|
---|
1514 | if (isOctalDigit(current)) {
|
---|
1515 | if (current >= '0' && current <= '3' &&
|
---|
1516 | isOctalDigit(next1) && isOctalDigit(next2)) {
|
---|
1517 | record16(convertOctal(current, next1, next2));
|
---|
1518 | shift(2);
|
---|
1519 | state = InString;
|
---|
1520 | } else if (isOctalDigit(current) &&
|
---|
1521 | isOctalDigit(next1)) {
|
---|
1522 | record16(convertOctal('0', current, next1));
|
---|
1523 | shift(1);
|
---|
1524 | state = InString;
|
---|
1525 | } else if (isOctalDigit(current)) {
|
---|
1526 | record16(convertOctal('0', '0', current));
|
---|
1527 | state = InString;
|
---|
1528 | } else {
|
---|
1529 | setDone(Bad);
|
---|
1530 | err = IllegalEscapeSequence;
|
---|
1531 | errmsg = LU::tr("Illegal escape squence");
|
---|
1532 | }
|
---|
1533 | } else if (current == 'x')
|
---|
1534 | state = InHexEscape;
|
---|
1535 | else if (current == 'u')
|
---|
1536 | state = InUnicodeEscape;
|
---|
1537 | else {
|
---|
1538 | record16(singleEscape(current));
|
---|
1539 | state = InString;
|
---|
1540 | }
|
---|
1541 | break;
|
---|
1542 | case InHexEscape:
|
---|
1543 | if (isHexDigit(current) && isHexDigit(next1)) {
|
---|
1544 | state = InString;
|
---|
1545 | record16(QLatin1Char(convertHex(current, next1)));
|
---|
1546 | shift(1);
|
---|
1547 | } else if (current == stringType) {
|
---|
1548 | record16(QLatin1Char('x'));
|
---|
1549 | shift(1);
|
---|
1550 | setDone(String);
|
---|
1551 | } else {
|
---|
1552 | record16(QLatin1Char('x'));
|
---|
1553 | record16(current);
|
---|
1554 | state = InString;
|
---|
1555 | }
|
---|
1556 | break;
|
---|
1557 | case InUnicodeEscape:
|
---|
1558 | if (isHexDigit(current) && isHexDigit(next1) &&
|
---|
1559 | isHexDigit(next2) && isHexDigit(next3)) {
|
---|
1560 | record16(convertUnicode(current, next1, next2, next3));
|
---|
1561 | shift(3);
|
---|
1562 | state = InString;
|
---|
1563 | } else if (current == stringType) {
|
---|
1564 | record16(QLatin1Char('u'));
|
---|
1565 | shift(1);
|
---|
1566 | setDone(String);
|
---|
1567 | } else {
|
---|
1568 | setDone(Bad);
|
---|
1569 | err = IllegalUnicodeEscapeSequence;
|
---|
1570 | errmsg = LU::tr("Illegal unicode escape sequence");
|
---|
1571 | }
|
---|
1572 | break;
|
---|
1573 | case InSingleLineComment:
|
---|
1574 | if (isLineTerminator()) {
|
---|
1575 | record16(current); // include newline
|
---|
1576 | processComment(buffer16, pos16);
|
---|
1577 | shiftWindowsLineBreak();
|
---|
1578 | yylineno++;
|
---|
1579 | yycolumn = 0;
|
---|
1580 | pos16 = 0;
|
---|
1581 | terminator = true;
|
---|
1582 | bol = true;
|
---|
1583 | if (restrKeyword) {
|
---|
1584 | token = QScriptGrammar::T_SEMICOLON;
|
---|
1585 | setDone(Other);
|
---|
1586 | } else
|
---|
1587 | state = Start;
|
---|
1588 | } else if (current == 0) {
|
---|
1589 | setDone(Eof);
|
---|
1590 | } else {
|
---|
1591 | record16(current);
|
---|
1592 | }
|
---|
1593 | break;
|
---|
1594 | case InMultiLineComment:
|
---|
1595 | if (current == 0) {
|
---|
1596 | setDone(Bad);
|
---|
1597 | err = UnclosedComment;
|
---|
1598 | errmsg = LU::tr("Unclosed comment at end of file");
|
---|
1599 | } else if (isLineTerminator()) {
|
---|
1600 | shiftWindowsLineBreak();
|
---|
1601 | yylineno++;
|
---|
1602 | } else if (current == '*' && next1 == '/') {
|
---|
1603 | processComment(buffer16, pos16);
|
---|
1604 | pos16 = 0;
|
---|
1605 | state = Start;
|
---|
1606 | shift(1);
|
---|
1607 | } else {
|
---|
1608 | record16(current);
|
---|
1609 | }
|
---|
1610 | break;
|
---|
1611 | case InIdentifier:
|
---|
1612 | if (isIdentLetter(current) || isDecimalDigit(current)) {
|
---|
1613 | record16(current);
|
---|
1614 | break;
|
---|
1615 | }
|
---|
1616 | setDone(Identifier);
|
---|
1617 | break;
|
---|
1618 | case InNum0:
|
---|
1619 | if (current == 'x' || current == 'X') {
|
---|
1620 | record8(current);
|
---|
1621 | state = InHex;
|
---|
1622 | } else if (current == '.') {
|
---|
1623 | record8(current);
|
---|
1624 | state = InDecimal;
|
---|
1625 | } else if (current == 'e' || current == 'E') {
|
---|
1626 | record8(current);
|
---|
1627 | state = InExponentIndicator;
|
---|
1628 | } else if (isOctalDigit(current)) {
|
---|
1629 | record8(current);
|
---|
1630 | state = InOctal;
|
---|
1631 | } else if (isDecimalDigit(current)) {
|
---|
1632 | record8(current);
|
---|
1633 | state = InDecimal;
|
---|
1634 | } else {
|
---|
1635 | setDone(Number);
|
---|
1636 | }
|
---|
1637 | break;
|
---|
1638 | case InHex:
|
---|
1639 | if (isHexDigit(current))
|
---|
1640 | record8(current);
|
---|
1641 | else
|
---|
1642 | setDone(Hex);
|
---|
1643 | break;
|
---|
1644 | case InOctal:
|
---|
1645 | if (isOctalDigit(current)) {
|
---|
1646 | record8(current);
|
---|
1647 | } else if (isDecimalDigit(current)) {
|
---|
1648 | record8(current);
|
---|
1649 | state = InDecimal;
|
---|
1650 | } else {
|
---|
1651 | setDone(Octal);
|
---|
1652 | }
|
---|
1653 | break;
|
---|
1654 | case InNum:
|
---|
1655 | if (isDecimalDigit(current)) {
|
---|
1656 | record8(current);
|
---|
1657 | } else if (current == '.') {
|
---|
1658 | record8(current);
|
---|
1659 | state = InDecimal;
|
---|
1660 | } else if (current == 'e' || current == 'E') {
|
---|
1661 | record8(current);
|
---|
1662 | state = InExponentIndicator;
|
---|
1663 | } else {
|
---|
1664 | setDone(Number);
|
---|
1665 | }
|
---|
1666 | break;
|
---|
1667 | case InDecimal:
|
---|
1668 | if (isDecimalDigit(current)) {
|
---|
1669 | record8(current);
|
---|
1670 | } else if (current == 'e' || current == 'E') {
|
---|
1671 | record8(current);
|
---|
1672 | state = InExponentIndicator;
|
---|
1673 | } else {
|
---|
1674 | setDone(Number);
|
---|
1675 | }
|
---|
1676 | break;
|
---|
1677 | case InExponentIndicator:
|
---|
1678 | if (current == '+' || current == '-') {
|
---|
1679 | record8(current);
|
---|
1680 | } else if (isDecimalDigit(current)) {
|
---|
1681 | record8(current);
|
---|
1682 | state = InExponent;
|
---|
1683 | } else {
|
---|
1684 | setDone(Bad);
|
---|
1685 | err = IllegalExponentIndicator;
|
---|
1686 | errmsg = LU::tr("Illegal syntax for exponential number");
|
---|
1687 | }
|
---|
1688 | break;
|
---|
1689 | case InExponent:
|
---|
1690 | if (isDecimalDigit(current)) {
|
---|
1691 | record8(current);
|
---|
1692 | } else {
|
---|
1693 | setDone(Number);
|
---|
1694 | }
|
---|
1695 | break;
|
---|
1696 | default:
|
---|
1697 | Q_ASSERT_X(0, "Lexer::lex", "Unhandled state in switch statement");
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | // move on to the next character
|
---|
1701 | if (!done)
|
---|
1702 | shift(1);
|
---|
1703 | if (state != Start && state != InSingleLineComment)
|
---|
1704 | bol = false;
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 | // no identifiers allowed directly after numeric literal, e.g. "3in" is bad
|
---|
1708 | if ((state == Number || state == Octal || state == Hex)
|
---|
1709 | && isIdentLetter(current)) {
|
---|
1710 | state = Bad;
|
---|
1711 | err = IllegalIdentifier;
|
---|
1712 | errmsg = LU::tr("Identifier cannot start with numeric literal");
|
---|
1713 | }
|
---|
1714 |
|
---|
1715 | // terminate string
|
---|
1716 | buffer8[pos8] = '\0';
|
---|
1717 |
|
---|
1718 | double dval = 0;
|
---|
1719 | if (state == Number) {
|
---|
1720 | dval = qstrtod(buffer8, 0, 0);
|
---|
1721 | } else if (state == Hex) { // scan hex numbers
|
---|
1722 | dval = QScript::integerFromString(buffer8, pos8, 16);
|
---|
1723 | state = Number;
|
---|
1724 | } else if (state == Octal) { // scan octal number
|
---|
1725 | dval = QScript::integerFromString(buffer8, pos8, 8);
|
---|
1726 | state = Number;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | restrKeyword = false;
|
---|
1730 | delimited = false;
|
---|
1731 |
|
---|
1732 | switch (parenthesesState) {
|
---|
1733 | case IgnoreParentheses:
|
---|
1734 | break;
|
---|
1735 | case CountParentheses:
|
---|
1736 | if (token == QScriptGrammar::T_RPAREN) {
|
---|
1737 | --parenthesesCount;
|
---|
1738 | if (parenthesesCount == 0)
|
---|
1739 | parenthesesState = BalancedParentheses;
|
---|
1740 | } else if (token == QScriptGrammar::T_LPAREN) {
|
---|
1741 | ++parenthesesCount;
|
---|
1742 | }
|
---|
1743 | break;
|
---|
1744 | case BalancedParentheses:
|
---|
1745 | parenthesesState = IgnoreParentheses;
|
---|
1746 | break;
|
---|
1747 | }
|
---|
1748 |
|
---|
1749 | switch (state) {
|
---|
1750 | case Eof:
|
---|
1751 | return 0;
|
---|
1752 | case Other:
|
---|
1753 | if(token == QScriptGrammar::T_RBRACE || token == QScriptGrammar::T_SEMICOLON)
|
---|
1754 | delimited = true;
|
---|
1755 | return token;
|
---|
1756 | case Identifier:
|
---|
1757 | if ((token = findReservedWord(buffer16, pos16)) < 0) {
|
---|
1758 | /* TODO: close leak on parse error. same holds true for String */
|
---|
1759 | qsyylval = QString(buffer16, pos16);
|
---|
1760 | return QScriptGrammar::T_IDENTIFIER;
|
---|
1761 | }
|
---|
1762 | if (token == QScriptGrammar::T_CONTINUE || token == QScriptGrammar::T_BREAK
|
---|
1763 | || token == QScriptGrammar::T_RETURN || token == QScriptGrammar::T_THROW) {
|
---|
1764 | restrKeyword = true;
|
---|
1765 | } else if (token == QScriptGrammar::T_IF || token == QScriptGrammar::T_FOR
|
---|
1766 | || token == QScriptGrammar::T_WHILE || token == QScriptGrammar::T_WITH) {
|
---|
1767 | parenthesesState = CountParentheses;
|
---|
1768 | parenthesesCount = 0;
|
---|
1769 | } else if (token == QScriptGrammar::T_DO) {
|
---|
1770 | parenthesesState = BalancedParentheses;
|
---|
1771 | }
|
---|
1772 | return token;
|
---|
1773 | case String:
|
---|
1774 | qsyylval = QString(buffer16, pos16);
|
---|
1775 | return QScriptGrammar::T_STRING_LITERAL;
|
---|
1776 | case Number:
|
---|
1777 | qsyylval = dval;
|
---|
1778 | return QScriptGrammar::T_NUMERIC_LITERAL;
|
---|
1779 | case Bad:
|
---|
1780 | return -1;
|
---|
1781 | default:
|
---|
1782 | Q_ASSERT(!"unhandled numeration value in switch");
|
---|
1783 | return -1;
|
---|
1784 | }
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | bool QScript::Lexer::isWhiteSpace() const
|
---|
1788 | {
|
---|
1789 | return (current == ' ' || current == '\t' ||
|
---|
1790 | current == 0x0b || current == 0x0c);
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | bool QScript::Lexer::isLineTerminator() const
|
---|
1794 | {
|
---|
1795 | return (current == '\n' || current == '\r');
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 | bool QScript::Lexer::isIdentLetter(ushort c)
|
---|
1799 | {
|
---|
1800 | /* TODO: allow other legitimate unicode chars */
|
---|
1801 | return ((c >= 'a' && c <= 'z')
|
---|
1802 | || (c >= 'A' && c <= 'Z')
|
---|
1803 | || c == '$'
|
---|
1804 | || c == '_');
|
---|
1805 | }
|
---|
1806 |
|
---|
1807 | bool QScript::Lexer::isDecimalDigit(ushort c)
|
---|
1808 | {
|
---|
1809 | return (c >= '0' && c <= '9');
|
---|
1810 | }
|
---|
1811 |
|
---|
1812 | bool QScript::Lexer::isHexDigit(ushort c) const
|
---|
1813 | {
|
---|
1814 | return ((c >= '0' && c <= '9')
|
---|
1815 | || (c >= 'a' && c <= 'f')
|
---|
1816 | || (c >= 'A' && c <= 'F'));
|
---|
1817 | }
|
---|
1818 |
|
---|
1819 | bool QScript::Lexer::isOctalDigit(ushort c) const
|
---|
1820 | {
|
---|
1821 | return (c >= '0' && c <= '7');
|
---|
1822 | }
|
---|
1823 |
|
---|
1824 | int QScript::Lexer::matchPunctuator(ushort c1, ushort c2,
|
---|
1825 | ushort c3, ushort c4)
|
---|
1826 | {
|
---|
1827 | if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
|
---|
1828 | shift(4);
|
---|
1829 | return QScriptGrammar::T_GT_GT_GT_EQ;
|
---|
1830 | } else if (c1 == '=' && c2 == '=' && c3 == '=') {
|
---|
1831 | shift(3);
|
---|
1832 | return QScriptGrammar::T_EQ_EQ_EQ;
|
---|
1833 | } else if (c1 == '!' && c2 == '=' && c3 == '=') {
|
---|
1834 | shift(3);
|
---|
1835 | return QScriptGrammar::T_NOT_EQ_EQ;
|
---|
1836 | } else if (c1 == '>' && c2 == '>' && c3 == '>') {
|
---|
1837 | shift(3);
|
---|
1838 | return QScriptGrammar::T_GT_GT_GT;
|
---|
1839 | } else if (c1 == '<' && c2 == '<' && c3 == '=') {
|
---|
1840 | shift(3);
|
---|
1841 | return QScriptGrammar::T_LT_LT_EQ;
|
---|
1842 | } else if (c1 == '>' && c2 == '>' && c3 == '=') {
|
---|
1843 | shift(3);
|
---|
1844 | return QScriptGrammar::T_GT_GT_EQ;
|
---|
1845 | } else if (c1 == '<' && c2 == '=') {
|
---|
1846 | shift(2);
|
---|
1847 | return QScriptGrammar::T_LE;
|
---|
1848 | } else if (c1 == '>' && c2 == '=') {
|
---|
1849 | shift(2);
|
---|
1850 | return QScriptGrammar::T_GE;
|
---|
1851 | } else if (c1 == '!' && c2 == '=') {
|
---|
1852 | shift(2);
|
---|
1853 | return QScriptGrammar::T_NOT_EQ;
|
---|
1854 | } else if (c1 == '+' && c2 == '+') {
|
---|
1855 | shift(2);
|
---|
1856 | return QScriptGrammar::T_PLUS_PLUS;
|
---|
1857 | } else if (c1 == '-' && c2 == '-') {
|
---|
1858 | shift(2);
|
---|
1859 | return QScriptGrammar::T_MINUS_MINUS;
|
---|
1860 | } else if (c1 == '=' && c2 == '=') {
|
---|
1861 | shift(2);
|
---|
1862 | return QScriptGrammar::T_EQ_EQ;
|
---|
1863 | } else if (c1 == '+' && c2 == '=') {
|
---|
1864 | shift(2);
|
---|
1865 | return QScriptGrammar::T_PLUS_EQ;
|
---|
1866 | } else if (c1 == '-' && c2 == '=') {
|
---|
1867 | shift(2);
|
---|
1868 | return QScriptGrammar::T_MINUS_EQ;
|
---|
1869 | } else if (c1 == '*' && c2 == '=') {
|
---|
1870 | shift(2);
|
---|
1871 | return QScriptGrammar::T_STAR_EQ;
|
---|
1872 | } else if (c1 == '/' && c2 == '=') {
|
---|
1873 | shift(2);
|
---|
1874 | return QScriptGrammar::T_DIVIDE_EQ;
|
---|
1875 | } else if (c1 == '&' && c2 == '=') {
|
---|
1876 | shift(2);
|
---|
1877 | return QScriptGrammar::T_AND_EQ;
|
---|
1878 | } else if (c1 == '^' && c2 == '=') {
|
---|
1879 | shift(2);
|
---|
1880 | return QScriptGrammar::T_XOR_EQ;
|
---|
1881 | } else if (c1 == '%' && c2 == '=') {
|
---|
1882 | shift(2);
|
---|
1883 | return QScriptGrammar::T_REMAINDER_EQ;
|
---|
1884 | } else if (c1 == '|' && c2 == '=') {
|
---|
1885 | shift(2);
|
---|
1886 | return QScriptGrammar::T_OR_EQ;
|
---|
1887 | } else if (c1 == '<' && c2 == '<') {
|
---|
1888 | shift(2);
|
---|
1889 | return QScriptGrammar::T_LT_LT;
|
---|
1890 | } else if (c1 == '>' && c2 == '>') {
|
---|
1891 | shift(2);
|
---|
1892 | return QScriptGrammar::T_GT_GT;
|
---|
1893 | } else if (c1 == '&' && c2 == '&') {
|
---|
1894 | shift(2);
|
---|
1895 | return QScriptGrammar::T_AND_AND;
|
---|
1896 | } else if (c1 == '|' && c2 == '|') {
|
---|
1897 | shift(2);
|
---|
1898 | return QScriptGrammar::T_OR_OR;
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | switch(c1) {
|
---|
1902 | case '=': shift(1); return QScriptGrammar::T_EQ;
|
---|
1903 | case '>': shift(1); return QScriptGrammar::T_GT;
|
---|
1904 | case '<': shift(1); return QScriptGrammar::T_LT;
|
---|
1905 | case ',': shift(1); return QScriptGrammar::T_COMMA;
|
---|
1906 | case '!': shift(1); return QScriptGrammar::T_NOT;
|
---|
1907 | case '~': shift(1); return QScriptGrammar::T_TILDE;
|
---|
1908 | case '?': shift(1); return QScriptGrammar::T_QUESTION;
|
---|
1909 | case ':': shift(1); return QScriptGrammar::T_COLON;
|
---|
1910 | case '.': shift(1); return QScriptGrammar::T_DOT;
|
---|
1911 | case '+': shift(1); return QScriptGrammar::T_PLUS;
|
---|
1912 | case '-': shift(1); return QScriptGrammar::T_MINUS;
|
---|
1913 | case '*': shift(1); return QScriptGrammar::T_STAR;
|
---|
1914 | case '/': shift(1); return QScriptGrammar::T_DIVIDE_;
|
---|
1915 | case '&': shift(1); return QScriptGrammar::T_AND;
|
---|
1916 | case '|': shift(1); return QScriptGrammar::T_OR;
|
---|
1917 | case '^': shift(1); return QScriptGrammar::T_XOR;
|
---|
1918 | case '%': shift(1); return QScriptGrammar::T_REMAINDER;
|
---|
1919 | case '(': shift(1); return QScriptGrammar::T_LPAREN;
|
---|
1920 | case ')': shift(1); return QScriptGrammar::T_RPAREN;
|
---|
1921 | case '{': shift(1); return QScriptGrammar::T_LBRACE;
|
---|
1922 | case '}': shift(1); return QScriptGrammar::T_RBRACE;
|
---|
1923 | case '[': shift(1); return QScriptGrammar::T_LBRACKET;
|
---|
1924 | case ']': shift(1); return QScriptGrammar::T_RBRACKET;
|
---|
1925 | case ';': shift(1); return QScriptGrammar::T_SEMICOLON;
|
---|
1926 |
|
---|
1927 | default: return -1;
|
---|
1928 | }
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 | ushort QScript::Lexer::singleEscape(ushort c) const
|
---|
1932 | {
|
---|
1933 | switch(c) {
|
---|
1934 | case 'b':
|
---|
1935 | return 0x08;
|
---|
1936 | case 't':
|
---|
1937 | return 0x09;
|
---|
1938 | case 'n':
|
---|
1939 | return 0x0A;
|
---|
1940 | case 'v':
|
---|
1941 | return 0x0B;
|
---|
1942 | case 'f':
|
---|
1943 | return 0x0C;
|
---|
1944 | case 'r':
|
---|
1945 | return 0x0D;
|
---|
1946 | case '"':
|
---|
1947 | return 0x22;
|
---|
1948 | case '\'':
|
---|
1949 | return 0x27;
|
---|
1950 | case '\\':
|
---|
1951 | return 0x5C;
|
---|
1952 | default:
|
---|
1953 | return c;
|
---|
1954 | }
|
---|
1955 | }
|
---|
1956 |
|
---|
1957 | ushort QScript::Lexer::convertOctal(ushort c1, ushort c2,
|
---|
1958 | ushort c3) const
|
---|
1959 | {
|
---|
1960 | return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0');
|
---|
1961 | }
|
---|
1962 |
|
---|
1963 | unsigned char QScript::Lexer::convertHex(ushort c)
|
---|
1964 | {
|
---|
1965 | if (c >= '0' && c <= '9')
|
---|
1966 | return (c - '0');
|
---|
1967 | else if (c >= 'a' && c <= 'f')
|
---|
1968 | return (c - 'a' + 10);
|
---|
1969 | else
|
---|
1970 | return (c - 'A' + 10);
|
---|
1971 | }
|
---|
1972 |
|
---|
1973 | unsigned char QScript::Lexer::convertHex(ushort c1, ushort c2)
|
---|
1974 | {
|
---|
1975 | return ((convertHex(c1) << 4) + convertHex(c2));
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | QChar QScript::Lexer::convertUnicode(ushort c1, ushort c2,
|
---|
1979 | ushort c3, ushort c4)
|
---|
1980 | {
|
---|
1981 | return QChar((convertHex(c3) << 4) + convertHex(c4),
|
---|
1982 | (convertHex(c1) << 4) + convertHex(c2));
|
---|
1983 | }
|
---|
1984 |
|
---|
1985 | void QScript::Lexer::record8(ushort c)
|
---|
1986 | {
|
---|
1987 | Q_ASSERT(c <= 0xff);
|
---|
1988 |
|
---|
1989 | // enlarge buffer if full
|
---|
1990 | if (pos8 >= size8 - 1) {
|
---|
1991 | char *tmp = new char[2 * size8];
|
---|
1992 | memcpy(tmp, buffer8, size8 * sizeof(char));
|
---|
1993 | delete [] buffer8;
|
---|
1994 | buffer8 = tmp;
|
---|
1995 | size8 *= 2;
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 | buffer8[pos8++] = (char) c;
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 | void QScript::Lexer::record16(QChar c)
|
---|
2002 | {
|
---|
2003 | // enlarge buffer if full
|
---|
2004 | if (pos16 >= size16 - 1) {
|
---|
2005 | QChar *tmp = new QChar[2 * size16];
|
---|
2006 | memcpy(tmp, buffer16, size16 * sizeof(QChar));
|
---|
2007 | delete [] buffer16;
|
---|
2008 | buffer16 = tmp;
|
---|
2009 | size16 *= 2;
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | buffer16[pos16++] = c;
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | void QScript::Lexer::recordStartPos()
|
---|
2016 | {
|
---|
2017 | startlineno = yylineno;
|
---|
2018 | startcolumn = yycolumn;
|
---|
2019 | }
|
---|
2020 |
|
---|
2021 | bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix)
|
---|
2022 | {
|
---|
2023 | pos16 = 0;
|
---|
2024 | bool lastWasEscape = false;
|
---|
2025 |
|
---|
2026 | if (prefix == EqualPrefix)
|
---|
2027 | record16(QLatin1Char('='));
|
---|
2028 |
|
---|
2029 | while (1) {
|
---|
2030 | if (isLineTerminator() || current == 0) {
|
---|
2031 | errmsg = LU::tr("Unterminated regular expression literal");
|
---|
2032 | return false;
|
---|
2033 | }
|
---|
2034 | else if (current != '/' || lastWasEscape == true)
|
---|
2035 | {
|
---|
2036 | record16(current);
|
---|
2037 | lastWasEscape = !lastWasEscape && (current == '\\');
|
---|
2038 | }
|
---|
2039 | else {
|
---|
2040 | pattern = QString(buffer16, pos16);
|
---|
2041 | pos16 = 0;
|
---|
2042 | shift(1);
|
---|
2043 | break;
|
---|
2044 | }
|
---|
2045 | shift(1);
|
---|
2046 | }
|
---|
2047 |
|
---|
2048 | flags = 0;
|
---|
2049 | while (isIdentLetter(current)) {
|
---|
2050 | record16(current);
|
---|
2051 | shift(1);
|
---|
2052 | }
|
---|
2053 |
|
---|
2054 | return true;
|
---|
2055 | }
|
---|
2056 |
|
---|
2057 | void QScript::Lexer::syncProhibitAutomaticSemicolon()
|
---|
2058 | {
|
---|
2059 | if (parenthesesState == BalancedParentheses) {
|
---|
2060 | // we have seen something like "if (foo)", which means we should
|
---|
2061 | // never insert an automatic semicolon at this point, since it would
|
---|
2062 | // then be expanded into an empty statement (ECMA-262 7.9.1)
|
---|
2063 | prohibitAutomaticSemicolon = true;
|
---|
2064 | parenthesesState = IgnoreParentheses;
|
---|
2065 | } else {
|
---|
2066 | prohibitAutomaticSemicolon = false;
|
---|
2067 | }
|
---|
2068 | }
|
---|
2069 |
|
---|
2070 | void QScript::Lexer::processComment(const QChar *chars, int length)
|
---|
2071 | {
|
---|
2072 | commentProcessor->processComment(chars, length);
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 |
|
---|
2076 | class Translator;
|
---|
2077 |
|
---|
2078 | class QScriptParser: protected QScriptGrammar, public QScript::CommentProcessor
|
---|
2079 | {
|
---|
2080 | public:
|
---|
2081 | QVariant val;
|
---|
2082 |
|
---|
2083 | struct Location {
|
---|
2084 | int startLine;
|
---|
2085 | int startColumn;
|
---|
2086 | int endLine;
|
---|
2087 | int endColumn;
|
---|
2088 | };
|
---|
2089 |
|
---|
2090 | public:
|
---|
2091 | QScriptParser();
|
---|
2092 | ~QScriptParser();
|
---|
2093 |
|
---|
2094 | void setLexer(QScript::Lexer *);
|
---|
2095 |
|
---|
2096 | bool parse(Translator *translator);
|
---|
2097 |
|
---|
2098 | QString fileName() const
|
---|
2099 | { return lexer->fileName(); }
|
---|
2100 | inline QString errorMessage() const
|
---|
2101 | { return error_message; }
|
---|
2102 | inline int errorLineNumber() const
|
---|
2103 | { return error_lineno; }
|
---|
2104 | inline int errorColumnNumber() const
|
---|
2105 | { return error_column; }
|
---|
2106 |
|
---|
2107 | protected:
|
---|
2108 | inline void reallocateStack();
|
---|
2109 |
|
---|
2110 | inline QVariant &sym(int index)
|
---|
2111 | { return sym_stack [tos + index - 1]; }
|
---|
2112 |
|
---|
2113 | inline Location &loc(int index)
|
---|
2114 | { return location_stack [tos + index - 2]; }
|
---|
2115 |
|
---|
2116 | std::ostream &yyMsg(int line = 0);
|
---|
2117 |
|
---|
2118 | virtual void processComment(const QChar *, int);
|
---|
2119 |
|
---|
2120 | protected:
|
---|
2121 | int tos;
|
---|
2122 | int stack_size;
|
---|
2123 | QVector<QVariant> sym_stack;
|
---|
2124 | int *state_stack;
|
---|
2125 | Location *location_stack;
|
---|
2126 | QString error_message;
|
---|
2127 | int error_lineno;
|
---|
2128 | int error_column;
|
---|
2129 |
|
---|
2130 | private:
|
---|
2131 | QScript::Lexer *lexer;
|
---|
2132 | QString extracomment;
|
---|
2133 | QString msgid;
|
---|
2134 | QString sourcetext;
|
---|
2135 | TranslatorMessage::ExtraData extra;
|
---|
2136 | };
|
---|
2137 |
|
---|
2138 | inline void QScriptParser::reallocateStack()
|
---|
2139 | {
|
---|
2140 | if (! stack_size)
|
---|
2141 | stack_size = 128;
|
---|
2142 | else
|
---|
2143 | stack_size <<= 1;
|
---|
2144 |
|
---|
2145 | sym_stack.resize(stack_size);
|
---|
2146 | state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
|
---|
2147 | location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
|
---|
2148 | }
|
---|
2149 |
|
---|
2150 | inline static bool automatic(QScript::Lexer *lexer, int token)
|
---|
2151 | {
|
---|
2152 | return (token == QScriptGrammar::T_RBRACE)
|
---|
2153 | || (token == 0)
|
---|
2154 | || lexer->prevTerminator();
|
---|
2155 | }
|
---|
2156 |
|
---|
2157 | QScriptParser::QScriptParser():
|
---|
2158 | tos(0),
|
---|
2159 | stack_size(0),
|
---|
2160 | sym_stack(0),
|
---|
2161 | state_stack(0),
|
---|
2162 | location_stack(0),
|
---|
2163 | lexer(0)
|
---|
2164 | {
|
---|
2165 | }
|
---|
2166 |
|
---|
2167 | QScriptParser::~QScriptParser()
|
---|
2168 | {
|
---|
2169 | if (stack_size) {
|
---|
2170 | qFree(state_stack);
|
---|
2171 | qFree(location_stack);
|
---|
2172 | }
|
---|
2173 | }
|
---|
2174 |
|
---|
2175 | static inline QScriptParser::Location location(QScript::Lexer *lexer)
|
---|
2176 | {
|
---|
2177 | QScriptParser::Location loc;
|
---|
2178 | loc.startLine = lexer->startLineNo();
|
---|
2179 | loc.startColumn = lexer->startColumnNo();
|
---|
2180 | loc.endLine = lexer->endLineNo();
|
---|
2181 | loc.endColumn = lexer->endColumnNo();
|
---|
2182 | return loc;
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 | void QScriptParser::setLexer(QScript::Lexer *lex)
|
---|
2186 | {
|
---|
2187 | lexer = lex;
|
---|
2188 | }
|
---|
2189 |
|
---|
2190 | bool QScriptParser::parse(Translator *translator)
|
---|
2191 | {
|
---|
2192 | Q_ASSERT(lexer != 0);
|
---|
2193 | const int INITIAL_STATE = 0;
|
---|
2194 |
|
---|
2195 | int yytoken = -1;
|
---|
2196 | int saved_yytoken = -1;
|
---|
2197 | int identLineNo = -1;
|
---|
2198 |
|
---|
2199 | reallocateStack();
|
---|
2200 |
|
---|
2201 | tos = 0;
|
---|
2202 | state_stack[++tos] = INITIAL_STATE;
|
---|
2203 |
|
---|
2204 | while (true)
|
---|
2205 | {
|
---|
2206 | const int state = state_stack [tos];
|
---|
2207 | if (yytoken == -1 && - TERMINAL_COUNT != action_index [state])
|
---|
2208 | {
|
---|
2209 | if (saved_yytoken == -1)
|
---|
2210 | {
|
---|
2211 | yytoken = lexer->lex();
|
---|
2212 | location_stack [tos] = location(lexer);
|
---|
2213 | }
|
---|
2214 | else
|
---|
2215 | {
|
---|
2216 | yytoken = saved_yytoken;
|
---|
2217 | saved_yytoken = -1;
|
---|
2218 | }
|
---|
2219 | }
|
---|
2220 |
|
---|
2221 | int act = t_action (state, yytoken);
|
---|
2222 |
|
---|
2223 | if (act == ACCEPT_STATE)
|
---|
2224 | return true;
|
---|
2225 |
|
---|
2226 | else if (act > 0)
|
---|
2227 | {
|
---|
2228 | if (++tos == stack_size)
|
---|
2229 | reallocateStack();
|
---|
2230 |
|
---|
2231 | sym_stack [tos] = lexer->val ();
|
---|
2232 | state_stack [tos] = act;
|
---|
2233 | location_stack [tos] = location(lexer);
|
---|
2234 | yytoken = -1;
|
---|
2235 | }
|
---|
2236 |
|
---|
2237 | else if (act < 0)
|
---|
2238 | {
|
---|
2239 | int r = - act - 1;
|
---|
2240 |
|
---|
2241 | tos -= rhs [r];
|
---|
2242 | act = state_stack [tos++];
|
---|
2243 |
|
---|
2244 | switch (r) {
|
---|
2245 |
|
---|
2246 | case 1: {
|
---|
2247 | sym(1) = sym(1).toByteArray();
|
---|
2248 | identLineNo = lexer->startLineNo();
|
---|
2249 | } break;
|
---|
2250 |
|
---|
2251 | case 7: {
|
---|
2252 | bool rx = lexer->scanRegExp(QScript::Lexer::NoPrefix);
|
---|
2253 | if (!rx) {
|
---|
2254 | error_message = lexer->errorMessage();
|
---|
2255 | error_lineno = lexer->startLineNo();
|
---|
2256 | error_column = lexer->startColumnNo();
|
---|
2257 | return false;
|
---|
2258 | }
|
---|
2259 | } break;
|
---|
2260 |
|
---|
2261 | case 8: {
|
---|
2262 | bool rx = lexer->scanRegExp(QScript::Lexer::EqualPrefix);
|
---|
2263 | if (!rx) {
|
---|
2264 | error_message = lexer->errorMessage();
|
---|
2265 | error_lineno = lexer->startLineNo();
|
---|
2266 | error_column = lexer->startColumnNo();
|
---|
2267 | return false;
|
---|
2268 | }
|
---|
2269 | } break;
|
---|
2270 |
|
---|
2271 | case 66: {
|
---|
2272 | QString name = sym(1).toString();
|
---|
2273 | if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) {
|
---|
2274 | if (!sourcetext.isEmpty())
|
---|
2275 | yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
|
---|
2276 | QVariantList args = sym(2).toList();
|
---|
2277 | if (args.size() < 2) {
|
---|
2278 | yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
|
---|
2279 | } else {
|
---|
2280 | if ((args.at(0).type() != QVariant::String)
|
---|
2281 | || (args.at(1).type() != QVariant::String)) {
|
---|
2282 | yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name));
|
---|
2283 | } else {
|
---|
2284 | QString context = args.at(0).toString();
|
---|
2285 | QString text = args.at(1).toString();
|
---|
2286 | QString comment = args.value(2).toString();
|
---|
2287 | bool plural = (args.size() > 4);
|
---|
2288 | recordMessage(translator, context, text, comment, extracomment,
|
---|
2289 | msgid, extra, plural, fileName(), identLineNo);
|
---|
2290 | }
|
---|
2291 | }
|
---|
2292 | sourcetext.clear();
|
---|
2293 | extracomment.clear();
|
---|
2294 | msgid.clear();
|
---|
2295 | extra.clear();
|
---|
2296 | } else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) {
|
---|
2297 | if (!sourcetext.isEmpty())
|
---|
2298 | yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
|
---|
2299 | QVariantList args = sym(2).toList();
|
---|
2300 | if (args.size() < 1) {
|
---|
2301 | yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
|
---|
2302 | } else {
|
---|
2303 | if (args.at(0).type() != QVariant::String) {
|
---|
2304 | yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name));
|
---|
2305 | } else {
|
---|
2306 | QString context = QFileInfo(fileName()).baseName();
|
---|
2307 | QString text = args.at(0).toString();
|
---|
2308 | QString comment = args.value(1).toString();
|
---|
2309 | bool plural = (args.size() > 2);
|
---|
2310 | recordMessage(translator, context, text, comment, extracomment,
|
---|
2311 | msgid, extra, plural, fileName(), identLineNo);
|
---|
2312 | }
|
---|
2313 | }
|
---|
2314 | sourcetext.clear();
|
---|
2315 | extracomment.clear();
|
---|
2316 | msgid.clear();
|
---|
2317 | extra.clear();
|
---|
2318 | } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
|
---|
2319 | if (!msgid.isEmpty())
|
---|
2320 | yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name));
|
---|
2321 | QVariantList args = sym(2).toList();
|
---|
2322 | if (args.size() < 1) {
|
---|
2323 | yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
|
---|
2324 | } else {
|
---|
2325 | if (args.at(0).type() != QVariant::String) {
|
---|
2326 | yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name));
|
---|
2327 | } else {
|
---|
2328 | msgid = args.at(0).toString();
|
---|
2329 | bool plural = (args.size() > 1);
|
---|
2330 | recordMessage(translator, QString(), sourcetext, QString(), extracomment,
|
---|
2331 | msgid, extra, plural, fileName(), identLineNo);
|
---|
2332 | }
|
---|
2333 | }
|
---|
2334 | sourcetext.clear();
|
---|
2335 | extracomment.clear();
|
---|
2336 | msgid.clear();
|
---|
2337 | extra.clear();
|
---|
2338 | }
|
---|
2339 | } break;
|
---|
2340 |
|
---|
2341 | case 70: {
|
---|
2342 | sym(1) = QVariantList();
|
---|
2343 | } break;
|
---|
2344 |
|
---|
2345 | case 71: {
|
---|
2346 | sym(1) = sym(2);
|
---|
2347 | } break;
|
---|
2348 |
|
---|
2349 | case 72: {
|
---|
2350 | sym(1) = QVariantList() << sym(1);
|
---|
2351 | } break;
|
---|
2352 |
|
---|
2353 | case 73: {
|
---|
2354 | sym(1) = sym(1).toList() << sym(3);
|
---|
2355 | } break;
|
---|
2356 |
|
---|
2357 | case 94: {
|
---|
2358 | if ((sym(1).type() == QVariant::String) || (sym(3).type() == QVariant::String))
|
---|
2359 | sym(1) = sym(1).toString() + sym(3).toString();
|
---|
2360 | else
|
---|
2361 | sym(1) = QVariant();
|
---|
2362 | } break;
|
---|
2363 |
|
---|
2364 | case 171:
|
---|
2365 |
|
---|
2366 | case 172:
|
---|
2367 |
|
---|
2368 | case 173:
|
---|
2369 |
|
---|
2370 | case 174:
|
---|
2371 |
|
---|
2372 | case 175:
|
---|
2373 |
|
---|
2374 | case 176:
|
---|
2375 |
|
---|
2376 | case 177:
|
---|
2377 |
|
---|
2378 | case 178:
|
---|
2379 |
|
---|
2380 | case 179:
|
---|
2381 |
|
---|
2382 | case 180:
|
---|
2383 |
|
---|
2384 | case 181:
|
---|
2385 |
|
---|
2386 | case 182:
|
---|
2387 |
|
---|
2388 | case 183:
|
---|
2389 |
|
---|
2390 | case 184:
|
---|
2391 |
|
---|
2392 | case 185:
|
---|
2393 | if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
|
---|
2394 | yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
|
---|
2395 | sourcetext.clear();
|
---|
2396 | extracomment.clear();
|
---|
2397 | msgid.clear();
|
---|
2398 | extra.clear();
|
---|
2399 | }
|
---|
2400 | break;
|
---|
2401 |
|
---|
2402 | } // switch
|
---|
2403 |
|
---|
2404 | state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT);
|
---|
2405 |
|
---|
2406 | if (rhs[r] > 1) {
|
---|
2407 | location_stack[tos - 1].endLine = location_stack[tos + rhs[r] - 2].endLine;
|
---|
2408 | location_stack[tos - 1].endColumn = location_stack[tos + rhs[r] - 2].endColumn;
|
---|
2409 | location_stack[tos] = location_stack[tos + rhs[r] - 1];
|
---|
2410 | }
|
---|
2411 | }
|
---|
2412 |
|
---|
2413 | else
|
---|
2414 | {
|
---|
2415 | if (saved_yytoken == -1 && automatic (lexer, yytoken) && t_action (state, T_AUTOMATIC_SEMICOLON) > 0)
|
---|
2416 | {
|
---|
2417 | saved_yytoken = yytoken;
|
---|
2418 | yytoken = T_SEMICOLON;
|
---|
2419 | continue;
|
---|
2420 | }
|
---|
2421 |
|
---|
2422 | else if ((state == INITIAL_STATE) && (yytoken == 0)) {
|
---|
2423 | // accept empty input
|
---|
2424 | yytoken = T_SEMICOLON;
|
---|
2425 | continue;
|
---|
2426 | }
|
---|
2427 |
|
---|
2428 | int ers = state;
|
---|
2429 | int shifts = 0;
|
---|
2430 | int reduces = 0;
|
---|
2431 | int expected_tokens [3];
|
---|
2432 | for (int tk = 0; tk < TERMINAL_COUNT; ++tk)
|
---|
2433 | {
|
---|
2434 | int k = t_action (ers, tk);
|
---|
2435 |
|
---|
2436 | if (! k)
|
---|
2437 | continue;
|
---|
2438 | else if (k < 0)
|
---|
2439 | ++reduces;
|
---|
2440 | else if (spell [tk])
|
---|
2441 | {
|
---|
2442 | if (shifts < 3)
|
---|
2443 | expected_tokens [shifts] = tk;
|
---|
2444 | ++shifts;
|
---|
2445 | }
|
---|
2446 | }
|
---|
2447 |
|
---|
2448 | error_message.clear ();
|
---|
2449 | if (shifts && shifts < 3)
|
---|
2450 | {
|
---|
2451 | bool first = true;
|
---|
2452 |
|
---|
2453 | for (int s = 0; s < shifts; ++s)
|
---|
2454 | {
|
---|
2455 | if (first)
|
---|
2456 | //: Beginning of the string that contains
|
---|
2457 | //: comma-separated list of expected tokens
|
---|
2458 | error_message += LU::tr("Expected ");
|
---|
2459 | else
|
---|
2460 | error_message += QLatin1String (", ");
|
---|
2461 |
|
---|
2462 | first = false;
|
---|
2463 | error_message += QLatin1String("`");
|
---|
2464 | error_message += QLatin1String (spell [expected_tokens [s]]);
|
---|
2465 | error_message += QLatin1String("'");
|
---|
2466 | }
|
---|
2467 | }
|
---|
2468 |
|
---|
2469 | if (error_message.isEmpty())
|
---|
2470 | error_message = lexer->errorMessage();
|
---|
2471 |
|
---|
2472 | error_lineno = lexer->startLineNo();
|
---|
2473 | error_column = lexer->startColumnNo();
|
---|
2474 |
|
---|
2475 | return false;
|
---|
2476 | }
|
---|
2477 | }
|
---|
2478 |
|
---|
2479 | return false;
|
---|
2480 | }
|
---|
2481 |
|
---|
2482 | std::ostream &QScriptParser::yyMsg(int line)
|
---|
2483 | {
|
---|
2484 | return std::cerr << qPrintable(fileName()) << ':' << (line ? line : lexer->startLineNo()) << ": ";
|
---|
2485 | }
|
---|
2486 |
|
---|
2487 | void QScriptParser::processComment(const QChar *chars, int length)
|
---|
2488 | {
|
---|
2489 | if (!length)
|
---|
2490 | return;
|
---|
2491 | // Try to match the logic of the C++ parser.
|
---|
2492 | if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
|
---|
2493 | extracomment += QString(chars+2, length-2);
|
---|
2494 | } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) {
|
---|
2495 | msgid = QString(chars+2, length-2).simplified();
|
---|
2496 | } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) {
|
---|
2497 | QString text = QString(chars+2, length-2).trimmed();
|
---|
2498 | int k = text.indexOf(QLatin1Char(' '));
|
---|
2499 | if (k > -1)
|
---|
2500 | extra.insert(text.left(k), text.mid(k + 1).trimmed());
|
---|
2501 | } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
|
---|
2502 | sourcetext.reserve(sourcetext.length() + length-2);
|
---|
2503 | ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length();
|
---|
2504 | int p = 2, c;
|
---|
2505 | forever {
|
---|
2506 | if (p >= length)
|
---|
2507 | break;
|
---|
2508 | c = chars[p++].unicode();
|
---|
2509 | if (isspace(c))
|
---|
2510 | continue;
|
---|
2511 | if (c != '"') {
|
---|
2512 | yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
|
---|
2513 | break;
|
---|
2514 | }
|
---|
2515 | forever {
|
---|
2516 | if (p >= length) {
|
---|
2517 | whoops:
|
---|
2518 | yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
|
---|
2519 | break;
|
---|
2520 | }
|
---|
2521 | c = chars[p++].unicode();
|
---|
2522 | if (c == '"')
|
---|
2523 | break;
|
---|
2524 | if (c == '\\') {
|
---|
2525 | if (p >= length)
|
---|
2526 | goto whoops;
|
---|
2527 | c = chars[p++].unicode();
|
---|
2528 | if (c == '\n')
|
---|
2529 | goto whoops;
|
---|
2530 | *ptr++ = '\\';
|
---|
2531 | }
|
---|
2532 | *ptr++ = c;
|
---|
2533 | }
|
---|
2534 | }
|
---|
2535 | sourcetext.resize(ptr - (ushort *)sourcetext.data());
|
---|
2536 | }
|
---|
2537 | }
|
---|
2538 |
|
---|
2539 |
|
---|
2540 | bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd)
|
---|
2541 | {
|
---|
2542 | QFile file(filename);
|
---|
2543 | if (!file.open(QIODevice::ReadOnly)) {
|
---|
2544 | cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
|
---|
2545 | return false;
|
---|
2546 | }
|
---|
2547 | QTextStream ts(&file);
|
---|
2548 | QByteArray codecName;
|
---|
2549 | if (!cd.m_codecForSource.isEmpty())
|
---|
2550 | codecName = cd.m_codecForSource;
|
---|
2551 | else
|
---|
2552 | codecName = translator.codecName(); // Just because it should be latin1 already
|
---|
2553 | ts.setCodec(QTextCodec::codecForName(codecName));
|
---|
2554 | ts.setAutoDetectUnicode(true);
|
---|
2555 |
|
---|
2556 | QString code = ts.readAll();
|
---|
2557 | QScriptParser parser;
|
---|
2558 | QScript::Lexer lexer(&parser);
|
---|
2559 | lexer.setCode(code, filename, /*lineNumber=*/1);
|
---|
2560 | parser.setLexer(&lexer);
|
---|
2561 | if (!parser.parse(&translator)) {
|
---|
2562 | std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": "
|
---|
2563 | << qPrintable(parser.errorMessage()) << std::endl;
|
---|
2564 | return false;
|
---|
2565 | }
|
---|
2566 |
|
---|
2567 | // Java uses UTF-16 internally and Jambi makes UTF-8 for tr() purposes of it.
|
---|
2568 | translator.setCodecName("UTF-8");
|
---|
2569 | return true;
|
---|
2570 | }
|
---|
2571 |
|
---|
2572 | QT_END_NAMESPACE
|
---|