Qt 4.8
Classes | Public Functions | Protected Functions | Protected Variables | List of all members
QScriptParser Class Reference

#include <qscriptparser_p.h>

Inheritance diagram for QScriptParser:
QScriptGrammar

Classes

struct  Location
 
union  Value
 

Public Functions

int errorColumnNumber () const
 
int errorLineNumber () const
 
QString errorMessage () const
 
bool parse (QScriptEnginePrivate *driver)
 
 QScriptParser ()
 
 ~QScriptParser ()
 

Protected Functions

Locationloc (int index)
 
void reallocateStack ()
 
Valuesym (int index)
 

Protected Variables

int error_column
 
int error_lineno
 
QString error_message
 
Locationlocation_stack
 
int stack_size
 
int * state_stack
 
Valuesym_stack
 
int tos
 

Additional Inherited Members

- Protected Types inherited from QScriptGrammar
enum  {
  EOF_SYMBOL = 0, T_AND = 1, T_AND_AND = 2, T_AND_EQ = 3,
  T_AUTOMATIC_SEMICOLON = 62, T_BREAK = 4, T_CASE = 5, T_CATCH = 6,
  T_COLON = 7, T_COMMA = 8, T_CONST = 81, T_CONTINUE = 9,
  T_DEBUGGER = 82, T_DEFAULT = 10, T_DELETE = 11, T_DIVIDE_ = 12,
  T_DIVIDE_EQ = 13, T_DO = 14, T_DOT = 15, T_ELSE = 16,
  T_EQ = 17, T_EQ_EQ = 18, T_EQ_EQ_EQ = 19, T_FALSE = 80,
  T_FINALLY = 20, T_FOR = 21, T_FUNCTION = 22, T_GE = 23,
  T_GT = 24, T_GT_GT = 25, T_GT_GT_EQ = 26, T_GT_GT_GT = 27,
  T_GT_GT_GT_EQ = 28, T_IDENTIFIER = 29, T_IF = 30, T_IN = 31,
  T_INSTANCEOF = 32, T_LBRACE = 33, T_LBRACKET = 34, T_LE = 35,
  T_LPAREN = 36, T_LT = 37, T_LT_LT = 38, T_LT_LT_EQ = 39,
  T_MINUS = 40, T_MINUS_EQ = 41, T_MINUS_MINUS = 42, T_NEW = 43,
  T_NOT = 44, T_NOT_EQ = 45, T_NOT_EQ_EQ = 46, T_NULL = 78,
  T_NUMERIC_LITERAL = 47, T_OR = 48, T_OR_EQ = 49, T_OR_OR = 50,
  T_PLUS = 51, T_PLUS_EQ = 52, T_PLUS_PLUS = 53, T_QUESTION = 54,
  T_RBRACE = 55, T_RBRACKET = 56, T_REMAINDER = 57, T_REMAINDER_EQ = 58,
  T_RESERVED_WORD = 83, T_RETURN = 59, T_RPAREN = 60, T_SEMICOLON = 61,
  T_STAR = 63, T_STAR_EQ = 64, T_STRING_LITERAL = 65, T_SWITCH = 66,
  T_THIS = 67, T_THROW = 68, T_TILDE = 69, T_TRUE = 79,
  T_TRY = 70, T_TYPEOF = 71, T_VAR = 72, T_VOID = 73,
  T_WHILE = 74, T_WITH = 75, T_XOR = 76, T_XOR_EQ = 77,
  ACCEPT_STATE = 237, RULE_COUNT = 269, STATE_COUNT = 468, TERMINAL_COUNT = 84,
  NON_TERMINAL_COUNT = 88, GOTO_INDEX_OFFSET = 468, GOTO_INFO_OFFSET = 1562, GOTO_CHECK_OFFSET = 1562
}
 
- Static Protected Functions inherited from QScriptGrammar
static int nt_action (int state, int nt)
 
static int t_action (int state, int token)
 
- Static Protected Variables inherited from QScriptGrammar
static const short action_check []
 
static const short action_default []
 
static const short action_index []
 
static const short action_info []
 
static const short goto_default []
 
static const short lhs []
 
static const short rhs []
 
static const int rule_index []
 
static const int rule_info []
 
static const char *const spell []
 

Detailed Description

Definition at line 56 of file qscriptparser_p.h.

Constructors and Destructors

◆ QScriptParser()

QScriptParser::QScriptParser ( )

