Debian Codegraph @

Source/Parser/CKRSSOntologyParser.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_PARSER_CKRSSONTOLOGYPARSER_H
22 #define KONCLUDE_PARSER_CKRSSONTOLOGYPARSER_H
23
24 // Libraries includes
25 #include <QDomDocument>
26 #include <QDomElement>
27
28 // Namespace includes
29 #include "COntologyParser.h"
30 #include "COntologyBuilder.h"
31
32
33 // Other includes
34 #include "Control/Command/CCommandRecordRouter.h"
35 #include "Control/Command/Records/CNotSupportedNodeErrorRecord.h"
36
37 #include "Logger/CLogIdentifier.h"
38
39 #include "Utilities/Container/CQtHash.h"
40
41
42 // Logger includes
43 #include "Logger/CLogger.h"
44
45 using namespace Konclude::Logger;
46
47 using namespace std;
48
49
50 namespace Konclude {
51
52 using namespace Utilities::Container;
53 using namespace Control::Command;
54 using namespace Control::Command::Records;
55
56 namespace Parser {
57
58
59
60 #define KONCLUDE_PARSER_USEPARSEJUMPFUNCTIONHASH
61
62
63 /*!
64 *
65 * \class CKRSSOntologyParser
66 * \author Andreas Steigmiller
67 * \version 0.1
68 * \brief Parser for KRSS Text
69 *
70 */
71 class CKRSSOntologyParser : public CLogIdentifier {
72 // public methods
73 public:
74 //! Constructor
75 CKRSSOntologyParser(COntologyBuilder* ontoBuilder);
76 CKRSSOntologyParser(COntologyBuilder* ontoBuilder, const QString& defNameString, CCommandRecordRouter* commandRecordRouter);
77
78 //! Destructor
79 virtual ~CKRSSOntologyParser();
80
81 virtual bool parseOntologyFile(const QString& filename);
82 virtual bool parseOntologyText(const QString& text);
83 virtual CBuildExpression* parseKRSSLine(const QString& line);
84
85 // protected methods
86 protected:
87 bool initializeParseFunctionJumpHash();
88
89 CBuildExpression* parseKRSSExpression(const QString& text, cint64& index);
90 QList<CBuildExpression* > parseClassChildNodes(const QString& text, cint64& index);
91 QList<CBuildExpression* > parseSpecialClassChildNodes(const QString& text, const QString& identicalChild, cint64& index);
92
93 QList<CBuildExpression* > parsePropertyClassChildNodes(const QString& text, cint64& index);
94
95
96 QString parseIdentifierNode(const QString& text, cint64& index);
97 bool checkIdentifierNode(const QString& text, const QString& expectedString, cint64& index);
98
99 CClassTermExpression* parseClassNode(const QString& text, cint64& index);
100 CObjectPropertyExpression* parseObjectPropertyNode(const QString& text, cint64& index);
101
102 CDeclarationAxiomExpression* parseDeclarationNode(CBuildExpression* expression);
103
104
105 CBuildExpression* parseObjectIntersectionOfNode(const QString& text, cint64& index);
106 CBuildExpression* parseObjectUnionOfNode(const QString& text, cint64& index);
107 CBuildExpression* parseObjectSomeValuesFromNode(const QString& text, cint64& index);
108 CBuildExpression* parseObjectAllValuesFromNode(const QString& text, cint64& index);
109 CBuildExpression* parseObjectComplementOfNode(const QString& text, cint64& index);
110
111
112
113
114
115 CBuildExpression* jumpFunctionParseObjectIntersectionOfNode(const QString& text, cint64& index);
116 CBuildExpression* jumpFunctionParseObjectUnionOfNode(const QString& text, cint64& index);
117 CBuildExpression* jumpFunctionParseObjectSomeValuesFromNode(const QString& text, cint64& index);
118 CBuildExpression* jumpFunctionParseObjectAllValuesFromNode(const QString& text, cint64& index);
119 CBuildExpression* jumpFunctionParseObjectComplementOfNode(const QString& text, cint64& index);
120
121
122 // protected variables
123 protected:
124 CCommandRecordRouter recordRouter;
125 COntologyBuilder* mOntoBuilder;
126
127 typedef CBuildExpression* (CKRSSOntologyParser::*ParseFunction) (const QString& text, cint64& index);
128
129 CQtHash<QString,ParseFunction> mParseFunctionJumpHash;
130
131 QString mDefName;
132 cint64 mDefNumber;
133
134
135 // private methods
136 private:
137
138
139 // private variables
140 private:
141
142
143
144 };
145
146 }; // end namespace Parser
147
148 }; // end namespace Konclude
149
150 #endif // KONCLUDE_PARSER_CKRSSONTOLOGYPARSER_H