3 Commits
Author SHA1 Message Date
c-my 12b26e2cfe 增强导错误时的 2018-05-07 13:14:10 +08:00
c-my a8a2c3ac32 添加了一个语法文件 2018-05-06 21:39:26 +08:00
c-my 4ed6bf4fce Update README.md 2018-05-05 21:09:14 +08:00
8 changed files with 234 additions and 10 deletions
+2
View File
@@ -1,2 +1,4 @@
# TuringMachine
无纸化的图灵机
* 不再需要使用纸质载体,保护环境 从我做起
* 喜加40
+2 -1
View File
@@ -105,7 +105,8 @@ void CentralWidget::importJson()
return;
if(!machine->setGrammar(filename))
{
setStatus("请检查文件格式");
QMessageBox::warning(this, "警告", "请检查文件格式");
setStatus("导入失败");
return;
};
setStatus(tr("导入成功"));
+1
View File
@@ -12,6 +12,7 @@
#include <QGraphicsView>
#include <QListWidget>
#include <QTimer>
#include <QMessageBox>
#include "turingmachine.h"
#include "papertape.h"
View File
View File
+227
View File
@@ -0,0 +1,227 @@
{
"name": "wcw",
"description": "{ wcw | w ∈ {a,b}+ }",
"grammar": {
"states": {
"states": [
"q0",
"[q1,a]",
"[q1,b]",
"[q2,a]",
"[q2,b]",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8"
],
"initial": "q0",
"finial": [
"q8"
]
},
"input": [
"a",
"b",
"c"
],
"alphabet": [
"a",
"b",
"c",
"X",
"Y",
"B"
],
"blank": "B",
"transition": {
"q0": {
"a": [
"[q1,a]",
"X",
"R"
],
"b": [
"[q1,b]",
"Y",
"R"
]
},
"[q1,a]": {
"a": [
"[q1,a]",
"a",
"R"
],
"b": [
"[q1,a]",
"b",
"R"
],
"c":[
"[q2,a]",
"c",
"R"
]
},
"[q1,b]": {
"a": [
"[q1,b]",
"a",
"R"
],
"b": [
"[q1,b]",
"b",
"R"
],
"c":[
"[q2,b]",
"c",
"R"
]
},
"[q2,a]": {
"X": [
"[q2,a]",
"X",
"R"
],
"Y": [
"[q2,a]",
"Y",
"R"
],
"a":[
"q3",
"X",
"L"
]
},
"[q2,b]": {
"X": [
"[q2,b]",
"X",
"R"
],
"Y": [
"[q2,b]",
"Y",
"R"
],
"b":[
"q3",
"Y",
"L"
]
},
"q3": {
"X": [
"q3",
"X",
"L"
],
"Y": [
"q3",
"Y",
"L"
],
"c": [
"q4",
"c",
"L"
]
},
"q4": {
"a": [
"q5",
"a",
"L"
],
"b": [
"q5",
"b",
"L"
],
"X": [
"q6",
"X",
"R"
],
"Y":[
"q6",
"Y",
"R"
]
},
"q5": {
"a": [
"q5",
"a",
"L"
],
"b": [
"q5",
"b",
"L"
],
"X": [
"q0",
"X",
"R"
],
"Y": [
"q0",
"Y",
"R"
]
},
"q6":{
"X":[
"q6",
"X",
"R"
],
"Y":[
"q6",
"Y",
"R"
],
"c":[
"q6",
"c",
"R"
],
"B":[
"q7",
"B",
"L"
]
},
"q7":{
"c":[
"q7",
"c",
"L"
],
"X":[
"q7",
"a",
"L"
],
"Y":[
"q7",
"b",
"L"
],
"B":[
"q8",
"B",
"R"
]
}
}
},
"demo":"aabbbcaabbb"
}
-7
View File
@@ -10,12 +10,5 @@ int main(int argc, char *argv[])
MainWindow w;
w.show();
// TuringMachine tm;
// tm.setGrammar("0n1n.json");
// tm.setTestStr("");
// if(tm.run())
// qDebug()<<"OK";
// else
// qDebug()<<"not ok";
return a.exec();
}
+2 -2
View File
@@ -14,7 +14,7 @@ MainWindow::MainWindow(QWidget *parent) :
helpMenu->addAction(aboutAction);
setCentralWidget(cw);
menuBar()->addMenu(helpMenu);
statusBar()->showMessage("欢迎使用环保图灵机!");
statusBar()->showMessage(tr("欢迎使用图灵机!"));
connect(cw, CentralWidget::setStatus, this,[this](QString message)
{
statusBar()->showMessage(message, 0);
@@ -31,7 +31,7 @@ void MainWindow::showAbout()
{
QMessageBox *aboutWindow = new QMessageBox(this);
aboutWindow->setStandardButtons(QMessageBox::Ok);
aboutWindow->setText(tr("<h1>TuringMachine</h1>"
aboutWindow->setText(tr("<h2>TuringMachine</h2>"
"<p>Based on Qt 5.10.1 (MinGW 5.3.0, 32bit)</p>"
"Source Code: <a href=\"https://github.com/c-my/TuringMachine\">https://github.com/c-my/TuringMachine</a><br/>"
"Email: "