Definition at line 57 of file qscriptparser.cpp.

57  :
58  tos(0),
59  stack_size(0),
60  sym_stack(0),
61  state_stack(0),
63 {
64 }
Location * location_stack

◆ ~QScriptParser()

QScriptParser::~QScriptParser ( )

Definition at line 66 of file qscriptparser.cpp.

67 {
68  if (stack_size) {
72  }
73 }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
Location * location_stack

Functions

◆ errorColumnNumber()

int QScriptParser::errorColumnNumber ( ) const
inline

Definition at line 104 of file qscriptparser_p.h.

105  { return error_column; }

◆ errorLineNumber()

int QScriptParser::errorLineNumber ( ) const
inline

Definition at line 102 of file qscriptparser_p.h.

103  { return error_lineno; }

◆ errorMessage()

QString QScriptParser::errorMessage ( ) const
inline

Definition at line 100 of file qscriptparser_p.h.

101  { return error_message; }
QString error_message

◆ loc()

Location& QScriptParser::loc ( int  index)
inlineprotected

Definition at line 113 of file qscriptparser_p.h.

Referenced by location(), and parse().

114  { return location_stack [tos + index - 2]; }
Location * location_stack
quint16 index

◆ parse()

bool QScriptParser::parse ( QScriptEnginePrivate driver)

Definition at line 85 of file qscriptparser.cpp.

