Mercurial > projects > qtd
annotate generator/parser/control.cpp @ 413:bdc08c8391ad
removed unnecessary regex grouping
author | Max Samukha <maxsamukha@gmail.com> |
---|---|
date | Thu, 05 May 2011 22:32:50 +0300 |
parents | 09a0f1d048f2 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 | |
45 #include "control.h" | |
46 #include "lexer.h" | |
47 | |
48 Control::Control() | |
49 : current_context(0), | |
50 _M_skipFunctionBody(false), | |
51 _M_lexer(0), | |
52 _M_parser(0) | |
53 { | |
54 pushContext(); | |
55 | |
56 declareTypedef(findOrInsertName("__builtin_va_list", | |
57 strlen("__builtin_va_list")), 0); | |
58 } | |
59 | |
60 Control::~Control() | |
61 { | |
62 popContext(); | |
63 | |
64 Q_ASSERT(current_context == 0); | |
65 } | |
66 | |
67 Lexer *Control::changeLexer(Lexer *lexer) | |
68 { | |
69 Lexer *old = _M_lexer; | |
70 _M_lexer = lexer; | |
71 return old; | |
72 } | |
73 | |
74 Parser *Control::changeParser(Parser *parser) | |
75 { | |
76 Parser *old = _M_parser; | |
77 _M_parser = parser; | |
78 return old; | |
79 } | |
80 | |
81 Type *Control::lookupType(const NameSymbol *name) const | |
82 { | |
83 Q_ASSERT(current_context != 0); | |
84 | |
85 return current_context->resolve(name); | |
86 } | |
87 | |
88 void Control::declare(const NameSymbol *name, Type *type) | |
89 { | |
90 //printf("*** Declare:"); | |
91 //printSymbol(name); | |
92 //putchar('\n'); | |
93 Q_ASSERT(current_context != 0); | |
94 | |
95 current_context->bind(name, type); | |
96 } | |
97 | |
98 void Control::pushContext() | |
99 { | |
100 // printf("+Context\n"); | |
101 Context *new_context = new Context; | |
102 new_context->parent = current_context; | |
103 current_context = new_context; | |
104 } | |
105 | |
106 void Control::popContext() | |
107 { | |
108 // printf("-Context\n"); | |
109 Q_ASSERT(current_context != 0); | |
110 | |
111 Context *old_context = current_context; | |
112 current_context = current_context->parent; | |
113 | |
114 delete old_context; | |
115 } | |
116 | |
117 void Control::declareTypedef(const NameSymbol *name, Declarator *d) | |
118 { | |
119 // printf("declared typedef:"); | |
120 // printSymbol(name); | |
121 // printf("\n"); | |
122 stl_typedef_table.insert(name, d); | |
123 } | |
124 | |
125 bool Control::isTypedef(const NameSymbol *name) const | |
126 { | |
127 // printf("is typedef:"); | |
128 // printSymbol(name); | |
129 // printf("= %d\n", (stl_typedef_table.find(name) != stl_typedef_table.end())); | |
130 | |
131 return stl_typedef_table.contains(name); | |
132 } | |
133 | |
134 QList<Control::ErrorMessage> Control::errorMessages () const | |
135 { | |
136 return _M_error_messages; | |
137 } | |
138 | |
139 void Control::clearErrorMessages () | |
140 { | |
141 _M_error_messages.clear (); | |
142 } | |
143 | |
144 void Control::reportError (const ErrorMessage &errmsg) | |
145 { | |
146 _M_error_messages.append(errmsg); | |
147 } | |
148 | |
149 // kate: space-indent on; indent-width 2; replace-tabs on; |