diff --git a/SyntacticAnalyzer/SyntacticAnalyzer.sln b/SyntacticAnalyzer/SyntacticAnalyzer.sln deleted file mode 100644 index 0828d04..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.13 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyntacticAnalyzer", "SyntacticAnalyzer\SyntacticAnalyzer.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.cpp deleted file mode 100644 index 12fca91..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "AnalysisStep.h" - -AnalysisStep::AnalysisStep(QWidget *parent) - : QWidget(parent) { - ui.setupUi(this); - setp_model = new TableModel; - ui.setp_table->setEditTriggers(QAbstractItemView::NoEditTriggers); - init_table(); - -} - -void AnalysisStep::add_step(map> setp) { - map>:: iterator it = setp.begin(); - map>::iterator end = setp.end(); - vector::iterator str_it; - vector::iterator str_end; - int row = 0; - int col = 0; - for (it; it != end; it++) { - int size = it->second.size(); - //qDebug() << "size=" << QString("%1").arg(size); - //setp_model->setHeaderData(row, Qt::Vertical, QString("%1").arg(it->first)); - col = 0; - setp_model->setItem(row, col, new QStandardItem(QString("%1").arg(it->first))); - str_it = it->second.begin(); - str_end = it->second.end(); - for (str_it; str_it != str_end; str_it++) { - setp_model->setItem(row, col, new QStandardItem(QString::fromLocal8Bit(str_it->data()))); - col++; - } - row++; - } -} - -void AnalysisStep::clear_table() { - setp_model->clear(); - init_table(); -} - -AnalysisStep::~AnalysisStep() { - delete setp_model; -} - -void AnalysisStep::init_table() { - setp_model->setColumnCount(5); - //setp_model->setHeaderData(0, Qt::Horizontal, QString::fromLocal8Bit("")); - setp_model->setHeaderData(0, Qt::Horizontal, QString::fromLocal8Bit("ջ״̬")); - setp_model->setHeaderData(1, Qt::Horizontal, QString::fromLocal8Bit("ϵ")); - setp_model->setHeaderData(2, Qt::Horizontal, QString::fromLocal8Bit("봮״̬")); - setp_model->setHeaderData(3, Qt::Horizontal, QString::fromLocal8Bit("ض")); - setp_model->setHeaderData(4, Qt::Horizontal, QString::fromLocal8Bit("")); - ui.setp_table->setModel(setp_model); - ui.setp_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - ui.setp_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.h b/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.h deleted file mode 100644 index cc8df7e..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.h +++ /dev/null @@ -1,30 +0,0 @@ -///================================================================================================= -/// \file AnalysisStep.h -/// -/// \brief ʾ洦 -///================================================================================================= - -#pragma once - -#include -#include "ui_AnalysisStep.h" -#include "TableModel.h" -#include -#include -#include -#include -using namespace std; -class AnalysisStep : public QWidget { - Q_OBJECT - - public: - AnalysisStep(QWidget *parent = Q_NULLPTR); - void add_step(map> setp); - void clear_table(); - ~AnalysisStep(); - - private: - Ui::AnalysisStep ui; - TableModel *setp_model; - void init_table(); -}; diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.ui b/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.ui deleted file mode 100644 index ff4a93f..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/AnalysisStep.ui +++ /dev/null @@ -1,53 +0,0 @@ - - - AnalysisStep - - - - 0 - 0 - 811 - 800 - - - - 分析过程 - - - - - - QHeaderView::section { - color: white; - background-color: rgb(0, 170, 255); - border: 5px solid #f6f7fa; - border-radius:0px; - border-color: rgb(0, 170, 255); -} - - - false - - - false - - - false - - - true - - - false - - - false - - - - - - - - - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/Config.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/Config.cpp deleted file mode 100644 index d1f8f63..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/Config.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "Config.h" -#include -Config::Config(QWidget *parent) - : QWidget(parent) { - ui.setupUi(this); - connect(ui.open_terminals, SIGNAL(clicked()), this, SLOT(open_terminal())); - connect(ui.open_garmms, SIGNAL(clicked()), this, SLOT(open_grammars())); - connect(ui.ok, SIGNAL(clicked()), this, SLOT(ok_btn())); - connect(this, SIGNAL(file_type_send(int)), this, SLOT(open_file(int))); - read_setting(); -} - - -void Config::connect_signal_slot() { - connect(ui.open_terminals, SIGNAL(clicked()), this, SLOT(open_terminal())); - connect(ui.open_garmms, SIGNAL(clicked()), this, SLOT(open_grammars())); - connect(ui.ok, SIGNAL(clicked()), this, SLOT(ok_btn())); - connect(this, SIGNAL(file_type_send(int)), this, SLOT(open_file(int))); -} - -QString Config::get_grammars_path() { - return ui.garmmars_path->text(); -} - -QString Config::get_terminal_path() { - return ui.terminals_path->text(); -} - -Config::~Config() { -} - -void Config::open_file(int file_type) { - qDebug() << "open"; - QFileDialog *file_dialog = new QFileDialog(this); // Ի - file_dialog->setWindowTitle(QString::fromLocal8Bit("ļ")); //ļԻ - file_dialog->setDirectory("."); //Ĭļ· - file_dialog->setNameFilter(tr("file(*.txt)")); //ļ - file_dialog->setFileMode(QFileDialog::ExistingFile); //ļ - file_dialog->setViewMode(QFileDialog::Detail); //ͼģʽ - QString file_path; - if (file_dialog->exec()) { - QByteArray file_name_btye = file_dialog->selectedFiles()[0].toLocal8Bit(); - std::string file_name = file_name_btye.toStdString(); - file_path = QFileInfo(QString::fromStdString(file_name)).absoluteFilePath(); - if (file_type == 0) { - teminanls_path = file_path; - ui.terminals_path->setText(file_path); - - } else { - grammars_path = file_path; - ui.garmmars_path->setText(file_path); - } - - } - delete file_dialog; -} - -void Config::read_setting() { - QSettings *read = new QSettings("config.ini", QSettings::IniFormat); - QString file_name = QFileInfo(QString::fromLocal8Bit(read->value("/path/terminals").toByteArray())).absoluteFilePath(); - ui.terminals_path->setText(file_name); - file_name = QFileInfo(QString::fromLocal8Bit(read->value("/path/grammars").toByteArray())).absoluteFilePath(); - ui.garmmars_path->setText(file_name); - delete read; -} - -void Config::wirte_setting() { - QSettings *write = new QSettings("config.ini", QSettings::IniFormat); - QString file_name = ui.terminals_path->text(); - write->setValue("/path/terminals", file_name); - file_name = ui.garmmars_path->text(); - write->setValue("/path/grammars", file_name); - delete write; -} - -void Config::open_terminal() { - emit file_type_send(0); -} - -void Config::open_grammars() { - emit file_type_send(1); -} - -void Config::ok_btn() { - emit finish(); - emit teminanls_file(ui.terminals_path->text()); - emit grammars_file(ui.garmmars_path->text()); - wirte_setting(); - -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/Config.h b/SyntacticAnalyzer/SyntacticAnalyzer/Config.h deleted file mode 100644 index 902a4d9..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/Config.h +++ /dev/null @@ -1,40 +0,0 @@ -///================================================================================================= -/// \file Config.h -/// -/// \brief Ϣд -///================================================================================================= - -#pragma once - -#include -#include "ui_Config.h" -#include -#include -#include -class Config : public QWidget { - Q_OBJECT - - public: - Config(QWidget *parent = Q_NULLPTR); - void connect_signal_slot(); - QString get_grammars_path(); - QString get_terminal_path(); - ~Config(); - private slots: - void open_terminal(); - void open_grammars(); - void ok_btn(); - void open_file(int file_type); - signals: - void teminanls_file(QString); - void grammars_file(QString); - void file_type_send(int file_type); - void finish(); - - private: - Ui::Config ui; - QString teminanls_path; - QString grammars_path; - void read_setting(); - void wirte_setting(); -}; diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/Config.ui b/SyntacticAnalyzer/SyntacticAnalyzer/Config.ui deleted file mode 100644 index 2dda1cd..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/Config.ui +++ /dev/null @@ -1,115 +0,0 @@ - - - Config - - - - 0 - 0 - 384 - 130 - - - - - 385 - 130 - - - - 配置 - - - - - - - - - - - - 文法文件路径 - - - - - - - - - - 打开文件 - - - - - - - - - - - 终结符集合文件路径 - - - - - - - - - - 打开文件 - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 确定 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.cpp deleted file mode 100644 index 656533b..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "InputInfo.h" -#include -#include -#include -#include -#include -InputInfo::InputInfo(QWidget *parent) - : QWidget(parent) { - ui.setupUi(this); - connect(ui.input_finish, SIGNAL(clicked()), this, SLOT(input_finish())); -} - -std::vector InputInfo::get_info() { - return info; -} - -InputInfo::~InputInfo() { -} - -void InputInfo::input_finish() { - info.clear(); - QStringList list = ui.input_edit->toPlainText().split("\n"); - for (int i = 0; i < list.size(); i++) { - info.push_back(list[i].toStdString()); - } - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, QString::fromLocal8Bit(""), QString::fromLocal8Bit("Ƿ񱣴Ϣ"), - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); - if (reply == QMessageBox::Yes) { - QString file_name = QFileDialog::getSaveFileName(this, QString::fromLocal8Bit("Ϣ"), "", tr("*.txt")); - if (!file_name.isNull()) { - QFile file(file_name); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - QMessageBox::warning(this, QString::fromLocal8Bit("Ϣ"), QString::fromLocal8Bit("޷Ϣ!"), QMessageBox::Yes); - } - QTextStream in(&file); - in << ui.input_edit->toPlainText(); - file.close(); - } - } - emit finish(); -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.h b/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.h deleted file mode 100644 index 0688abd..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.h +++ /dev/null @@ -1,27 +0,0 @@ -///================================================================================================= -/// \file InputInfo.h -/// -/// \brief ڶ봰ڵϢ -///================================================================================================= - -#pragma once - -#include -#include "ui_InputInfo.h" -#include -using namespace std; -class InputInfo : public QWidget { - Q_OBJECT - - public: - InputInfo(QWidget *parent = Q_NULLPTR); - vector get_info(); - ~InputInfo(); - public slots: - void input_finish(); - signals: - void finish(); - private: - Ui::InputInfo ui; - vector info; -}; diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.ui b/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.ui deleted file mode 100644 index bd20f6e..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/InputInfo.ui +++ /dev/null @@ -1,72 +0,0 @@ - - - InputInfo - - - - 0 - 0 - 280 - 299 - - - - - 280 - 350 - - - - 输入信息 - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 输入结束 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.cpp deleted file mode 100644 index 42293b6..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.cpp +++ /dev/null @@ -1,637 +0,0 @@ -#include "SyntacticAnalyzer.h" - -SyntacticAnalyzer::SyntacticAnalyzer(QWidget *parent) - : QMainWindow(parent) { - ui.setupUi(this); - this->setWindowState(Qt::WindowMaximized); - ui.output_text->setOpenExternalLinks(false); - ui.output_text->setOpenLinks(false); - init(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::init() -/// -/// \brief ʼ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::init() { - settings = new QSettings("config.ini", QSettings::IniFormat); - get_settings(); - cfg = new Config(); - input = new InputInfo(); - last_first_model = new TableModel; - proirty_model = new TableModel; - analysis_setp = new AnalysisStep; - info_type = -1; - ui.lastView->setEditTriggers(QAbstractItemView::NoEditTriggers); - ui.tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); - update_input(); - exp_check.get_grammar(grammars); - exp_check.get_terminal_symbol(terminal_symbols); - exp_check.make_priority_table(); - connect_signal_slot(); - set_first_last(); - set_prority_table(); - show_last_first(); - show_prority_table(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::update_info() -/// -/// \brief Ϣ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::update_info() { - exp_check.reset(); - if (info_type == -1) { //ļ - grammars.clear(); - terminal_symbols.clear(); - ui.output_text->clear(); - QString file_name = cfg->get_grammars_path(); - read_grammars(file_name.toStdString()); - file_name = cfg->get_terminal_path(); - read_terminals(file_name.toStdString()); - } - - exp_check.get_grammar(grammars); //ñʽIJ - exp_check.get_terminal_symbol(terminal_symbols); - exp_check.make_priority_table(); - update_input(); - last_first_model->clear(); - proirty_model->clear(); - set_first_last(); //ˢϢ - set_prority_table(); - show_last_first(); - show_prority_table(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::connect_signal_slot() -/// -/// \brief źۺ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::connect_signal_slot() { - connect(ui.check, SIGNAL(triggered()), this, SLOT(check_btn())); - connect(ui.open_exp, SIGNAL(triggered()), this, SLOT(open_expression())); - connect(ui.read_settings, SIGNAL(triggered()), this, SLOT(open_setting())); - connect(cfg, SIGNAL(teminanls_file(QString)), this, SLOT(rev_terminal_path(QString))); - connect(cfg, SIGNAL(grammars_file(QString)), this, SLOT(rev_grammars_path(QString))); - connect(cfg, SIGNAL(finish()), this, SLOT(close_cfg())); - connect(cfg, SIGNAL(finish()), this, SLOT(update_info())); - connect(this, SIGNAL(send_input_type(int)), this, SLOT(input_info(int))); - connect(ui.input_grammars, SIGNAL(triggered()), this, SLOT(input_grammars())); - connect(ui.input_treminal, SIGNAL(triggered()), this, SLOT(input_terminals())); - connect(ui.input_exp, SIGNAL(triggered()), this, SLOT(input_exp())); - connect(input, SIGNAL(finish()), this, SLOT(input_finish())); - connect(ui.output_text, SIGNAL(anchorClicked(const QUrl&)), this, SLOT(show_step(const QUrl&))); -} -SyntacticAnalyzer::~SyntacticAnalyzer() { - delete settings; - delete cfg; - delete last_first_model; - delete proirty_model; - delete input; - delete analysis_setp; - -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::add_grammar(string grammar) -/// -/// \brief ķIJʽ -/// -/// \date 2018/6/5 -/// -/// \param grammar ʽ -///================================================================================================= - -void SyntacticAnalyzer::add_grammar(string grammar) { - grammars.push_back(grammar); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::add_terminal_symbols(char terminal) -/// -/// \brief ս. -/// -/// \date 2018/6/5 -/// -/// \param terminal ս. -///================================================================================================= - -void SyntacticAnalyzer::add_terminal_symbols(char terminal) { - terminal_symbols.insert(terminal); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::add_exp(string exp) -/// -/// \brief ӱʽ -/// -/// \date 2018/6/5 -/// -/// \param exp The exponent. -///================================================================================================= - -void SyntacticAnalyzer::add_exp(string exp) { - expressions.push_back(exp); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::get_settings() -/// -/// \brief ȡϢ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::get_settings() { - QString file_name = QFileInfo(QString::fromLocal8Bit(settings->value("/path/terminals").toByteArray())).absoluteFilePath(); - read_terminals(file_name.toStdString()); - file_name = QFileInfo(QString::fromLocal8Bit(settings->value("/path/grammars").toByteArray())).absoluteFilePath(); - read_grammars(file_name.toStdString()); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::open_expression() -/// -/// \brief ļʽ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::open_expression() { - QFileDialog *file_dialog = new QFileDialog(this); // Ի - file_dialog->setWindowTitle(QString::fromLocal8Bit("ļ")); //ļԻ - file_dialog->setDirectory("."); //Ĭļ· - file_dialog->setNameFilter(tr("file(*.txt)")); //ļ - file_dialog->setFileMode(QFileDialog::ExistingFile); //ļ - file_dialog->setViewMode(QFileDialog::Detail); //ͼģʽ - QString file_path; - if (file_dialog->exec()) { - QByteArray file_name_btye = file_dialog->selectedFiles()[0].toLocal8Bit(); //ÿζȡһļ - std::string file_name = file_name_btye.toStdString(); - file_path = QFileInfo(QString::fromStdString(file_name)).absoluteFilePath(); - expressions.clear(); - read_exp(file_path.toStdString()); - update_input(); - } - delete file_dialog; -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::open_setting() -/// -/// \brief ô -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::open_setting() { - cfg->show(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::check_btn() -/// -/// \brief ʽ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::check_btn() { - if (info_type != -1) //жǷҪ - update_info(); - ui.output_text->clear(); //һεϢ - vector::iterator it = expressions.begin(); - vector::iterator end = expressions.end(); - step_record.clear(); //һεķ¼ - int count = 0; //ʽ - for (it; it != end; it++) { //ʽ - - check_expression(*it, count); - step_record[count] = exp_check.get_setp(); - count++; - exp_check.reset(); - } -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::rev_terminal_path(QString path) -/// -/// \brief ôڽսļ· -/// -/// \date 2018/6/5 -/// -/// \param path սļ·. -///================================================================================================= - -void SyntacticAnalyzer::rev_terminal_path(QString path) { - terminal_symbols.clear(); - read_terminals(path.toStdString()); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::rev_grammars_path(QString path) -/// -/// \brief Reverse grammars path. -/// -/// \date 2018/6/5 -/// -/// \param path Full pathname of the file. -///================================================================================================= - -void SyntacticAnalyzer::rev_grammars_path(QString path) { - grammars.clear(); - read_grammars(path.toStdString()); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::close_cfg() -/// -/// \brief رô -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::close_cfg() { - if (cfg->isVisible()) - cfg->close(); - ui.input_text->clear(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::input_info(int input_type) -/// -/// \brief յϢ -/// 0ķ -/// 1ʽ -/// 2ս -/// -/// \date 2018/6/5 -/// -/// \param input_type -///================================================================================================= - -void SyntacticAnalyzer::input_info(int input_type) { - info_type = input_type; - input->show(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::input_finish() -/// -/// \brief 봰Ӧ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::input_finish() { - vector info_vec = input->get_info(); - input->close(); - if (info_type != -1) { - if (info_type == 0) { //ķ - grammars.clear(); - grammars = info_vec; - } else if (info_type == 1) { //ʽ - expressions.clear(); - expressions = info_vec; - } else { //ս - terminal_symbols.clear(); - vector::iterator it = info_vec.begin(); - vector::iterator end = info_vec.end(); - for (it; it != end; it++) { - - for (int i = 0; i < it->length(); i++) { - if(it->at(i) != ' ' || it->at(i) != '\n' || it->at(i) != '\t') - terminal_symbols.insert(it->at(i)); - } - } - } - } - update_info(); //Ϣ - info_type = -1; -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::input_grammars() -/// -/// \brief ķťӦ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::input_grammars() { - emit send_input_type(0); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::input_exp() -/// -/// \brief ʽӦ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::input_exp() { - emit send_input_type(1); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::input_terminals() -/// -/// \brief Input սӦ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::input_terminals() { - emit send_input_type(2); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::update_input() -/// -/// \brief Ϣ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::update_input() { - ui.input_text->clear(); //һεϢ - set::iterator it = terminal_symbols.begin(); - set::iterator end = terminal_symbols.end(); - vector::iterator gra_it = grammars.begin(); - vector::iterator gra_end = grammars.end(); - vector::iterator exp_it = expressions.begin(); - vector::iterator exp_end = expressions.end(); - ui.input_text->append(QString::fromLocal8Bit("ս:")); - QString terminals = ""; - for (it; it != end; it++) { - terminals.append(*it).append(" "); - } - ui.input_text->append(terminals); - ui.input_text->append("\n"); - ui.input_text->append(QString::fromLocal8Bit("ķ:")); - for (gra_it; gra_it != gra_end; gra_it++) { - ui.input_text->append(QString::fromStdString(*gra_it)); - } - ui.input_text->append("\n"); - ui.input_text->append(QString::fromLocal8Bit("ʽ:")); - for (exp_it; exp_it != exp_end; exp_it++) { - ui.input_text->append(QString::fromStdString(*exp_it)); - } - //update_info(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::show_step(const QUrl &link) -/// -/// \brief ʾ -/// -/// \date 2018/6/5 -/// -/// \param link еij -///================================================================================================= - -void SyntacticAnalyzer::show_step(const QUrl &link) { - QUrlQuery query(link); - QString record = query.queryItemValue("record_index"); //ȡм¼ֵ - qDebug() << "Record index:" << record; - analysis_setp->clear_table(); - analysis_setp->add_step(step_record[record.toInt()]); - analysis_setp->show(); - -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::set_first_last() -/// -/// \brief FIRST/LASTʽ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::set_first_last() { - - last_first_model->setColumnCount(2); - last_first_model->setHeaderData(0, Qt::Horizontal, QString::fromLocal8Bit("FIRST")); - last_first_model->setHeaderData(1, Qt::Horizontal, QString::fromLocal8Bit("LAST")); - ui.lastView->setModel(last_first_model); - ui.lastView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - ui.lastView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::set_prority_table() -/// -/// \brief ȹϵʽ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::set_prority_table() { - set::iterator it = terminal_symbols.begin(); - set::iterator end = terminal_symbols.end(); - int size = terminal_symbols.size(); - proirty_model->setColumnCount(size); - proirty_model->setRowCount(size); - int index = 0; - for (it; it != end; it++) { - proirty_model->setHeaderData(index, Qt::Horizontal, QString("").append(*it)); - proirty_model->setHeaderData(index, Qt::Vertical, QString("").append(*it)); - index++; - } - ui.tableView->setModel(proirty_model); - ui.lastView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - ui.lastView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::show_last_first() -/// -/// \brief ʾFIRST/LAST -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::show_last_first() { - map> first = exp_check.get_first(); //FIRST - map> last = exp_check.get_last(); - map>::iterator first_it = first.begin(); - map>::iterator first_end = first.end(); - map>::iterator last_it = last.begin(); //LAST - map>::iterator last_end = last.end(); - set::iterator it; - set::iterator end; - int size = first.size(); - last_first_model->setRowCount(size); - int row = 0; - int col = 0; - for (first_it; first_it != first_end; first_it++) { //ʾFIRST - QString terminals = ""; - last_first_model->setHeaderData(row, Qt::Vertical, QString("").append(first_it->first)); - it = first_it->second.begin(); - end = first_it->second.end(); - for (it; it != end; it++) { - terminals.append(*it).append(" "); - } - last_first_model->setItem(row, col, new QStandardItem(terminals)); - row++; - } - row = 0; - col++; - for (last_it; last_it != last_end; last_it++) { //ʾLAST - QString terminals = ""; - it = last_it->second.begin(); - end = last_it->second.end(); - for (it; it != end; it++) { - terminals.append(*it).append(" "); - } - - last_first_model->setItem(row, col, new QStandardItem(terminals)); - row++; - } - -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::show_prority_table() -/// -/// \brief ʾȹϵ -/// -/// \date 2018/6/5 -///================================================================================================= - -void SyntacticAnalyzer::show_prority_table() { - map, char> prority_table = exp_check.get_priority_table(); - set::iterator row_it = terminal_symbols.begin(); - set::iterator row_end = terminal_symbols.end(); - set::iterator col_it = terminal_symbols.begin(); - set::iterator col_end = terminal_symbols.end(); - int row = 0; - int col = 0; - for (row_it; row_it != row_end; row_it++) { - col_it = terminal_symbols.begin(); - col_end = terminal_symbols.end(); - col = 0; - for (col_it; col_it != col_end; col_it++) { - QString prority = QString("").append(prority_table[make_pair(*row_it, *col_it)]); - proirty_model->setItem(row, col, new QStandardItem(prority)); - col++; - } - row++; - } -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::check_expression(string exp, int record_index) -/// -/// \brief ʽ -/// ΪÿһʽϢһӣ -/// Ӱñʽڷ¼е -/// -/// \date 2018/6/5 -/// -/// \param exp ʽ. -/// \param record_index ʽ -///================================================================================================= - -void SyntacticAnalyzer::check_expression(string exp, int record_index) { - - exp_check.check_expression(exp); - - map error = exp_check.get_error(); - map::iterator it = error.begin(); - map::iterator end = error.end(); - bool flag = true; - QString error_info = ""; - if (error.empty()) //ʽɳ - ui.output_text->append(QString("

%2

").arg(record_index).arg(QString::fromStdString(exp))); - else - ui.output_text->append(QString::fromStdString(exp)); - for (it; it != end; it++) { - flag = false; - - QTextCursor cursor(ui.output_text->document()); - QTextCursor cursor_postion(ui.output_text->textCursor()); - QTextCharFormat color_format; - color_format.setForeground(Qt::red); - int postion = cursor_postion.position() - (exp.length() - it->first); - cursor.setPosition(postion, QTextCursor::KeepAnchor); - cursor.movePosition(QTextCursor::NoMove, QTextCursor::KeepAnchor, 1); - cursor.select(QTextCursor::WordUnderCursor); - cursor.setCharFormat(color_format); - } - for (it = error.begin(); it != end; it++) { //¼ɳ - flag = false; - - ui.output_text->append(QString("

%2:%3

").arg(record_index).arg(it->first).arg(QString::fromLocal8Bit(it->second.data()))); - } -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::read_grammars(string file_name) -/// -/// \brief ļжȡķ -/// -/// \date 2018/6/5 -/// -/// \param file_name ļ· -///================================================================================================= - -void SyntacticAnalyzer::read_grammars(string file_name) { - ifstream fin(file_name); - string line; - while (getline(fin, line)) { - add_grammar(line); - } - fin.close(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::read_terminals(string file_name) -/// -/// \brief ļжȡս -/// -/// \date 2018/6/5 -/// -/// \param file_name ļ· -///================================================================================================= - -void SyntacticAnalyzer::read_terminals(string file_name) { - ifstream fin(file_name); - char terminal; - while (fin >> terminal) { - add_terminal_symbols(terminal); - } - fin.close(); -} - -///================================================================================================= -/// \fn void SyntacticAnalyzer::read_exp(string file_name) -/// -/// \brief ļжȡʽ -/// -/// \date 2018/6/5 -/// -/// \param file_name ļ· -///================================================================================================= - -void SyntacticAnalyzer::read_exp(string file_name) { - ifstream fin(file_name); - string line; - while (getline(fin, line)) { - add_exp(line); - } - fin.close(); -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.h b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.h deleted file mode 100644 index 8ec9cb9..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.h +++ /dev/null @@ -1,171 +0,0 @@ -///================================================================================================= -/// \file SyntacticAnalyzer.h -/// -/// \brief ȷGUI߼ -/// \date 2018/6/5 -///================================================================================================= - -#ifndef SYNTACTICANALYZER_H -#define SYNTACTICANALYZER_H -#include -#include "ui_SyntacticAnalyzer.h" -#include "ExpressionCheck.h" -#include "InputInfo.h" -#include "Config.h" -#include "AnalysisStep.h" -#include -#include -#include -#include -#include -#include -#include "TableModel.h" -#include -#include -#include -#include"boost/format.hpp" -#include -#include -#include -#include -#include -#include -using namespace std; -class SyntacticAnalyzer : public QMainWindow { - Q_OBJECT - - public: - SyntacticAnalyzer(QWidget *parent = Q_NULLPTR); - ~SyntacticAnalyzer(); - - private slots : - //ļ򿪱ʽ - void open_expression(); - - //ô - void open_setting(); - - //ʼʽ - void check_btn(); - - //սϵļ· - void rev_terminal_path(QString); - - //ķļ· - void rev_grammars_path(QString); - - //رô - void close_cfg(); - - //Ϣ - void update_info(); - - //봰ڻȡϢ - void input_info(int input_type); - - //Ӧ - void input_finish(); - - //ķťӦ - void input_grammars(); - - //սťӦ - void input_terminals(); - - //ʽťӦ - void input_exp(); - - // - void update_input(); - - //ʾijʽķ - void show_step(const QUrl &link); - signals: - //ݵ - void send_input_type(int input_type); - - private: - Ui::SyntacticAnalyzerClass ui; - - /// \brief ʽ - ExpressionCheck exp_check; - - /// \brief Ϣд - QSettings *settings; - - /// \brief ķ - vector grammars; - - /// \brief ʽ - vector expressions; - - /// \brief ʽ¼ - map>> step_record; - - /// \brief ս - set terminal_symbols; - - /// \brief ʾFIRST/LASTıģ - TableModel *last_first_model; - - /// \brief ʾȹϵıģ - TableModel *proirty_model; - - /// \brief ô - Config *cfg; - - /// \brief 봰 - InputInfo *input = new InputInfo; - - /// \brief - AnalysisStep *analysis_setp; - - - /// \brief Ϣͣ0Ϊķ1Ϊʽ2Ϊս - int info_type; - - //ʼ - void init(); - - //ȡϢ - void get_settings(); - - //źۺ - void connect_signal_slot(); - - //ļȡķ - void read_grammars(string file_name); - - //ļȡս - void read_terminals(string file_name); - - //ļȡʽ - void read_exp(string file_name); - - //ķIJʽ - void add_grammar(string grammar); - - //ս - void add_terminal_symbols(char terminal); - - //ӱʽ - void add_exp(string exp); - - //ʽ - void check_expression(string exp, int record_index); - - //FIRST/LASTʽ - void set_first_last(); - - //ȹϵʽ - void set_prority_table(); - - //ʾFIRST/LAST - void show_last_first(); - - //ʾȹϵ - void show_prority_table(); - -}; -#endif - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.qrc b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.qrc deleted file mode 100644 index 007fda4..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.ui b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.ui deleted file mode 100644 index adb64ba..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.ui +++ /dev/null @@ -1,212 +0,0 @@ - - - SyntacticAnalyzerClass - - - - 0 - 0 - 1017 - 490 - - - - 算符优先语法分析器 - - - - - - - - - QLayout::SetFixedSize - - - - - - - FIRST和LAST集 - - - - - - QHeaderView::section { - color: white; - background-color: rgb(0, 170, 255); - border: 5px solid #f6f7fa; - border-radius:0px; - border-color: rgb(0, 170, 255); -} - - - true - - - true - - - 100 - - - true - - - true - - - true - - - true - - - false - - - - - - - - - - - - 优先关系表 - - - - - - QHeaderView::section { - color: white; - background-color: rgb(0, 170, 255); - border: 5px solid #f6f7fa; - border-radius:0px; - border-color: rgb(0, 170, 255); -} - - - - - - - - - - - - - - 输入项 - - - - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - 检测结果 - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 1017 - 26 - - - - - - TopToolBarArea - - - false - - - - - - - - - - - - 导入表达式 - - - 导入表达式 - - - - - 检查 - - - 检查 - - - - - 输入文法 - - - 输入文法 - - - - - 输入终结符 - - - - - 输入表达式 - - - - - 配置 - - - 配置 - - - - - - - - - diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj deleted file mode 100644 index 806d501..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {B12702AD-ABFB-343A-A199-8E24837244A3} - Qt4VSv1.0 - 10.0.15063.0 - - - - Application - v141 - - - Application - v141 - - - - $(MSBuildProjectDirectory)\QtMsBuild - - - $(SolutionDir)$(Platform)\$(Configuration)\ - D:\QT\QT\5.9\MSVC2017_64\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64 - - - $(SolutionDir)$(Platform)\$(Configuration)\ - - - - - - - - - - - - - - - - - - - true - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - Disabled - ProgramDatabase - MultiThreadedDebugDLL - true - - - Windows - $(OutDir)\$(ProjectName).exe - $(QTDIR)\lib;%(AdditionalLibraryDirectories) - true - operator_precedence_analysis.lib;libboost_regex-vc141-mt-gd-x64-1_67.lib;D:\QT\QT\5.9\MSVC2017_64\lib\qtmaind.lib;shell32.lib;E:\LIB\boost_1_67_0\lib64-msvc-14.1\libboost_regex-vc141-mt-gd-x64-1_67.lib;D:\QT\QT\5.9\MSVC2017_64\lib\Qt5Widgetsd.lib;D:\QT\QT\5.9\MSVC2017_64\lib\Qt5Guid.lib;D:\QT\QT\5.9\MSVC2017_64\lib\Qt5Cored.lib - - - .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - Moc'ing %(Identity)... - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) - D:\QT\QT\5.9\MSVC2017_64 - - - Uic'ing %(Identity)... - .\GeneratedFiles\ui_%(Filename).h - - - Rcc'ing %(Identity)... - .\GeneratedFiles\qrc_%(Filename).cpp - D:\QT\QT\5.9\MSVC2017_64 - - - - - true - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - - MultiThreadedDLL - true - - - Windows - $(OutDir)\$(ProjectName).exe - $(QTDIR)\lib;%(AdditionalLibraryDirectories) - false - qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;%(AdditionalDependencies) - - - .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - Moc'ing %(Identity)... - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) - - - Uic'ing %(Identity)... - .\GeneratedFiles\ui_%(Filename).h - - - Rcc'ing %(Identity)... - .\GeneratedFiles\qrc_%(Filename).cpp - - - - - - - - - - - - - - - - - - - - - Designer - - - - - - - - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - - - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - - - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - - - - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - BOOST_ALL_NO_LIB;UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName)\.;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;E:\LIB\boost_1_67_0;D:\SDK\dlib-19.4\dlib\external\libpng;D:\SDK\dlib-19.4;D:\SDK\dlib-19.4\dlib\external\zlib;D:\SDK\dlib-19.4\dlib\external\libjpeg;D:\SDK\dlib-19.4\dlib\external\cblas;D:\ffmpeg\ffmpeg-20170117-f7e9275-win64-dev\include - UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;BOOST_ALL_NO_LIB;_CRT_SECURE_NO_WARNINGS;_UNICODE;CPU_ONLY - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.filters b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.filters deleted file mode 100644 index 68eccf8..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.filters +++ /dev/null @@ -1,117 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {99349809-55BA-4b9d-BF79-8FDBB0286EB3} - ui - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - moc;h;cpp - False - - - {69a007d7-05d0-4fb6-b413-b5f953aad87d} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - include - - - include - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Form Files - - - Form Files - - - Form Files - - - Form Files - - - - - Resource Files - - - - - Header Files - - - Header Files - - - Generated Files - - - Generated Files - - - Generated Files - - - Generated Files - - - \ No newline at end of file diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.user b/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.user deleted file mode 100644 index 2907b9d..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/SyntacticAnalyzer.vcxproj.user +++ /dev/null @@ -1,12 +0,0 @@ - - - - - D:\QT\QT\5.9\msvc2017_64 - PATH=$(QTDIR)\bin%3b$(PATH) - - - D:\QT\QT\5.9\msvc2017_64 - PATH=$(QTDIR)\bin%3b$(PATH) - - \ No newline at end of file diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.cpp deleted file mode 100644 index 1b60645..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "tablemodel.h" - - -TableModel::~TableModel() { - - -} - -QVariant TableModel::data(const QModelIndex &idx, int role /*= Qt::DisplayRole*/) const { - QVariant value = QStandardItemModel::data(idx, role); - if (Qt::TextAlignmentRole == role) { - value = int(Qt::AlignCenter | Qt::AlignHCenter); - return value; - } - return value; -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.h b/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.h deleted file mode 100644 index f8c91ab..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/TableModel.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include -#include -class TableModel : public QStandardItemModel { - Q_OBJECT - - public: - TableModel(QObject *parent = Q_NULLPTR): QStandardItemModel() {} - ~TableModel(); - QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const; -}; diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/config.ini b/SyntacticAnalyzer/SyntacticAnalyzer/config.ini deleted file mode 100644 index dd4a881..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/config.ini +++ /dev/null @@ -1,3 +0,0 @@ -[path] -terminals=E:/CppProject/SyntacticAnalyzer/SyntacticAnalyzer/terminals.txt -grammars=E:/CppProject/SyntacticAnalyzer/SyntacticAnalyzer/grammar.txt diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/expressions.txt b/SyntacticAnalyzer/SyntacticAnalyzer/expressions.txt deleted file mode 100644 index 33b67a9..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/expressions.txt +++ /dev/null @@ -1,5 +0,0 @@ -(i+i*i)*i-i -(i+i*i*i-i -(i+i*i)*(i-i) -(i+(i-i))*i-i -(i+(i*i)) \ No newline at end of file diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/grammar.txt b/SyntacticAnalyzer/SyntacticAnalyzer/grammar.txt deleted file mode 100644 index ce9ed28..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/grammar.txt +++ /dev/null @@ -1,3 +0,0 @@ -E->E+T|E-T|T -T->T*F|T/F|F -F->(E)|i \ No newline at end of file diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/main.cpp b/SyntacticAnalyzer/SyntacticAnalyzer/main.cpp deleted file mode 100644 index b8d0970..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "SyntacticAnalyzer.h" -#include - -int main(int argc, char *argv[]) { - QApplication a(argc, argv); - SyntacticAnalyzer w; - w.show(); - return a.exec(); -} diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/operator_precedence_analysis.lib b/SyntacticAnalyzer/SyntacticAnalyzer/operator_precedence_analysis.lib deleted file mode 100644 index 61c9d18..0000000 Binary files a/SyntacticAnalyzer/SyntacticAnalyzer/operator_precedence_analysis.lib and /dev/null differ diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/terminals.txt b/SyntacticAnalyzer/SyntacticAnalyzer/terminals.txt deleted file mode 100644 index 7e6d693..0000000 --- a/SyntacticAnalyzer/SyntacticAnalyzer/terminals.txt +++ /dev/null @@ -1,6 +0,0 @@ -( -) -* -+ -- -/ \ No newline at end of file diff --git a/opa-md-x64/opa-md-x64.sln b/opa-md-x64/opa-md-x64.sln new file mode 100644 index 0000000..ccb9e8e --- /dev/null +++ b/opa-md-x64/opa-md-x64.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opa-md-x64", "opa-md-x64\opa-md-x64.vcxproj", "{F5CF6ADD-CD2B-47A4-85CB-03019314BC23}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Debug|x64.ActiveCfg = Debug|x64 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Debug|x64.Build.0 = Debug|x64 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Debug|x86.ActiveCfg = Debug|Win32 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Debug|x86.Build.0 = Debug|Win32 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Release|x64.ActiveCfg = Release|x64 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Release|x64.Build.0 = Release|x64 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Release|x86.ActiveCfg = Release|Win32 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.cpp b/opa-md-x64/opa-md-x64/ExpressionCheck.cpp similarity index 92% rename from SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.cpp rename to opa-md-x64/opa-md-x64/ExpressionCheck.cpp index c9f6afa..4ee548b 100644 --- a/SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.cpp +++ b/opa-md-x64/opa-md-x64/ExpressionCheck.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "ExpressionCheck.h" #include #include @@ -6,13 +7,13 @@ ExpressionCheck::ExpressionCheck() { left_prime_phrase = ""; is_move = true; - error_info.push_back("ȱٱʽ"); - error_info.push_back("ʽ"); - error_info.push_back("żޱʽ"); - error_info.push_back("Ƿ"); - error_info.push_back("ʽȱ"); + error_info.push_back("ȱٱʽ"); //eg. + error_info.push_back("ʽȱ"); //eg .ii + error_info.push_back("żޱʽ"); //eg.() + error_info.push_back("ȱ"); + error_info.push_back("ʽȱ"); //eg. )( error_info.push_back("ȷ"); - error_info.push_back("Ƿ"); + error_info.push_back("ȱ"); expression_index = 0; setp = 1; } @@ -68,7 +69,7 @@ void ExpressionCheck::make_priority_table() { /// \date 2018/6/3 /// /// \param left_prime_phrase ض -/// \param normalize_char Լķ +/// \param normalize_char Լķ /// /// \return ///================================================================================================= @@ -77,7 +78,7 @@ int ExpressionCheck::check_error(string left_prime_phrase, char normalize_char) if (normalize_char == 'i') { //ʽǷ int index = left_prime_phrase.find(normalize_char); - if (index != left_prime_phrase.size() - 1 != 0 && left_prime_phrase[index + 1] == 'i') { //ʽȱ + if (index != left_prime_phrase.size() - 1 != 0 && left_prime_phrase[index + 1] == 'i') { //ʽȱ,eg. ii return DEFECT_OPERATOR; } if ((index != 0 && (terminal_symbols.find(index - 1) == terminal_symbols.end()))) //ʽҲȱ @@ -88,7 +89,7 @@ int ExpressionCheck::check_error(string left_prime_phrase, char normalize_char) if (normalize_char == '(' || normalize_char == ')') { //źϷԼ int left_index = left_prime_phrase.find('('); int right_index = left_prime_phrase.find(')'); - if (left_index != -1 && right_index != -1) { //żǷڱʽ + if (left_index != -1 && right_index != -1) { //żǷڱʽ,eg. (i) for (int i = left_index; i != right_index; i++) { if (terminal_symbols.find(left_prime_phrase[i]) == terminal_symbols.end()) return OK; @@ -98,7 +99,7 @@ int ExpressionCheck::check_error(string left_prime_phrase, char normalize_char) if (left_index == left_prime_phrase.size() - 1) { //Ƿ return INVALID_LEFT_BRACKET; } - if (left_index + 1 == right_index) { //ȱ + if (left_index + 1 == right_index) { //ȱeg. )( return DEFECT_OPERATOR; } if (left_index != -1 && right_index == -1) { //Ƿ @@ -110,9 +111,9 @@ int ExpressionCheck::check_error(string left_prime_phrase, char normalize_char) } if (terminal_symbols.find(normalize_char) != terminal_symbols.end()) { //Ƿڷս int index = left_prime_phrase.find(normalize_char); - if ((index != 0 && (terminal_symbols.find(index - 1) != terminal_symbols.end()))) //ȱ + if ((index != 0 && (terminal_symbols.find(index - 1) != terminal_symbols.end()))) //ȱٱʽ return EXPRESSION_ERROR; - if ((index != left_prime_phrase.size() - 1 && (terminal_symbols.find(index + 1) != terminal_symbols.end()))) //Ҳȱ + if ((index != left_prime_phrase.size() - 1 && (terminal_symbols.find(index + 1) != terminal_symbols.end()))) //Ҳȱٱʽ return EXPRESSION_ERROR; } return OK; @@ -145,19 +146,19 @@ char ExpressionCheck::skip_no_terminal(char top_value) { } ///================================================================================================= -/// \fn char ExpressionCheck::normalization(char top_value, char exp_value) +/// \fn char ExpressionCheck::reduction(char top_value, char exp_value) /// -/// \brief Լ +/// \brief Լ /// /// \date 2018/6/3 /// /// \param top_value ջԪ /// \param exp_value ʽǰַ /// -/// \return ԼջԪ +/// \return ԼջԪ ///================================================================================================= -char ExpressionCheck::normalization(char top_value, char exp_value) { +char ExpressionCheck::reduction(char top_value, char exp_value) { char q = top_value; //ջԪأضĵһս char a = exp_value; //봮 char p = top_value; @@ -175,14 +176,13 @@ char ExpressionCheck::normalization(char top_value, char exp_value) { reverse(left_prime_phrase.begin(), left_prime_phrase.end()); //ضķת top_value = symbols_stack.top(); //ջԪ - if (match_production_left(left_prime_phrase)) { //ǷԼ + if (match_production_left(left_prime_phrase)) { //ǷԼ symbols_stack.push('V'); //滻ض is_move = false; //ƽ left_phrase = left_prime_phrase; //ض } else { int error_type = check_error(left_prime_phrase, q); if (error_type != OK) { - //cout << error_info[erro_type] << endl; error_record[expression_index] = error_info[error_type]; } is_move = true; @@ -259,11 +259,7 @@ bool ExpressionCheck::match_production_left(string right_str) { ///================================================================================================= void ExpressionCheck::save_analysis_step(int index, char prioity, string left, string act) { - string stack_status = get_stack_status(); - if (prioity == 0) - prioity = '<'; - boost::format fmt("%-20s|%-20s|%-20s|%-20s|%-20s|%-20s"); - fmt % setp % stack_status % prioity % expression_str.substr(index) % left % act; + string stack_status = get_stack_status(); //ջ״̬ analysis_info[setp].push_back(stack_status); analysis_info[setp].push_back(string("").append(1, prioity)); analysis_info[setp].push_back(expression_str.substr(index)); @@ -272,6 +268,7 @@ void ExpressionCheck::save_analysis_step(int index, char prioity, string left, s setp++; } + ///================================================================================================= /// \fn int ExpressionCheck::check_expression(string expression) /// @@ -310,14 +307,9 @@ int ExpressionCheck::check_expression(string expression) { error_record[expression_index] = error_info[EXP_NO_OPERATOR]; } save_analysis_step(index, table[make_pair(top_value, a)], left_phrase, "ƽ"); - //if(table[make_pair(top_value, a)] == '<' || table[make_pair(top_value, a)] == '=') - // - //if((table[make_pair(top_value, a)] == '>')) { //Լǰļ¼ - // save_analysis_step(index, table[make_pair(top_value, a)], left_phrase, "Լ"); - //} - top_value = normalization(q, a); //Լ - if (!left_phrase.empty()) { //Լ - save_analysis_step(index, table[make_pair(top_value, a)], left_phrase, "Լ"); + top_value = reduction(q, a); //Լ + if (!left_phrase.empty()) { //Լ + save_analysis_step(index, table[make_pair(top_value, a)], left_phrase, "Լ"); left_phrase.clear(); } if (is_move || top_value == '#' || table[make_pair(top_value, a)] == '<' || table[make_pair(top_value, a)] == '=') { //ƽ @@ -333,17 +325,19 @@ int ExpressionCheck::check_expression(string expression) { top_value = symbols_stack.top(); top_value = skip_no_terminal(top_value); - normalization(top_value, '#'); - save_analysis_step(index, '>', left_phrase, "Լ"); + reduction(top_value, '#'); + if (!left_phrase.empty()) + save_analysis_step(index, '>', left_phrase, "Լ"); } + left_phrase.clear(); if (terminal_symbols.find(symbols_stack.top()) != terminal_symbols.end() || symbols_stack.top() == '#') { if(error_record.find(expression_index) == error_record.end()) - error_record[expression_index] = error_info[EXPRESSION_ERROR]; + error_record[expression_index] = error_info[EXPRESSION_ERROR]; //ȱٱʽ save_analysis_step(index, ' ', left_phrase, ""); } else - save_analysis_step(index, ' ', left_phrase, "ȷ"); + save_analysis_step(index, ' ', left_phrase, ""); setp = 0; return 0; } diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.h b/opa-md-x64/opa-md-x64/ExpressionCheck.h similarity index 80% rename from SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.h rename to opa-md-x64/opa-md-x64/ExpressionCheck.h index 3a59105..880fd3d 100644 --- a/SyntacticAnalyzer/SyntacticAnalyzer/ExpressionCheck.h +++ b/opa-md-x64/opa-md-x64/ExpressionCheck.h @@ -4,13 +4,15 @@ /// \brief ڱʽ ///================================================================================================= -#ifndef EXPRESSIONCHECK_H -#define EXPRESSIONCHECK_H +#ifndef EXPRESSIONCHECK_H __declspec(dllexport) +#define EXPRESSIONCHECK_H __declspec(dllexport) #include "PriorityTable.h" #include #include #include #include +#include +#include using namespace std; ///================================================================================================= @@ -20,24 +22,27 @@ using namespace std; /// ///================================================================================================= -enum ERROR_CODE { +enum EXPRESSIONCHECK_H ERROR_CODE { - ///< ȱٱʽ + /// \brief ȱٱʽ EXPRESSION_ERROR, - ///< ʽȱ + /// \brief ʽȱ EXP_NO_OPERATOR, - ///< żޱʽ + /// \brief żޱʽ BRACKETS_NO_EXP, - ///< Ƿ + /// \brief Ƿ INVALID_LEFT_BRACKET, - ///< ȷ - DEFECT_OPERATOR, OK, + /// \brief ʽȱ + DEFECT_OPERATOR, - ///< Ƿ + /// \brief ȷ + OK, + + /// \brief Ƿ INVALID_RIGHT_BRACKET }; @@ -49,25 +54,26 @@ enum ERROR_CODE { /// \date 2018/6/3 ///================================================================================================= -class ExpressionCheck { +class EXPRESSIONCHECK_H ExpressionCheck { public: ExpressionCheck(); + //ȡķ void get_grammar(std::vector grammars); - //ȡս + //ȡս void get_terminal_symbol(set terminal_symbols); - //ȹϵ + //ȹϵ void make_priority_table(); //ʽ int check_expression(string expression); - //ӡϢ + //ӡϢ void print_info(); - //ӡջ״̬ + //ӡ״̬ void print_stack(); //ӡ @@ -79,7 +85,7 @@ class ExpressionCheck { // void reset(); - //ȡ + //ȡ map> get_setp(); //ȡϢ @@ -94,8 +100,9 @@ class ExpressionCheck { //ȡFIRST map> get_first(); - //ȡջ״̬ + //ȡջ״̬ string get_stack_status(); + ~ExpressionCheck(); private: @@ -147,22 +154,22 @@ class ExpressionCheck { /// \brief Ƿƽ bool is_move; - //ضļ + //ضд int check_error(string left_prime_phrase, char normalize_char); //ս char skip_no_terminal(char top_value); - //Լ - char normalization(char top_value, char exp_value); + //Լ + char reduction(char top_value, char exp_value); //ʽ׼ void production_to_std(); - //ݲʽҲƥʽ + //ݲʽҲƥ bool match_production_left(string right_str); - // + //洢 void save_analysis_step(int index, char prioity, string left, string act); }; diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.cpp b/opa-md-x64/opa-md-x64/PriorityTable.cpp similarity index 99% rename from SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.cpp rename to opa-md-x64/opa-md-x64/PriorityTable.cpp index 69c8c02..ad685cf 100644 --- a/SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.cpp +++ b/opa-md-x64/opa-md-x64/PriorityTable.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "PriorityTable.h" #include #include diff --git a/SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.h b/opa-md-x64/opa-md-x64/PriorityTable.h similarity index 95% rename from SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.h rename to opa-md-x64/opa-md-x64/PriorityTable.h index 78c0511..2568972 100644 --- a/SyntacticAnalyzer/SyntacticAnalyzer/PriorityTable.h +++ b/opa-md-x64/opa-md-x64/PriorityTable.h @@ -4,8 +4,8 @@ /// \brief Declares the priority table class. ///================================================================================================= -#ifndef PRIORITYTABLE_H -#define PRIORITYTABLE_H +#ifndef PRIORITYTABLE_H __declspec(dllexport) +#define PRIORITYTABLE_H __declspec(dllexport) #include #include #include @@ -22,7 +22,7 @@ using namespace std; /// \date 2018/6/1 ///================================================================================================= -class PriorityTable { +class PRIORITYTABLE_H PriorityTable { public: PriorityTable(); //ȡʽ diff --git a/opa-md-x64/opa-md-x64/ReadMe.txt b/opa-md-x64/opa-md-x64/ReadMe.txt new file mode 100644 index 0000000..6ac62b0 --- /dev/null +++ b/opa-md-x64/opa-md-x64/ReadMe.txt @@ -0,0 +1,9 @@ +======================================================================== + 动态链接库:opa-md-x64 项目概述 +======================================================================== +基于算符优先分析算法,生成响应的DLL,和LIB文件。 + +///////////////////////////////依赖库////////////////////////////////////////////// +BOOST 1.64 + +///////////////////////////////////////////////////////////////////////////// diff --git a/opa-md-x64/opa-md-x64/dllmain.cpp b/opa-md-x64/opa-md-x64/dllmain.cpp new file mode 100644 index 0000000..260abc6 --- /dev/null +++ b/opa-md-x64/opa-md-x64/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : DLL Ӧóڵ㡣 +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/opa-md-x64/opa-md-x64/opa-md-x64.cpp b/opa-md-x64/opa-md-x64/opa-md-x64.cpp new file mode 100644 index 0000000..208c023 --- /dev/null +++ b/opa-md-x64/opa-md-x64/opa-md-x64.cpp @@ -0,0 +1,22 @@ +// opa-md-x64.cpp : DLL Ӧóĵ +// + +#include "stdafx.h" +#include "opa-md-x64.h" + + +// ǵһʾ +OPAMDX64_API int nopamdx64=0; + +// ǵһʾ +OPAMDX64_API int fnopamdx64(void) +{ + return 42; +} + +// ѵĹ캯 +// йඨϢ opa-md-x64.h +Copamdx64::Copamdx64() +{ + return; +} diff --git a/opa-md-x64/opa-md-x64/opa-md-x64.h b/opa-md-x64/opa-md-x64/opa-md-x64.h new file mode 100644 index 0000000..60e2ff5 --- /dev/null +++ b/opa-md-x64/opa-md-x64/opa-md-x64.h @@ -0,0 +1,22 @@ +// ifdef Ǵʹ DLL 򵥵 +// ı׼ DLL еļ϶ OPAMDX64_EXPORTS +// űġʹô DLL +// κĿϲӦ˷šԴļаļκĿὫ +// OPAMDX64_API ΪǴ DLL ģ DLL ô˺궨 +// ΪDZġ +#ifdef OPAMDX64_EXPORTS +#define OPAMDX64_API __declspec(dllexport) +#else +#define OPAMDX64_API __declspec(dllimport) +#endif + +// Ǵ opa-md-x64.dll +class OPAMDX64_API Copamdx64 { +public: + Copamdx64(void); + // TODO: ڴķ +}; + +extern OPAMDX64_API int nopamdx64; + +OPAMDX64_API int fnopamdx64(void); diff --git a/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj new file mode 100644 index 0000000..22ff548 --- /dev/null +++ b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj @@ -0,0 +1,179 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {F5CF6ADD-CD2B-47A4-85CB-03019314BC23} + Win32Proj + opamdx64 + 10.0.15063.0 + + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + operator_precedence_analysisd + + + false + + + false + operator_precedence_analysis + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;OPAMDX64_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + Windows + + + + + Use + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;OPAMDX64_EXPORTS;%(PreprocessorDefinitions) + + + Console + libboost_regex-vc141-mt-gd-x64-1_67.lib + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;OPAMDX64_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;OPAMDX64_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Windows + true + true + libboost_regex-vc141-mt-x64-1_67.lib + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.filters b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.filters new file mode 100644 index 0000000..56848cd --- /dev/null +++ b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.filters @@ -0,0 +1,48 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + \ No newline at end of file diff --git a/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.user b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/opa-md-x64/opa-md-x64/opa-md-x64.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/opa-md-x64/opa-md-x64/stdafx.cpp b/opa-md-x64/opa-md-x64/stdafx.cpp new file mode 100644 index 0000000..1ebf3f6 --- /dev/null +++ b/opa-md-x64/opa-md-x64/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// opa-md-x64.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H κĸͷļ +//ڴļ diff --git a/opa-md-x64/opa-md-x64/stdafx.h b/opa-md-x64/opa-md-x64/stdafx.h new file mode 100644 index 0000000..1aa967d --- /dev/null +++ b/opa-md-x64/opa-md-x64/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +// Windows ͷļ: +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/opa-md-x64/opa-md-x64/targetver.h b/opa-md-x64/opa-md-x64/targetver.h new file mode 100644 index 0000000..416cebf --- /dev/null +++ b/opa-md-x64/opa-md-x64/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// _WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include