86 {
87  const int INITIAL_STATE = 0;
88  QScript::Lexer *lexer = driver->lexer();
89 
90  int yytoken = -1;
91  int saved_yytoken = -1;
92 
94 
95  tos = 0;
96  state_stack[++tos] = INITIAL_STATE;
97 
98  while (true)
99  {
100  const int state = state_stack [tos];
101  if (yytoken == -1 && - TERMINAL_COUNT != action_index [state])
102  {
103  if (saved_yytoken == -1)
104  {
105  yytoken = lexer->lex();
106  location_stack [tos] = location(lexer);
107  }
108  else
109  {
110  yytoken = saved_yytoken;
111  saved_yytoken = -1;
112  }
113  }
114 
115  int act = t_action (state, yytoken);
116 
117  if (act == ACCEPT_STATE)
118  return true;
119 
120  else if (act > 0)
121  {
122  if (++tos == stack_size)
123  reallocateStack();
124 
125  sym_stack [tos].dval = lexer->dval ();
126  state_stack [tos] = act;
127  location_stack [tos] = location(lexer);
128  yytoken = -1;
129  }
130 
131  else if (act < 0)
132  {
133  int r = - act - 1;
134 
135  tos -= rhs [r];
136  act = state_stack [tos++];
137 
138  switch (r) {
139 
140 case 0: {
141  sym(1).Node = QScript::makeAstNode<QScript::AST::ThisExpression> (driver->nodePool());
143 } break;
144 
145 case 1: {
146  sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
148 } break;
149 
150 case 2: {
151  sym(1).Node = QScript::makeAstNode<QScript::AST::NullExpression> (driver->nodePool());
153 } break;
154 
155 case 3: {
156  sym(1).Node = QScript::makeAstNode<QScript::AST::TrueLiteral> (driver->nodePool());
158 } break;
159 
160 case 4: {
161  sym(1).Node = QScript::makeAstNode<QScript::AST::FalseLiteral> (driver->nodePool());
163 } break;
164 
165 case 5: {
166  sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
168 } break;
169 
170 case 6: {
171  sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteral> (driver->nodePool(), sym(1).sval);
173 } break;
174 
175 case 7: {
176  bool rx = lexer->scanRegExp(QScript::Lexer::NoPrefix);
177  if (!rx) {
178  error_message = lexer->errorMessage();
179  error_lineno = lexer->startLineNo();
180  error_column = lexer->startColumnNo();
181  return false;
182  }
183  sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
185 } break;
186 
187 case 8: {
188  bool rx = lexer->scanRegExp(QScript::Lexer::EqualPrefix);
189  if (!rx) {
190  error_message = lexer->errorMessage();
191  error_lineno = lexer->startLineNo();
192  error_column = lexer->startColumnNo();
193  return false;
194  }
195  sym(1).Node = QScript::makeAstNode<QScript::AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
197 } break;
198 
199 case 9: {
200  sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision);
202 } break;
203 
204 case 10: {
205  sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ());
207 } break;
208 
209 case 11: {
210  sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), sym(4).Elision);
212 } break;
213 
214 case 12: {
215  if (sym(2).Node)
216  sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ());
217  else
218  sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool());
220 } break;
221 
222 case 13: {
223  sym(1).Node = QScript::makeAstNode<QScript::AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ());
225 } break;
226 
227 case 14: {
228  sym(1) = sym(2);
230 } break;
231 
232 case 15: {
233  sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).Elision, sym(2).Expression);
235 } break;
236 
237 case 16: {
238  sym(1).Node = QScript::makeAstNode<QScript::AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision, sym(4).Expression);
240 } break;
241 
242 case 17: {
243  sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool());
245 } break;
246 
247 case 18: {
248  sym(1).Node = QScript::makeAstNode<QScript::AST::Elision> (driver->nodePool(), sym(1).Elision);
250 } break;
251 
252 case 19: {
253  sym(1).Node = 0;
254 } break;
255 
256 case 20: {
257  sym(1).Elision = sym(1).Elision->finish ();
259 } break;
260 
261 case 21: {
262  sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyName, sym(3).Expression);
264 } break;
265 
266 case 22: {
267  sym(1).Node = QScript::makeAstNode<QScript::AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
269 } break;
270 
271 case 23: {
272  sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
274 } break;
275 
276 case 24: {
277  sym(1).Node = QScript::makeAstNode<QScript::AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
279 } break;
280 
281 case 25: {
282  sym(1).Node = QScript::makeAstNode<QScript::AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
284 } break;
285 
286 case 26: {
287  sym(1).Node = QScript::makeAstNode<QScript::AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
289 } break;
290 
291 case 27:
292 
293 case 28:
294 
295 case 29:
296 
297 case 30:
298 
299 case 31:
300 
301 case 32:
302 
303 case 33:
304 
305 case 34:
306 
307 case 35:
308 
309 case 36:
310 
311 case 37:
312 
313 case 38:
314 
315 case 39:
316 
317 case 40:
318 
319 case 41:
320 
321 case 42:
322 
323 case 43:
324 
325 case 44:
326 
327 case 45:
328 
329 case 46:
330 
331 case 47:
332 
333 case 48:
334 
335 case 49:
336 
337 case 50:
338 
339 case 51:
340 
341 case 52:
342 
343 case 53:
344 
345 case 54:
346 
347 case 55:
348 
349 case 56:
350 
351 case 57:
352 {
353  sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
354 } break;
355 
356 case 62: {
357  sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
359 } break;
360 
361 case 63: {
362  sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
364 } break;
365 
366 case 64: {
367  sym(1).Node = QScript::makeAstNode<QScript::AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(3).ArgumentList);
369 } break;
370 
371 case 66: {
372  sym(1).Node = QScript::makeAstNode<QScript::AST::NewExpression> (driver->nodePool(), sym(2).Expression);
374 } break;
375 
376 case 67: {
377  sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList);
379 } break;
380 
381 case 68: {
382  sym(1).Node = QScript::makeAstNode<QScript::AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(2).ArgumentList);
384 } break;
385 
386 case 69: {
387  sym(1).Node = QScript::makeAstNode<QScript::AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
389 } break;
390 
391 case 70: {
392  sym(1).Node = QScript::makeAstNode<QScript::AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval);
394 } break;
395 
396 case 71: {
397  sym(1).Node = 0;
398 } break;
399 
400 case 72: {
401  sym(1).Node = sym(2).ArgumentList->finish ();
403 } break;
404 
405 case 73: {
406  sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
408 } break;
409 
410 case 74: {
411  sym(1).Node = QScript::makeAstNode<QScript::AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
413 } break;
414 
415 case 78: {
416  sym(1).Node = QScript::makeAstNode<QScript::AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
418 } break;
419 
420 case 79: {
421  sym(1).Node = QScript::makeAstNode<QScript::AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
423 } break;
424 
425 case 81: {
426  sym(1).Node = QScript::makeAstNode<QScript::AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
428 } break;
429 
430 case 82: {
431  sym(1).Node = QScript::makeAstNode<QScript::AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
433 } break;
434 
435 case 83: {
436  sym(1).Node = QScript::makeAstNode<QScript::AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
438 } break;
439 
440 case 84: {
441  sym(1).Node = QScript::makeAstNode<QScript::AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
443 } break;
444 
445 case 85: {
446  sym(1).Node = QScript::makeAstNode<QScript::AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
448 } break;
449 
450 case 86: {
451  sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
453 } break;
454 
455 case 87: {
456  sym(1).Node = QScript::makeAstNode<QScript::AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
458 } break;
459 
460 case 88: {
461  sym(1).Node = QScript::makeAstNode<QScript::AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
463 } break;
464 
465 case 89: {
466  sym(1).Node = QScript::makeAstNode<QScript::AST::NotExpression> (driver->nodePool(), sym(2).Expression);
468 } break;
469 
470 case 91: {
471  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mul, sym(3).Expression);
473 } break;
474 
475 case 92: {
476  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Div, sym(3).Expression);
478 } break;
479 
480 case 93: {
481  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mod, sym(3).Expression);
483 } break;
484 
485 case 95: {
486  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Add, sym(3).Expression);
488 } break;
489 
490 case 96: {
491  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Sub, sym(3).Expression);
493 } break;
494 
495 case 98: {
496  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::LShift, sym(3).Expression);
498 } break;
499 
500 case 99: {
501  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::RShift, sym(3).Expression);
503 } break;
504 
505 case 100: {
506  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::URShift, sym(3).Expression);
508 } break;
509 
510 case 102: {
511  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression);
513 } break;
514 
515 case 103: {
516  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression);
518 } break;
519 
520 case 104: {
521  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression);
523 } break;
524 
525 case 105: {
526  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression);
528 } break;
529 
530 case 106: {
531  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression);
533 } break;
534 
535 case 107: {
536  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::In, sym(3).Expression);
538 } break;
539 
540 case 109: {
541  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression);
543 } break;
544 
545 case 110: {
546  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression);
548 } break;
549 
550 case 111: {
551  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression);
553 } break;
554 
555 case 112: {
556  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression);
558 } break;
559 
560 case 113: {
561  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression);
563 } break;
564 
565 case 115: {
566  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression);
568 } break;
569 
570 case 116: {
571  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression);
573 } break;
574 
575 case 117: {
576  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression);
578 } break;
579 
580 case 118: {
581  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression);
583 } break;
584 
585 case 120: {
586  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression);
588 } break;
589 
590 case 121: {
591  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression);
593 } break;
594 
595 case 122: {
596  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression);
598 } break;
599 
600 case 123: {
601  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression);
603 } break;
604 
605 case 125: {
606  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression);
608 } break;
609 
610 case 127: {
611  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression);
613 } break;
614 
615 case 129: {
616  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression);
618 } break;
619 
620 case 131: {
621  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression);
623 } break;
624 
625 case 133: {
626  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression);
628 } break;
629 
630 case 135: {
631  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression);
633 } break;
634 
635 case 137: {
636  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression);
638 } break;
639 
640 case 139: {
641  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression);
643 } break;
644 
645 case 141: {
646  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression);
648 } break;
649 
650 case 143: {
651  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression);
653 } break;
654 
655 case 145: {
656  sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression);
658 } break;
659 
660 case 147: {
661  sym(1).Node = QScript::makeAstNode<QScript::AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression);
663 } break;
664 
665 case 149: {
666  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression);
668 } break;
669 
670 case 151: {
671  sym(1).Node = QScript::makeAstNode<QScript::AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression);
673 } break;
674 
675 case 152: {
677 } break;
678 
679 case 153: {
681 } break;
682 
683 case 154: {
685 } break;
686 
687 case 155: {
689 } break;
690 
691 case 156: {
693 } break;
694 
695 case 157: {
697 } break;
698 
699 case 158: {
701 } break;
702 
703 case 159: {
705 } break;
706 
707 case 160: {
709 } break;
710 
711 case 161: {
713 } break;
714 
715 case 162: {
717 } break;
718 
719 case 163: {
721 } break;
722 
723 case 165: {
724  sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
726 } break;
727 
728 case 166: {
729  sym(1).Node = 0;
730 } break;
731 
732 case 169: {
733  sym(1).Node = QScript::makeAstNode<QScript::AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
735 } break;
736 
737 case 170: {
738  sym(1).Node = 0;
739 } break;
740 
741 case 187: {
742  sym(1).Node = QScript::makeAstNode<QScript::AST::Block> (driver->nodePool(), sym(2).StatementList);
744 } break;
745 
746 case 188: {
747  sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).Statement);
749 } break;
750 
751 case 189: {
752  sym(1).Node = QScript::makeAstNode<QScript::AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
754 } break;
755 
756 case 190: {
757  sym(1).Node = 0;
758 } break;
759 
760 case 191: {
761  sym(1).Node = sym(1).StatementList->finish ();
762 } break;
763 
764 case 193: {
765  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
767 } break;
768 
769 case 194: {
770  sym(1).ival = T_CONST;
771 } break;
772 
773 case 195: {
774  sym(1).ival = T_VAR;
775 } break;
776 
777 case 196: {
778  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
780 } break;
781 
782 case 197: {
783  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
785 } break;
786 
787 case 198: {
788  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
790 } break;
791 
792 case 199: {
793  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
795 } break;
796 
797 case 200: {
798  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
800 } break;
801 
802 case 201: {
803  sym(1).Node = QScript::makeAstNode<QScript::AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
805 } break;
806 
807 case 202: {
808  sym(1) = sym(2);
810 } break;
811 
812 case 203: {
813  sym(1).Node = 0;
814 } break;
815 
816 case 205: {
817  sym(1) = sym(2);
819 } break;
820 
821 case 206: {
822  sym(1).Node = 0;
823 } break;
824 
825 case 208: {
826  sym(1).Node = QScript::makeAstNode<QScript::AST::EmptyStatement> (driver->nodePool());
828 } break;
829 
830 case 210: {
831  sym(1).Node = QScript::makeAstNode<QScript::AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
833 } break;
834 
835 case 211: {
836  sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement);
838 } break;
839 
840 case 212: {
841  sym(1).Node = QScript::makeAstNode<QScript::AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
843 } break;
844 
845 case 214: {
846  sym(1).Node = QScript::makeAstNode<QScript::AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
848 } break;
849 
850 case 215: {
851  sym(1).Node = QScript::makeAstNode<QScript::AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
853 } break;
854 
855 case 216: {
856  sym(1).Node = QScript::makeAstNode<QScript::AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement);
858 } break;
859 
860 case 217: {
861  sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement);
862  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(10));
863 } break;
864 
865 case 218: {
866  sym(1).Node = QScript::makeAstNode<QScript::AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement);
868 } break;
869 
870 case 219: {
871  sym(1).Node = QScript::makeAstNode<QScript::AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
873 } break;
874 
875 case 221: {
876  sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool());
878 } break;
879 
880 case 223: {
881  sym(1).Node = QScript::makeAstNode<QScript::AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
883 } break;
884 
885 case 225: {
886  sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool());
888 } break;
889 
890 case 227: {
891  sym(1).Node = QScript::makeAstNode<QScript::AST::BreakStatement> (driver->nodePool(), sym(2).sval);
893 } break;
894 
895 case 229: {
896  sym(1).Node = QScript::makeAstNode<QScript::AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
898 } break;
899 
900 case 230: {
901  sym(1).Node = QScript::makeAstNode<QScript::AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
903 } break;
904 
905 case 231: {
906  sym(1).Node = QScript::makeAstNode<QScript::AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
908 } break;
909 
910 case 232: {
911  sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
913 } break;
914 
915 case 233: {
916  sym(1).Node = QScript::makeAstNode<QScript::AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
918 } break;
919 
920 case 234: {
921  sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
923 } break;
924 
925 case 235: {
926  sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
928 } break;
929 
930 case 236: {
931  sym(1).Node = 0;
932 } break;
933 
934 case 237: {
935  sym(1).Node = sym(1).CaseClauses->finish ();
937 } break;
938 
939 case 238: {
940  sym(1).Node = QScript::makeAstNode<QScript::AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList);
942 } break;
943 
944 case 239: {
945  sym(1).Node = QScript::makeAstNode<QScript::AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
947 } break;
948 
949 case 240: {
950  sym(1).Node = QScript::makeAstNode<QScript::AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement);
952 } break;
953 
954 case 242: {
955  sym(1).Node = QScript::makeAstNode<QScript::AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
957 } break;
958 
959 case 243: {
960  sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
962 } break;
963 
964 case 244: {
965  sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
967 } break;
968 
969 case 245: {
970  sym(1).Node = QScript::makeAstNode<QScript::AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally);
972 } break;
973 
974 case 246: {
975  sym(1).Node = QScript::makeAstNode<QScript::AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement);
977 } break;
978 
979 case 247: {
980  sym(1).Node = QScript::makeAstNode<QScript::AST::Finally> (driver->nodePool(), sym(2).Statement);
982 } break;
983 
984 case 249: {
985  sym(1).Node = QScript::makeAstNode<QScript::AST::DebuggerStatement> (driver->nodePool());
987 } break;
988 
989 case 250: {
990  sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
992 } break;
993 
994 case 251: {
995  sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody);
997 } break;
998 
999 case 252: {
1000  sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
1001  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1002 } break;
1003 
1004 case 253: {
1005  sym(1).Node = QScript::makeAstNode<QScript::AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval);
1006  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(3));
1007 } break;
1008 
1009 case 254: {
1010  sym(1).Node = 0;
1011 } break;
1012 
1013 case 255: {
1014  sym(1).Node = sym(1).FormalParameterList->finish ();
1015  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1016 } break;
1017 
1018 case 256: {
1019  sym(1).Node = 0;
1020 } break;
1021 
1022 case 258: {
1023  sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
1024  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1025 } break;
1026 
1027 case 259: {
1028  sym(1).Node = QScript::makeAstNode<QScript::AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
1029  driver->changeAbstractSyntaxTree(sym(1).Node);
1030  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1031 } break;
1032 
1033 case 260: {
1034  sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
1035  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1036 } break;
1037 
1038 case 261: {
1039  sym(1).Node = QScript::makeAstNode<QScript::AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
1040  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(2));
1041 } break;
1042 
1043 case 262: {
1044  sym(1).Node = QScript::makeAstNode<QScript::AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
1045  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1046 } break;
1047 
1048 case 263: {
1049  sym(1).Node = QScript::makeAstNode<QScript::AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
1050  Q_SCRIPT_UPDATE_POSITION(sym(1).Node, loc(1), loc(1));
1051 } break;
1052 
1053 case 264: {
1054  sym(1).sval = 0;
1055 } break;
1056 
1057 case 266: {
1058  sym(1).Node = 0;
1059 } break;
1060 
1061  } // switch
1062 
1063  state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT);
1064 
1065  if (rhs[r] > 1) {
1068  location_stack[tos] = location_stack[tos + rhs[r] - 1];
1069  }
1070  }
1071 
1072  else
1073  {
1074  if (saved_yytoken == -1 && automatic (driver, yytoken) && t_action (state, T_AUTOMATIC_SEMICOLON) > 0)
1075  {
1076  saved_yytoken = yytoken;
1077  yytoken = T_SEMICOLON;
1078  continue;
1079  }
1080 
1081  else if ((state == INITIAL_STATE) && (yytoken == 0)) {
1082  // accept empty input
1083  yytoken = T_SEMICOLON;
1084  continue;
1085  }
1086 
1087  int ers = state;
1088  int shifts = 0;
1089  int reduces = 0;
1090  int expected_tokens [3];
1091  for (int tk = 0; tk < TERMINAL_COUNT; ++tk)
1092  {
1093  int k = t_action (ers, tk);
1094 
1095  if (! k)
1096  continue;
1097  else if (k < 0)
1098  ++reduces;
1099  else if (spell [tk])
1100  {
1101  if (shifts < 3)
1102  expected_tokens [shifts] = tk;
1103  ++shifts;
1104  }
1105  }
1106 
1107  error_message.clear ();
1108  if (shifts && shifts < 3)
1109  {
1110  bool first = true;
1111 
1112  for (int s = 0; s < shifts; ++s)
1113  {
1114  if (first)
1115  error_message += QLatin1String ("Expected ");
1116  else
1117  error_message += QLatin1String (", ");
1118 
1119  first = false;
1120  error_message += QLatin1String("`");
1121  error_message += QLatin1String (spell [expected_tokens [s]]);
1122  error_message += QLatin1String("'");
1123  }
1124  }
1125 
1126  if (error_message.isEmpty())
1127  error_message = lexer->errorMessage();
1128 
1129  error_lineno = lexer->startLineNo();
1130  error_column = lexer->startColumnNo();
1131 
1132  return false;
1133  }
1134  }
1135 
1136  return false;
1137 }
static const short lhs[]
int startLineNo() const
QScript::AST::Statement * Statement
QScript::AST::FunctionDeclaration * FunctionDeclaration
QString error_message
FormalParameterList * finish()
static int t_action(int state, int token)
static int nt_action(int state, int nt)
QScript::AST::Finally * Finally
VariableDeclarationList * finish(bool readOnly)
Definition: qscriptast_p.h:907
QScript::AST::VariableDeclaration * VariableDeclaration
Location * location_stack
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static bool automatic(QScriptEnginePrivate *driver, int token)
int characterCount() const
QScript::AST::ExpressionNode * Expression
QScript::AST::Catch * Catch
QScript::AST::StatementList * StatementList
Location & loc(int index)
#define Q_SCRIPT_UPDATE_POSITION(node, startloc, endloc)
QScript::AST::CaseClause * CaseClause
Value & sym(int index)
QScript::AST::SourceElement * SourceElement
QString errorMessage() const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QScript::AST::ElementList * ElementList
QScriptNameIdImpl * pattern
QScript::AST::ArgumentList * ArgumentList
bool scanRegExp(RegExpBodyPrefix prefix=NoPrefix)
static QScriptParser::Location location(QScript::Lexer *lexer)
QScript::AST::DefaultClause * DefaultClause
QScript::AST::SourceElements * SourceElements
static const short action_index[]
QScript::AST::FunctionBody * FunctionBody
void reallocateStack()
ArgumentList * finish()
Definition: qscriptast_p.h:595
QScript::AST::PropertyName * PropertyName
PropertyNameAndValueList * finish()
Definition: qscriptast_p.h:438
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
QScriptNameIdImpl * sval
const QChar * characterBuffer() const
QScript::AST::Node * Node
QScript::AST::CaseClauses * CaseClauses
static const char *const spell[]
SourceElements * finish()
static const short rhs[]
QScript::AST::CaseBlock * CaseBlock
QScript::AST::Elision * Elision
QScript::AST::VariableDeclarationList * VariableDeclarationList
int startColumnNo() const
QScript::AST::PropertyNameAndValueList * PropertyNameAndValueList
ElementList * finish()
Definition: qscriptast_p.h:376
QScript::AST::FormalParameterList * FormalParameterList
StatementList * finish()
Definition: qscriptast_p.h:844

