aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 15:29:08 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 15:29:08 +0200
commit194bbe845b479217b82fe738740cb5485499e739 (patch)
tree0001afc2da3d6834a51d69f2fba34407406fb89d /qtmips_gui
parent2b04361cc673a515fd5bde133fdf2692885e008f (diff)
downloadqtmips-194bbe845b479217b82fe738740cb5485499e739.tar.gz
qtmips-194bbe845b479217b82fe738740cb5485499e739.tar.bz2
qtmips-194bbe845b479217b82fe738740cb5485499e739.zip
Allow start of comments by two slashes.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/highlighter.cpp10
-rw-r--r--qtmips_gui/mainwindow.cpp3
2 files changed, 10 insertions, 3 deletions
diff --git a/qtmips_gui/highlighter.cpp b/qtmips_gui/highlighter.cpp
index 5924eba..baaa8d0 100644
--- a/qtmips_gui/highlighter.cpp
+++ b/qtmips_gui/highlighter.cpp
@@ -47,7 +47,10 @@ Highlighter::Highlighter(QTextDocument *parent)
keywordFormat.setFontWeight(QFont::Bold);
const QString keywordPatterns[] = {
QStringLiteral("\\.org\\b"), QStringLiteral("\\.word\\b"),
- QStringLiteral("\\.text\\b"), QStringLiteral("\\.data\\b")
+ QStringLiteral("\\.text\\b"), QStringLiteral("\\.data\\b"),
+ QStringLiteral("\\.globl\\b"), QStringLiteral("\\.set\\b"),
+ QStringLiteral("\\.equ\\b"), QStringLiteral("\\.end\\b"),
+ QStringLiteral("\\.ent\\b")
};
for (const QString &pattern : keywordPatterns) {
@@ -84,11 +87,12 @@ Highlighter::Highlighter(QTextDocument *parent)
rule.pattern = QRegularExpression(QStringLiteral(";[^\n]*"));
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
-
- singleLineCommentFormat.setForeground(Qt::red);
rule.pattern = QRegularExpression(QStringLiteral("#[^\n]*"));
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
+ rule.pattern = QRegularExpression(QStringLiteral("//[^\n]*"));
+ rule.format = singleLineCommentFormat;
+ highlightingRules.append(rule);
multiLineCommentFormat.setForeground(Qt::red);
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 306099a..46352ea 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -689,6 +689,9 @@ void MainWindow::compile_source() {
pos = line.indexOf(";");
if (pos >= 0)
line.truncate(pos);
+ pos = line.indexOf("//");
+ if (pos >= 0)
+ line.truncate(pos);
line = line.simplified();
pos = line.indexOf(":");
if (pos >= 0) {