• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop QMake parser
 

KDevelop QMake parser

  • buildtools
  • lib
  • parsers
  • qmake
qmake_yacc.cpp
1 /* A Bison parser, made by GNU Bison 2.3. */
2 
3 /* Skeleton implementation for Bison LALR(1) parsers in C++
4 
5  Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2, or (at your option)
10  any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA. */
21 
22 /* As a special exception, you may create a larger work that contains
23  part or all of the Bison parser skeleton and distribute that work
24  under terms of your choice, so long as that work isn't itself a
25  parser generator using the skeleton or a modified version thereof
26  as a parser skeleton. Alternatively, if you modify or redistribute
27  the parser skeleton itself, you may (at your option) remove this
28  special exception, which will cause the skeleton and the resulting
29  Bison output files to be licensed under the GNU General Public
30  License without this special exception.
31 
32  This special exception was added by the Free Software Foundation in
33  version 2.2 of Bison. */
34 
35 // Take the name prefix into account.
36 #define yylex TQMakelex
37 
38 #include "qmake_yacc.hpp"
39 
40 /* User implementation prologue. */
41 
42 
43 /* Line 317 of lalr1.cc. */
44 #line 45 "tqmake_yacc.cpp"
45 
46 #ifndef YY_
47 # if YYENABLE_NLS
48 # if ENABLE_NLS
49 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
50 # define YY_(msgid) dgettext ("bison-runtime", msgid)
51 # endif
52 # endif
53 # ifndef YY_
54 # define YY_(msgid) msgid
55 # endif
56 #endif
57 
58 /* Suppress unused-variable warnings by "using" E. */
59 #define YYUSE(e) ((void) (e))
60 
61 /* A pseudo ostream that takes yydebug_ into account. */
62 # define YYCDEBUG \
63  for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
64  (*yycdebug_)
65 
66 /* Enable debugging if requested. */
67 #if YYDEBUG
68 
69 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
70 do { \
71  if (yydebug_) \
72  { \
73  *yycdebug_ << Title << ' '; \
74  yy_symbol_print_ ((Type), (Value), (Location)); \
75  *yycdebug_ << std::endl; \
76  } \
77 } while (false)
78 
79 # define YY_REDUCE_PRINT(Rule) \
80 do { \
81  if (yydebug_) \
82  yy_reduce_print_ (Rule); \
83 } while (false)
84 
85 # define YY_STACK_PRINT() \
86 do { \
87  if (yydebug_) \
88  yystack_print_ (); \
89 } while (false)
90 
91 #else /* !YYDEBUG */
92 
93 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
94 # define YY_REDUCE_PRINT(Rule)
95 # define YY_STACK_PRINT()
96 
97 #endif /* !YYDEBUG */
98 
99 #define YYACCEPT goto yyacceptlab
100 #define YYABORT goto yyabortlab
101 #define YYERROR goto yyerrorlab
102 
103 namespace TQMake
104 {
105 #if YYERROR_VERBOSE
106 
107  /* Return YYSTR after stripping away unnecessary quotes and
108  backslashes, so that it's suitable for yyerror. The heuristic is
109  that double-quoting is unnecessary unless the string contains an
110  apostrophe, a comma, or backslash (other than backslash-backslash).
111  YYSTR is taken from yytname. */
112  std::string
113  Parser::yytnamerr_ (const char *yystr)
114  {
115  if (*yystr == '"')
116  {
117  std::string yyr = "";
118  char const *yyp = yystr;
119 
120  for (;;)
121  switch (*++yyp)
122  {
123  case '\'':
124  case ',':
125  goto do_not_strip_quotes;
126 
127  case '\\':
128  if (*++yyp != '\\')
129  goto do_not_strip_quotes;
130  /* Fall through. */
131  default:
132  yyr += *yyp;
133  break;
134 
135  case '"':
136  return yyr;
137  }
138  do_not_strip_quotes: ;
139  }
140 
141  return yystr;
142  }
143 
144 #endif
145 
147  Parser::Parser (TQMake::Lexer* lexer_yyarg, TQValueStack<ProjectAST*>& projects_yyarg, int depth_yyarg)
148  : yydebug_ (false),
149  yycdebug_ (&std::cerr),
150  lexer (lexer_yyarg),
151  projects (projects_yyarg),
152  depth (depth_yyarg)
153  {
154  }
155 
156  Parser::~Parser ()
157  {
158  }
159 
160 #if YYDEBUG
161  /*--------------------------------.
162  | Print this symbol on YYOUTPUT. |
163  `--------------------------------*/
164 
165  inline void
166  Parser::yy_symbol_value_print_ (int yytype,
167  const semantic_type* yyvaluep, const location_type* yylocationp)
168  {
169  YYUSE (yylocationp);
170  YYUSE (yyvaluep);
171  switch (yytype)
172  {
173  default:
174  break;
175  }
176  }
177 
178 
179  void
180  Parser::yy_symbol_print_ (int yytype,
181  const semantic_type* yyvaluep, const location_type* yylocationp)
182  {
183  *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
184  << ' ' << yytname_[yytype] << " ("
185  << *yylocationp << ": ";
186  yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
187  *yycdebug_ << ')';
188  }
189 #endif /* ! YYDEBUG */
190 
191  void
192  Parser::yydestruct_ (const char* yymsg,
193  int yytype, semantic_type* yyvaluep, location_type* yylocationp)
194  {
195  YYUSE (yylocationp);
196  YYUSE (yymsg);
197  YYUSE (yyvaluep);
198 
199  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
200 
201  switch (yytype)
202  {
203 
204  default:
205  break;
206  }
207  }
208 
209  void
210  Parser::yypop_ (unsigned int n)
211  {
212  yystate_stack_.pop (n);
213  yysemantic_stack_.pop (n);
214  yylocation_stack_.pop (n);
215  }
216 
217  std::ostream&
218  Parser::debug_stream () const
219  {
220  return *yycdebug_;
221  }
222 
223  void
224  Parser::set_debug_stream (std::ostream& o)
225  {
226  yycdebug_ = &o;
227  }
228 
229 
230  Parser::debug_level_type
231  Parser::debug_level () const
232  {
233  return yydebug_;
234  }
235 
236  void
237  Parser::set_debug_level (debug_level_type l)
238  {
239  yydebug_ = l;
240  }
241 
242 
243  int
244  Parser::parse ()
245  {
247  int yychar = yyempty_;
248  int yytoken = 0;
249 
250  /* State. */
251  int yyn;
252  int yylen = 0;
253  int yystate = 0;
254 
255  /* Error handling. */
256  int yynerrs_ = 0;
257  int yyerrstatus_ = 0;
258 
260  semantic_type yylval;
262  location_type yylloc;
264  location yyerror_range[2];
265 
267  semantic_type yyval;
269  location_type yyloc;
270 
271  int yyresult;
272 
273  YYCDEBUG << "Starting parse" << std::endl;
274 
275 
276  /* Initialize the stacks. The initial state will be pushed in
277  yynewstate, since the latter expects the semantical and the
278  location values to have been already stored, initialize these
279  stacks with a primary value. */
280  yystate_stack_ = state_stack_type (0);
281  yysemantic_stack_ = semantic_stack_type (0);
282  yylocation_stack_ = location_stack_type (0);
283  yysemantic_stack_.push (yylval);
284  yylocation_stack_.push (yylloc);
285 
286  /* New state. */
287  yynewstate:
288  yystate_stack_.push (yystate);
289  YYCDEBUG << "Entering state " << yystate << std::endl;
290  goto yybackup;
291 
292  /* Backup. */
293  yybackup:
294 
295  /* Try to take a decision without look-ahead. */
296  yyn = yypact_[yystate];
297  if (yyn == yypact_ninf_)
298  goto yydefault;
299 
300  /* Read a look-ahead token. */
301  if (yychar == yyempty_)
302  {
303  YYCDEBUG << "Reading a token: ";
304  yychar = yylex (&yylval, lexer);
305  }
306 
307 
308  /* Convert token to internal form. */
309  if (yychar <= yyeof_)
310  {
311  yychar = yytoken = yyeof_;
312  YYCDEBUG << "Now at end of input." << std::endl;
313  }
314  else
315  {
316  yytoken = yytranslate_ (yychar);
317  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
318  }
319 
320  /* If the proper action on seeing token YYTOKEN is to reduce or to
321  detect an error, take that action. */
322  yyn += yytoken;
323  if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
324  goto yydefault;
325 
326  /* Reduce or error. */
327  yyn = yytable_[yyn];
328  if (yyn <= 0)
329  {
330  if (yyn == 0 || yyn == yytable_ninf_)
331  goto yyerrlab;
332  yyn = -yyn;
333  goto yyreduce;
334  }
335 
336  /* Accept? */
337  if (yyn == yyfinal_)
338  goto yyacceptlab;
339 
340  /* Shift the look-ahead token. */
341  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
342 
343  /* Discard the token being shifted unless it is eof. */
344  if (yychar != yyeof_)
345  yychar = yyempty_;
346 
347  yysemantic_stack_.push (yylval);
348  yylocation_stack_.push (yylloc);
349 
350  /* Count tokens shifted since error; after three, turn off error
351  status. */
352  if (yyerrstatus_)
353  --yyerrstatus_;
354 
355  yystate = yyn;
356  goto yynewstate;
357 
358  /*-----------------------------------------------------------.
359  | yydefault -- do the default action for the current state. |
360  `-----------------------------------------------------------*/
361  yydefault:
362  yyn = yydefact_[yystate];
363  if (yyn == 0)
364  goto yyerrlab;
365  goto yyreduce;
366 
367  /*-----------------------------.
368  | yyreduce -- Do a reduction. |
369  `-----------------------------*/
370  yyreduce:
371  yylen = yyr2_[yyn];
372  /* If YYLEN is nonzero, implement the default value of the action:
373  `$$ = $1'. Otherwise, use the top of the stack.
374 
375  Otherwise, the following line sets YYVAL to garbage.
376  This behavior is undocumented and Bison
377  users should not rely upon it. */
378  if (yylen)
379  yyval = yysemantic_stack_[yylen - 1];
380  else
381  yyval = yysemantic_stack_[0];
382 
383  {
384  slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
385  YYLLOC_DEFAULT (yyloc, slice, yylen);
386  }
387  YY_REDUCE_PRINT (yyn);
388  switch (yyn)
389  {
390  case 2:
391 #line 144 "qmake.yy"
392  {
393  ProjectAST *projectAST = new ProjectAST();
394  projects.push(projectAST);
395  ;}
396  break;
397 
398  case 4:
399 #line 152 "qmake.yy"
400  {
401  projects.top()->addChildAST((yysemantic_stack_[(2) - (2)].node));
402  (yysemantic_stack_[(2) - (2)].node)->setDepth(depth);
403  ;}
404  break;
405 
406  case 6:
407 #line 160 "qmake.yy"
408  {
409  (yyval.node) = (yysemantic_stack_[(1) - (1)].node);
410  ;}
411  break;
412 
413  case 7:
414 #line 164 "qmake.yy"
415  {
416  (yyval.node) = (yysemantic_stack_[(1) - (1)].node);
417  ;}
418  break;
419 
420  case 8:
421 #line 168 "qmake.yy"
422  {
423  (yyval.node) = (yysemantic_stack_[(1) - (1)].node);
424  ;}
425  break;
426 
427  case 9:
428 #line 172 "qmake.yy"
429  {
430  (yyval.node) = (yysemantic_stack_[(1) - (1)].node);
431  ;}
432  break;
433 
434  case 10:
435 #line 176 "qmake.yy"
436  {
437  (yyval.node) = new NewLineAST();
438  ;}
439  break;
440 
441  case 11:
442 #line 182 "qmake.yy"
443  {
444  AssignmentAST *node = new AssignmentAST();
445  node->scopedID = (yysemantic_stack_[(5) - (1)].value);
446  node->op = (yysemantic_stack_[(5) - (2)].value);
447  node->values = (yysemantic_stack_[(5) - (3)].values) ;
448  node->values.append( (yysemantic_stack_[(5) - (4)].value) );
449  node->values.append( (yysemantic_stack_[(5) - (5)].value) );
450  node->indent = (yysemantic_stack_[(5) - (3)].indent);
451  (yyval.node) = node;
452  ;}
453  break;
454 
455  case 12:
456 #line 193 "qmake.yy"
457  {
458  AssignmentAST *node = new AssignmentAST();
459  node->scopedID = (yysemantic_stack_[(5) - (1)].value);
460  node->op = (yysemantic_stack_[(5) - (2)].value);
461  node->values = (yysemantic_stack_[(5) - (3)].values) ;
462  node->values.append( (yysemantic_stack_[(5) - (4)].value) );
463  node->indent = (yysemantic_stack_[(5) - (3)].indent);
464  (yyval.node) = node;
465  ;}
466  break;
467 
468  case 13:
469 #line 203 "qmake.yy"
470  {
471  AssignmentAST *node = new AssignmentAST();
472  node->scopedID = (yysemantic_stack_[(5) - (1)].value);
473  node->op = (yysemantic_stack_[(5) - (2)].value);
474  node->values = (yysemantic_stack_[(5) - (3)].values) ;
475  node->values.append( (yysemantic_stack_[(5) - (4)].value) );
476  node->values.append( (yysemantic_stack_[(5) - (5)].value) );
477  node->indent = (yysemantic_stack_[(5) - (3)].indent);
478  (yyval.node) = node;
479  ;}
480  break;
481 
482  case 14:
483 #line 214 "qmake.yy"
484  {
485  AssignmentAST *node = new AssignmentAST();
486  node->scopedID = (yysemantic_stack_[(5) - (1)].value);
487  node->op = (yysemantic_stack_[(5) - (2)].value);
488  node->values = (yysemantic_stack_[(5) - (3)].values) ;
489  node->values.append( (yysemantic_stack_[(5) - (4)].value) );
490  node->values.append( (yysemantic_stack_[(5) - (5)].value) );
491  node->indent = (yysemantic_stack_[(5) - (3)].indent);
492  (yyval.node) = node;
493  ;}
494  break;
495 
496  case 15:
497 #line 225 "qmake.yy"
498  {
499  AssignmentAST *node = new AssignmentAST();
500  node->scopedID = (yysemantic_stack_[(4) - (1)].value);
501  node->op = (yysemantic_stack_[(4) - (2)].value);
502  node->values.append( (yysemantic_stack_[(4) - (3)].value) );
503  node->values.append( (yysemantic_stack_[(4) - (4)].value) );
504  (yyval.node) = node;
505  ;}
506  break;
507 
508  case 16:
509 #line 234 "qmake.yy"
510  {
511  AssignmentAST *node = new AssignmentAST();
512  node->scopedID = (yysemantic_stack_[(4) - (1)].value);
513  node->op = (yysemantic_stack_[(4) - (2)].value);
514  node->values.append( (yysemantic_stack_[(4) - (3)].value) );
515  (yyval.node) = node;
516  ;}
517  break;
518 
519  case 17:
520 #line 242 "qmake.yy"
521  {
522  AssignmentAST *node = new AssignmentAST();
523  node->scopedID = (yysemantic_stack_[(4) - (1)].value);
524  node->op = (yysemantic_stack_[(4) - (2)].value);
525  node->values.append( (yysemantic_stack_[(4) - (3)].value) );
526  node->values.append( (yysemantic_stack_[(4) - (4)].value) );
527  (yyval.node) = node;
528  ;}
529  break;
530 
531  case 18:
532 #line 251 "qmake.yy"
533  {
534  AssignmentAST *node = new AssignmentAST();
535  node->scopedID = (yysemantic_stack_[(5) - (1)].value);
536  node->op = (yysemantic_stack_[(5) - (2)].value);
537  node->values = (yysemantic_stack_[(5) - (3)].values);
538  node->values.append( (yysemantic_stack_[(5) - (4)].value) );
539  node->values.append( (yysemantic_stack_[(5) - (5)].value) );
540  node->indent = (yysemantic_stack_[(5) - (3)].indent);
541  (yyval.node) = node;
542  ;}
543  break;
544 
545  case 22:
546 #line 266 "qmake.yy"
547  {
548  (yyval.values).append( (yysemantic_stack_[(3) - (2)].value) );
549  (yyval.values).append( (yysemantic_stack_[(3) - (3)].value) );
550  ;}
551  break;
552 
553  case 23:
554 #line 271 "qmake.yy"
555  {
556  (yyval.values).append( (yysemantic_stack_[(2) - (2)].value) );
557  ;}
558  break;
559 
560  case 24:
561 #line 275 "qmake.yy"
562  {
563  (yyval.values).append( (yysemantic_stack_[(5) - (2)].value) );
564  (yyval.values).append( (yysemantic_stack_[(5) - (3)].value) );
565  (yyval.values).append( (yysemantic_stack_[(5) - (4)].value) );
566  (yyval.values).append( (yysemantic_stack_[(5) - (5)].value) );
567  if( (yysemantic_stack_[(5) - (4)].indent) != "" && (yyval.indent) == "" )
568  (yyval.indent) = (yysemantic_stack_[(5) - (4)].indent);
569  ;}
570  break;
571 
572  case 25:
573 #line 284 "qmake.yy"
574  {
575  (yyval.values).append( (yysemantic_stack_[(5) - (2)].value) );
576  (yyval.values).append( (yysemantic_stack_[(5) - (3)].value) );
577  (yyval.values).append( (yysemantic_stack_[(5) - (4)].value) );
578  (yyval.values).append( (yysemantic_stack_[(5) - (5)].value) );
579  if( (yysemantic_stack_[(5) - (4)].indent) != "" && (yyval.indent) == "" )
580  (yyval.indent) = (yysemantic_stack_[(5) - (4)].indent);
581  ;}
582  break;
583 
584  case 26:
585 #line 293 "qmake.yy"
586  {
587  (yyval.values) = TQStringList();
588  (yyval.values).append( (yysemantic_stack_[(2) - (1)].value) );
589  (yyval.values).append( (yysemantic_stack_[(2) - (2)].value) );
590  ;}
591  break;
592 
593  case 27:
594 #line 301 "qmake.yy"
595  { (yyval.value) = (yysemantic_stack_[(1) - (1)].value); ;}
596  break;
597 
598  case 28:
599 #line 302 "qmake.yy"
600  { (yyval.value) = (yysemantic_stack_[(1) - (1)].value); ;}
601  break;
602 
603  case 29:
604 #line 307 "qmake.yy"
605  {
606  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
607  (yyval.indent) = (yysemantic_stack_[(1) - (1)].value);
608  ;}
609  break;
610 
611  case 30:
612 #line 312 "qmake.yy"
613  {
614  (yyval.value) = TQString();
615  (yyval.indent) = TQString();
616  ;}
617  break;
618 
619  case 31:
620 #line 318 "qmake.yy"
621  {
622  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
623  ;}
624  break;
625 
626  case 32:
627 #line 322 "qmake.yy"
628  {
629  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
630  ;}
631  break;
632 
633  case 33:
634 #line 326 "qmake.yy"
635  {
636  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
637  ;}
638  break;
639 
640  case 34:
641 #line 330 "qmake.yy"
642  {
643  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
644  ;}
645  break;
646 
647  case 35:
648 #line 334 "qmake.yy"
649  {
650  (yyval.value) = (yysemantic_stack_[(1) - (1)].value);
651  ;}
652  break;
653 
654  case 36:
655 #line 340 "qmake.yy"
656  {
657  ProjectAST *projectAST = new ProjectAST(ProjectAST::Scope);
658  projects.push(projectAST);
659  projects.top()->scopedID = (yysemantic_stack_[(1) - (1)].value);
660  depth++;
661  ;}
662  break;
663 
664  case 37:
665 #line 347 "qmake.yy"
666  {
667  (yyval.node) = projects.pop();
668  depth--;
669  ;}
670  break;
671 
672  case 38:
673 #line 354 "qmake.yy"
674  {
675  ProjectAST *projectAST = new ProjectAST(ProjectAST::FunctionScope);
676  projects.push(projectAST);
677  projects.top()->scopedID = (yysemantic_stack_[(4) - (1)].value);
678  projects.top()->args = (yysemantic_stack_[(4) - (3)].value);
679  depth++;
680 
681  //tqWarning("%s", $<value>1.ascii());
682  if ((yysemantic_stack_[(4) - (1)].value).contains("include"))
683  {
684  IncludeAST *includeAST = new IncludeAST();
685  includeAST->projectName = (yysemantic_stack_[(4) - (3)].value);
686  projects.top()->addChildAST(includeAST);
687  includeAST->setDepth(depth);
688  }
689  ;}
690  break;
691 
692  case 39:
693 #line 372 "qmake.yy"
694  {
695  (yyval.node) = projects.pop();
696  depth--;
697  ;}
698  break;
699 
700  case 40:
701 #line 378 "qmake.yy"
702  { (yyval.value) = (yysemantic_stack_[(1) - (1)].value); ;}
703  break;
704 
705  case 41:
706 #line 379 "qmake.yy"
707  { (yyval.value) = ""; ;}
708  break;
709 
710  case 43:
711 #line 384 "qmake.yy"
712  {
713  projects.top()->addChildAST((yysemantic_stack_[(2) - (2)].node));
714  (yysemantic_stack_[(2) - (2)].node)->setDepth(depth);
715  ;}
716  break;
717 
718  case 45:
719 #line 392 "qmake.yy"
720  {
721  ProjectAST *projectAST = new ProjectAST(ProjectAST::FunctionScope);
722  projects.push(projectAST);
723  projects.top()->scopedID = "else";
724  projects.top()->args = "";
725  depth++;
726  ;}
727  break;
728 
729  case 46:
730 #line 400 "qmake.yy"
731  {
732  (yyval.node) = projects.pop();
733  depth--;
734  ;}
735  break;
736 
737  case 47:
738 #line 405 "qmake.yy"
739  {
740  (yyval.node) = new ProjectAST();
741  ;}
742  break;
743 
744  case 48:
745 #line 411 "qmake.yy"
746  {
747  CommentAST *node = new CommentAST();
748  node->comment = (yysemantic_stack_[(1) - (1)].value);
749  (yyval.node) = node;
750  ;}
751  break;
752 
753 
754  /* Line 675 of lalr1.cc. */
755 #line 756 "tqmake_yacc.cpp"
756  default: break;
757  }
758  YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
759 
760  yypop_ (yylen);
761  yylen = 0;
762  YY_STACK_PRINT ();
763 
764  yysemantic_stack_.push (yyval);
765  yylocation_stack_.push (yyloc);
766 
767  /* Shift the result of the reduction. */
768  yyn = yyr1_[yyn];
769  yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
770  if (0 <= yystate && yystate <= yylast_
771  && yycheck_[yystate] == yystate_stack_[0])
772  yystate = yytable_[yystate];
773  else
774  yystate = yydefgoto_[yyn - yyntokens_];
775  goto yynewstate;
776 
777  /*------------------------------------.
778  | yyerrlab -- here on detecting error |
779  `------------------------------------*/
780  yyerrlab:
781  /* If not already recovering from an error, report this error. */
782  if (!yyerrstatus_)
783  {
784  ++yynerrs_;
785  error (yylloc, yysyntax_error_ (yystate));
786  }
787 
788  yyerror_range[0] = yylloc;
789  if (yyerrstatus_ == 3)
790  {
791  /* If just tried and failed to reuse look-ahead token after an
792  error, discard it. */
793 
794  if (yychar <= yyeof_)
795  {
796  /* Return failure if at end of input. */
797  if (yychar == yyeof_)
798  YYABORT;
799  }
800  else
801  {
802  yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
803  yychar = yyempty_;
804  }
805  }
806 
807  /* Else will try to reuse look-ahead token after shifting the error
808  token. */
809  goto yyerrlab1;
810 
811 
812  /*---------------------------------------------------.
813  | yyerrorlab -- error raised explicitly by YYERROR. |
814  `---------------------------------------------------*/
815  yyerrorlab:
816 
817  /* Pacify compilers like GCC when the user code never invokes
818  YYERROR and the label yyerrorlab therefore never appears in user
819  code. */
820  if (false)
821  goto yyerrorlab;
822 
823  yyerror_range[0] = yylocation_stack_[yylen - 1];
824  /* Do not reclaim the symbols of the rule which action triggered
825  this YYERROR. */
826  yypop_ (yylen);
827  yylen = 0;
828  yystate = yystate_stack_[0];
829  goto yyerrlab1;
830 
831  /*-------------------------------------------------------------.
832  | yyerrlab1 -- common code for both syntax error and YYERROR. |
833  `-------------------------------------------------------------*/
834  yyerrlab1:
835  yyerrstatus_ = 3; /* Each real token shifted decrements this. */
836 
837  for (;;)
838  {
839  yyn = yypact_[yystate];
840  if (yyn != yypact_ninf_)
841  {
842  yyn += yyterror_;
843  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
844  {
845  yyn = yytable_[yyn];
846  if (0 < yyn)
847  break;
848  }
849  }
850 
851  /* Pop the current state because it cannot handle the error token. */
852  if (yystate_stack_.height () == 1)
853  YYABORT;
854 
855  yyerror_range[0] = yylocation_stack_[0];
856  yydestruct_ ("Error: popping",
857  yystos_[yystate],
858  &yysemantic_stack_[0], &yylocation_stack_[0]);
859  yypop_ ();
860  yystate = yystate_stack_[0];
861  YY_STACK_PRINT ();
862  }
863 
864  if (yyn == yyfinal_)
865  goto yyacceptlab;
866 
867  yyerror_range[1] = yylloc;
868  // Using YYLLOC is tempting, but would change the location of
869  // the look-ahead. YYLOC is available though.
870  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
871  yysemantic_stack_.push (yylval);
872  yylocation_stack_.push (yyloc);
873 
874  /* Shift the error token. */
875  YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
876  &yysemantic_stack_[0], &yylocation_stack_[0]);
877 
878  yystate = yyn;
879  goto yynewstate;
880 
881  /* Accept. */
882  yyacceptlab:
883  yyresult = 0;
884  goto yyreturn;
885 
886  /* Abort. */
887  yyabortlab:
888  yyresult = 1;
889  goto yyreturn;
890 
891  yyreturn:
892  if (yychar != yyeof_ && yychar != yyempty_)
893  yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
894 
895  /* Do not reclaim the symbols of the rule which action triggered
896  this YYABORT or YYACCEPT. */
897  yypop_ (yylen);
898  while (yystate_stack_.height () != 1)
899  {
900  yydestruct_ ("Cleanup: popping",
901  yystos_[yystate_stack_[0]],
902  &yysemantic_stack_[0],
903  &yylocation_stack_[0]);
904  yypop_ ();
905  }
906 
907  return yyresult;
908  }
909 
910  // Generate an error message.
911  std::string
912  Parser::yysyntax_error_ (int yystate)
913  {
914  std::string res;
915  YYUSE (yystate);
916 #if YYERROR_VERBOSE
917  int yyn = yypact_[yystate];
918  if (yypact_ninf_ < yyn && yyn <= yylast_)
919  {
920  /* Start YYX at -YYN if negative to avoid negative indexes in
921  YYCHECK. */
922  int yyxbegin = yyn < 0 ? -yyn : 0;
923 
924  /* Stay within bounds of both yycheck and yytname. */
925  int yychecklim = yylast_ - yyn + 1;
926  int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
927  int count = 0;
928  for (int x = yyxbegin; x < yyxend; ++x)
929  if (yycheck_[x + yyn] == x && x != yyterror_)
930  ++count;
931 
932  // FIXME: This method of building the message is not compatible
933  // with internationalization. It should work like yacc.c does it.
934  // That is, first build a string that looks like this:
935  // "syntax error, unexpected %s or %s or %s"
936  // Then, invoke YY_ on this string.
937  // Finally, use the string as a format to output
938  // yytname_[tok], etc.
939  // Until this gets fixed, this message appears in English only.
940  res = "syntax error, unexpected ";
941  res += yytnamerr_ (yytname_[tok]);
942  if (count < 5)
943  {
944  count = 0;
945  for (int x = yyxbegin; x < yyxend; ++x)
946  if (yycheck_[x + yyn] == x && x != yyterror_)
947  {
948  res += (!count++) ? ", expecting " : " or ";
949  res += yytnamerr_ (yytname_[x]);
950  }
951  }
952  }
953  else
954 #endif
955  res = YY_("syntax error");
956  return res;
957  }
958 
959 
960  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
961  STATE-NUM. */
962  const signed char Parser::yypact_ninf_ = -44;
963  const signed char
964  Parser::yypact_[] =
965  {
966  -44, 19, -44, -44, 8, 45, -44, -44, -44, -44,
967  -44, -44, -44, -44, -44, -44, -44, -44, -44, 12,
968  10, 31, -44, 24, -44, -15, -5, 8, -44, -44,
969  -44, -44, -44, 26, -44, 14, -44, -44, -44, -44,
970  -44, -44, -44, -44, 0, 31, -44, -44, -44, 18,
971  18, -44, -44, 20, 26, 26, 27, -44, -44, -44,
972  -44, 31, 39, -44
973  };
974 
975  /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
976  doesn't specify something else to do. Zero means the default is an
977  error. */
978  const unsigned char
979  Parser::yydefact_[] =
980  {
981  2, 0, 5, 1, 3, 36, 49, 48, 4, 6,
982  7, 8, 9, 10, 31, 32, 33, 34, 35, 41,
983  30, 44, 40, 0, 29, 30, 0, 0, 5, 37,
984  38, 28, 27, 29, 23, 0, 15, 17, 21, 20,
985  16, 26, 19, 43, 0, 44, 22, 11, 18, 13,
986  14, 12, 42, 47, 0, 0, 0, 39, 24, 25,
987  45, 44, 0, 46
988  };
989 
990  /* YYPGOTO[NTERM-NUM]. */
991  const signed char
992  Parser::yypgoto_[] =
993  {
994  -44, -44, -44, 7, 29, -44, -32, -44, 22, -25,
995  -44, -44, -44, -44, -44, -44, -43, -44, -44, -44,
996  -44
997  };
998 
999  /* YYDEFGOTO[NTERM-NUM]. */
1000  const signed char
1001  Parser::yydefgoto_[] =
1002  {
1003  -1, 1, 2, 4, 8, 9, 41, 25, 42, 26,
1004  20, 10, 21, 11, 45, 23, 29, 57, 61, 12,
1005  13
1006  };
1007 
1008  /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1009  positive, shift that token. If negative, reduce the rule which
1010  number is the opposite. If zero, do what YYDEFACT says. */
1011  const signed char Parser::yytable_ninf_ = -31;
1012  const signed char
1013  Parser::yytable_[] =
1014  {
1015  35, 46, 53, 5, 31, 32, 33, 36, 37, 38,
1016  39, 5, 6, 7, 31, 32, 52, 40, 62, 3,
1017  6, 7, 58, 59, 54, 55, 47, 48, 49, 50,
1018  22, 24, -30, -30, 30, 44, 51, -30, -30, 24,
1019  38, 39, 27, 56, 60, 31, 32, 34, 28, 14,
1020  15, 16, 17, 18, 19, 63, 43
1021  };
1022 
1023  /* YYCHECK. */
1024  const unsigned char
1025  Parser::yycheck_[] =
1026  {
1027  25, 33, 45, 3, 19, 20, 21, 12, 13, 14,
1028  15, 3, 12, 13, 19, 20, 16, 22, 61, 0,
1029  12, 13, 54, 55, 49, 50, 12, 13, 14, 15,
1030  18, 21, 14, 15, 10, 28, 22, 19, 20, 21,
1031  14, 15, 11, 23, 17, 19, 20, 25, 17, 4,
1032  5, 6, 7, 8, 9, 16, 27
1033  };
1034 
1035  /* STOS_[STATE-NUM] -- The (internal number of the) accessing
1036  symbol of state STATE-NUM. */
1037  const unsigned char
1038  Parser::yystos_[] =
1039  {
1040  0, 25, 26, 0, 27, 3, 12, 13, 28, 29,
1041  35, 37, 43, 44, 4, 5, 6, 7, 8, 9,
1042  34, 36, 18, 39, 21, 31, 33, 11, 17, 40,
1043  10, 19, 20, 21, 32, 33, 12, 13, 14, 15,
1044  22, 30, 32, 28, 27, 38, 30, 12, 13, 14,
1045  15, 22, 16, 40, 33, 33, 23, 41, 30, 30,
1046  17, 42, 40, 16
1047  };
1048 
1049 #if YYDEBUG
1050  /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
1051  to YYLEX-NUM. */
1052  const unsigned short int
1053  Parser::yytoken_number_[] =
1054  {
1055  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1056  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1057  275, 276, 277, 278
1058  };
1059 #endif
1060 
1061  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1062  const unsigned char
1063  Parser::yyr1_[] =
1064  {
1065  0, 24, 26, 25, 27, 27, 28, 28, 28, 28,
1066  28, 29, 29, 29, 29, 29, 29, 29, 29, 30,
1067  30, 30, 31, 31, 31, 31, 31, 32, 32, 33,
1068  33, 34, 34, 34, 34, 34, 36, 35, 38, 37,
1069  39, 39, 40, 40, 40, 42, 41, 41, 43, 44
1070  };
1071 
1072  /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1073  const unsigned char
1074  Parser::yyr2_[] =
1075  {
1076  0, 2, 0, 2, 2, 0, 1, 1, 1, 1,
1077  1, 5, 5, 5, 5, 4, 4, 4, 5, 1,
1078  1, 1, 3, 2, 5, 5, 2, 1, 1, 1,
1079  0, 1, 1, 1, 1, 1, 0, 3, 0, 7,
1080  1, 0, 3, 2, 0, 0, 5, 0, 1, 1
1081  };
1082 
1083 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1084  /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1085  First, the terminals, then, starting at \a yyntokens_, nonterminals. */
1086  const char*
1087  const Parser::yytname_[] =
1088  {
1089  "$end", "error", "$undefined", "ID_SIMPLE", "EQ", "PLUSEQ", "MINUSEQ",
1090  "STAREQ", "TILDEEQ", "LBRACE", "RBRACE", "COLON", "NEWLINE", "COMMENT",
1091  "CONT", "COMMENT_CONT", "RCURLY", "LCURLY", "ID_ARGS",
1092  "QUOTED_VARIABLE_VALUE", "VARIABLE_VALUE", "LIST_WS", "ENDOFFILE",
1093  "\"else\"", "$accept", "project", "@1", "statements", "statement",
1094  "variable_assignment", "possible_value", "multiline_values",
1095  "variable_value", "listws", "operator", "scope", "@2", "function_call",
1096  "@3", "function_args", "scope_body", "else_statement", "@4", "comment",
1097  "emptyline", 0
1098  };
1099 #endif
1100 
1101 #if YYDEBUG
1102  /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1103  const Parser::rhs_number_type
1104  Parser::yyrhs_[] =
1105  {
1106  25, 0, -1, -1, 26, 27, -1, 27, 28, -1,
1107  -1, 29, -1, 35, -1, 37, -1, 43, -1, 44,
1108  -1, 3, 34, 31, 33, 12, -1, 3, 34, 31,
1109  33, 22, -1, 3, 34, 31, 33, 14, -1, 3,
1110  34, 31, 33, 15, -1, 3, 34, 33, 12, -1,
1111  3, 34, 33, 22, -1, 3, 34, 33, 13, -1,
1112  3, 34, 31, 33, 13, -1, 32, -1, 15, -1,
1113  14, -1, 31, 21, 30, -1, 31, 32, -1, 31,
1114  33, 14, 33, 30, -1, 31, 33, 15, 33, 30,
1115  -1, 33, 30, -1, 20, -1, 19, -1, 21, -1,
1116  -1, 4, -1, 5, -1, 6, -1, 7, -1, 8,
1117  -1, -1, 3, 36, 40, -1, -1, 3, 9, 39,
1118  10, 38, 40, 41, -1, 18, -1, -1, 17, 27,
1119  16, -1, 11, 28, -1, -1, -1, 23, 17, 42,
1120  40, 16, -1, -1, 13, -1, 12, -1
1121  };
1122 
1123  /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1124  YYRHS. */
1125  const unsigned char
1126  Parser::yyprhs_[] =
1127  {
1128  0, 0, 3, 4, 7, 10, 11, 13, 15, 17,
1129  19, 21, 27, 33, 39, 45, 50, 55, 60, 66,
1130  68, 70, 72, 76, 79, 85, 91, 94, 96, 98,
1131  100, 101, 103, 105, 107, 109, 111, 112, 116, 117,
1132  125, 127, 128, 132, 135, 136, 137, 143, 144, 146
1133  };
1134 
1135  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1136  const unsigned short int
1137  Parser::yyrline_[] =
1138  {
1139  0, 144, 144, 144, 151, 156, 159, 163, 167, 171,
1140  175, 181, 192, 202, 213, 224, 233, 241, 250, 263,
1141  263, 263, 265, 270, 274, 283, 292, 301, 302, 306,
1142  312, 317, 321, 325, 329, 333, 340, 339, 354, 353,
1143  378, 379, 382, 383, 388, 392, 391, 405, 410, 418
1144  };
1145 
1146  // Print the state stack on the debug stream.
1147  void
1148  Parser::yystack_print_ ()
1149  {
1150  *yycdebug_ << "Stack now";
1151  for (state_stack_type::const_iterator i = yystate_stack_.begin ();
1152  i != yystate_stack_.end (); ++i)
1153  *yycdebug_ << ' ' << *i;
1154  *yycdebug_ << std::endl;
1155  }
1156 
1157  // Report on the debug stream that the rule \a yyrule is going to be reduced.
1158  void
1159  Parser::yy_reduce_print_ (int yyrule)
1160  {
1161  unsigned int yylno = yyrline_[yyrule];
1162  int yynrhs = yyr2_[yyrule];
1163  /* Print the symbols being reduced, and their result. */
1164  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1165  << " (line " << yylno << "), ";
1166  /* The symbols being reduced. */
1167  for (int yyi = 0; yyi < yynrhs; yyi++)
1168  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1169  yyrhs_[yyprhs_[yyrule] + yyi],
1170  &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
1171  &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
1172  }
1173 #endif // YYDEBUG
1174 
1175  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1176  Parser::token_number_type
1177  Parser::yytranslate_ (int t)
1178  {
1179  static
1180  const token_number_type
1181  translate_table[] =
1182  {
1183  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1184  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1185  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1188  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1189  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1190  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1191  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1194  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1196  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1197  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1198  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1199  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1200  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1201  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1202  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1203  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1204  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1205  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1206  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1207  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1208  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1209  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1210  15, 16, 17, 18, 19, 20, 21, 22, 23
1211  };
1212  if ((unsigned int) t <= yyuser_token_number_max_)
1213  return translate_table[t];
1214  else
1215  return yyundef_token_;
1216  }
1217 
1218  const int Parser::yyeof_ = 0;
1219  const int Parser::yylast_ = 56;
1220  const int Parser::yynnts_ = 21;
1221  const int Parser::yyempty_ = -2;
1222  const int Parser::yyfinal_ = 3;
1223  const int Parser::yyterror_ = 1;
1224  const int Parser::yyerrcode_ = 256;
1225  const int Parser::yyntokens_ = 24;
1226 
1227  const unsigned int Parser::yyuser_token_number_max_ = 278;
1228  const Parser::token_number_type Parser::yyundef_token_ = 2;
1229 
1230 } // namespace TQMake
1231 
1232 #line 421 "qmake.yy"
1233 
1234 
1235 
1236 namespace TQMake
1237 {
1238  void Parser::error(const location_type& /*l*/, const std::string& m)
1239  {
1240  std::cerr << m << std::endl;
1241  }
1242 }
1243 
TQMake::AST::setDepth
void setDepth(int depth)
Sets the depth of the node in AST.
Definition: qmakeast.h:75
TQMake::IncludeAST
Include AST node.
Definition: qmakeast.h:225
TQMake::AssignmentAST::values
TQStringList values
List of values.
Definition: qmakeast.h:186
TQMake::NewLineAST
New line AST node.
Definition: qmakeast.h:196
TQMake::ProjectAST
Project AST node.
Definition: qmakeast.h:106
TQMake::location
Abstract a location.
Definition: location.hh:51
TQMake
Definition: location.hh:47
TQMake::Parser::set_debug_stream
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: qmake_yacc.cpp:224
TQMake::Result
The yylval type.
Definition: qmake_yacc.hpp:101
TQMake::Parser::set_debug_level
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: qmake_yacc.cpp:237
TQMake::ProjectAST::Scope
Scope.
Definition: qmakeast.h:111
TQMake::Parser::debug_level_type
int debug_level_type
Type for debugging levels.
Definition: qmake_yacc.hpp:265
TQMake::CommentAST::comment
TQString comment
Comment text.
Definition: qmakeast.h:216
TQMake::ProjectAST::FunctionScope
FunctionScope.
Definition: qmakeast.h:112
TQMake::AssignmentAST::scopedID
TQString scopedID
Scoped name of the variable.
Definition: qmakeast.h:182
TQMake::Result::values
TQStringList values
Type of semantic value for "multiline_values" grammar rule.
Definition: qmake_yacc.hpp:124
TQMake::AssignmentAST::op
TQString op
Operator.
Definition: qmakeast.h:184
TQMake::CommentAST
Comment AST node.
Definition: qmakeast.h:209
TQMake::Parser::Parser
Parser(TQMake::Lexer *lexer_yyarg, TQValueStack< ProjectAST *> &projects_yyarg, int depth_yyarg)
Build a parser object.
Definition: qmake_yacc.cpp:147
TQMake::AssignmentAST
Assignment AST node.
Definition: qmakeast.h:174
TQMake::slice
Present a slice of the top of a stack.
Definition: stack.hh:105
TQMake::Result::value
TQString value
Type of semantic value for simple grammar rules.
Definition: qmake_yacc.hpp:105
TQMake::Parser::parse
virtual int parse()
Parse.
Definition: qmake_yacc.cpp:244
TQMake::Parser::debug_stream
std::ostream & debug_stream() const
The current debugging stream.
Definition: qmake_yacc.cpp:218
TQMake::Result::node
AST * node
Type of semantic value for grammar rules which are parts of AST.
Definition: qmake_yacc.hpp:107
TQMake::Parser::debug_level
debug_level_type debug_level() const
The current debugging level.
Definition: qmake_yacc.cpp:231
TQMake::AssignmentAST::indent
TQString indent
Indentation of multiline values.
Definition: qmakeast.h:188

KDevelop QMake parser

Skip menu "KDevelop QMake parser"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDevelop QMake parser

Skip menu "KDevelop QMake parser"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop QMake parser by doxygen 1.8.13
This website is maintained by Timothy Pearson.