◆ reallocateStack()

void QScriptParser::reallocateStack ( )
inlineprotected

Definition at line 127 of file qscriptparser_p.h.

Referenced by errorColumnNumber(), and parse().

128 {
129  if (! stack_size)
130  stack_size = 128;
131  else
132  stack_size <<= 1;
133 
134  sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
135  state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
136  location_stack = reinterpret_cast<Location*> (qRealloc(location_stack, stack_size * sizeof(Location)));
137 }
Location
Definition: qsql.h:55
Location * location_stack
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63

◆ sym()

Value& QScriptParser::sym ( int  index)
inlineprotected

Definition at line 110 of file qscriptparser_p.h.

Referenced by parse().

111  { return sym_stack [tos + index - 1]; }
quint16 index

Properties

◆ error_column

int QScriptParser::error_column
protected

Definition at line 124 of file qscriptparser_p.h.

Referenced by errorColumnNumber(), and parse().

◆ error_lineno

int QScriptParser::error_lineno
protected

Definition at line 123 of file qscriptparser_p.h.

Referenced by errorLineNumber(), and parse().

◆ error_message

QString QScriptParser::error_message
protected

Definition at line 122 of file qscriptparser_p.h.

Referenced by errorMessage(), and parse().

◆ location_stack

Location* QScriptParser::location_stack
protected

Definition at line 121 of file qscriptparser_p.h.

Referenced by loc(), parse(), reallocateStack(), and ~QScriptParser().

◆ stack_size

int QScriptParser::stack_size
protected

Definition at line 118 of file qscriptparser_p.h.

Referenced by parse(), reallocateStack(), and ~QScriptParser().

◆ state_stack

int* QScriptParser::state_stack
protected

Definition at line 120 of file qscriptparser_p.h.

Referenced by parse(), reallocateStack(), and ~QScriptParser().

◆ sym_stack

Value* QScriptParser::sym_stack
protected

Definition at line 119 of file qscriptparser_p.h.

Referenced by parse(), reallocateStack(), sym(), and ~QScriptParser().

◆ tos

int QScriptParser::tos
protected

Definition at line 117 of file qscriptparser_p.h.

Referenced by loc(), parse(), and sym().


The documentation for this class was generated from the following files: