author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the utils of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef CPPGENERATOR_H |
|
43 |
#define CPPGENERATOR_H |
|
44 |
||
45 |
#include "lalr.h" |
|
46 |
#include "compress.h" |
|
47 |
||
48 |
class Grammar; |
|
49 |
class Automaton; |
|
50 |
class Recognizer; |
|
51 |
||
52 |
class CppGenerator |
|
53 |
{ |
|
54 |
public: |
|
55 |
CppGenerator(const Recognizer &p, Grammar &grammar, Automaton &aut, bool verbose): |
|
56 |
p (p), |
|
57 |
grammar (grammar), |
|
58 |
aut (aut), |
|
59 |
verbose (verbose), |
|
60 |
debug_info (false), |
|
61 |
copyright (false) {} |
|
62 |
||
63 |
void operator () (); |
|
64 |
||
65 |
bool debugInfo () const { return debug_info; } |
|
66 |
void setDebugInfo (bool d) { debug_info = d; } |
|
67 |
||
68 |
void setCopyright (bool t) { copyright = t; } |
|
69 |
||
70 |
private: |
|
71 |
void generateDecl (QTextStream &out); |
|
72 |
void generateImpl (QTextStream &out); |
|
73 |
||
74 |
QString debugInfoProt() const; |
|
75 |
QString copyrightHeader() const; |
|
76 |
QString privateCopyrightHeader() const; |
|
77 |
||
78 |
private: |
|
79 |
static QString startIncludeGuard(const QString &fileName); |
|
80 |
static QString endIncludeGuard(const QString &fileName); |
|
81 |
||
82 |
const Recognizer &p; |
|
83 |
Grammar &grammar; |
|
84 |
Automaton &aut; |
|
85 |
bool verbose; |
|
86 |
int accept_state; |
|
87 |
int state_count; |
|
88 |
int terminal_count; |
|
89 |
int non_terminal_count; |
|
90 |
bool debug_info; |
|
91 |
bool copyright; |
|
92 |
Compress compressed_action; |
|
93 |
Compress compressed_goto; |
|
94 |
QVector<int> count; |
|
95 |
QVector<int> defgoto; |
|
96 |
}; |
|
97 |
||
98 |
#endif // CPPGENERATOR_H |