work save: start to write parser

This commit is contained in:
royqh1979@gmail.com 2021-08-05 23:13:21 +08:00
parent 82f548a3b8
commit 0b2fd71df6
7 changed files with 1296 additions and 166 deletions

View File

@ -16,6 +16,8 @@ SOURCES += \
compiler/executablerunner.cpp \ compiler/executablerunner.cpp \
compiler/filecompiler.cpp \ compiler/filecompiler.cpp \
compiler/stdincompiler.cpp \ compiler/stdincompiler.cpp \
parser/cpppreprocessor.cpp \
parser/statementmodel.cpp \
qsynedit/Search.cpp \ qsynedit/Search.cpp \
qsynedit/SearchBase.cpp \ qsynedit/SearchBase.cpp \
qsynedit/SearchRegex.cpp \ qsynedit/SearchRegex.cpp \
@ -73,6 +75,9 @@ HEADERS += \
compiler/executablerunner.h \ compiler/executablerunner.h \
compiler/filecompiler.h \ compiler/filecompiler.h \
compiler/stdincompiler.h \ compiler/stdincompiler.h \
parser/cpppreprocessor.h \
parser/statementmodel.h \
parser/utils.h \
qsynedit/Search.h \ qsynedit/Search.h \
qsynedit/SearchBase.h \ qsynedit/SearchBase.h \
qsynedit/SearchRegex.h \ qsynedit/SearchRegex.h \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
#include "cpppreprocessor.h"
CppPreprocessor::CppPreprocessor(QObject *parent) : QObject(parent)
{
}

View File

@ -0,0 +1,16 @@
#ifndef CPPPREPROCESSOR_H
#define CPPPREPROCESSOR_H
#include <QObject>
class CppPreprocessor : public QObject
{
Q_OBJECT
public:
explicit CppPreprocessor(QObject *parent = nullptr);
signals:
};
#endif // CPPPREPROCESSOR_H

View File

@ -0,0 +1,6 @@
#include "statementmodel.h"
StatementModel::StatementModel(QObject *parent) : QObject(parent)
{
}

View File

@ -0,0 +1,16 @@
#ifndef STATEMENTMODEL_H
#define STATEMENTMODEL_H
#include <QObject>
class StatementModel : public QObject
{
Q_OBJECT
public:
explicit StatementModel(QObject *parent = nullptr);
signals:
};
#endif // STATEMENTMODEL_H

View File

@ -0,0 +1,51 @@
#ifndef PARSER_UTILS_H
#define PARSER_UTILS_H
#include <QObject>
#include <memory>
// preprocess/ macro define
struct Define {
QString Name;
QString args;
QString value;
QString filename;
bool isMultiLine; // if true the expanded macro will span multiline
bool hardCoded;// if true, don't free memory (points to hard defines)
QStringList argList; // args list to format values
QString formatValue; // format template to format values
};
using PDefine = std::shared_ptr<Define>;
enum class SkipType {
skItself, // skip itself
skToSemicolon, // skip to ;
skToColon, // skip to :
skToRightParenthesis, // skip to )
skToLeftBrace,// Skip to {
skToRightBrace, // skip to }
skNone // It's a keyword but don't process here
};
enum class StatementKind {
skUnknown,
skPreprocessor,
skEnumType,
skEnum,
skTypedef,
skClass,
skFunction,
skConstructor,
skDestructor,
skVariable,
skParameter,
skNamespace,
skNamespaceAlias,
skBlock,
skUserCodeIn, // user code template
skKeyword, // keywords
skGlobalVariable,
skLocalVariable,
skAlias
};
#endif // PARSER_UTILS_H