From 194bbe845b479217b82fe738740cb5485499e739 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 3 Jul 2019 15:29:08 +0200 Subject: Allow start of comments by two slashes. Signed-off-by: Pavel Pisa --- qtmips_gui/highlighter.cpp | 10 +++++++--- qtmips_gui/mainwindow.cpp | 3 +++ 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 @@ -687,6 +687,9 @@ void MainWindow::compile_source() { if (pos >= 0) line.truncate(pos); pos = line.indexOf(";"); + if (pos >= 0) + line.truncate(pos); + pos = line.indexOf("//"); if (pos >= 0) line.truncate(pos); line = line.simplified(); -- cgit v1.2.3