File indexing completed on 2024-04-28 11:20:31

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2014 Lucas Hermann Negri <lucashnegri@gmail.com>
0004 */
0005 
0006 #include "luahighlighter.h"
0007 #include "luakeywords.h"
0008 #include "luahelper.h"
0009 
0010 #include <QRegularExpression>
0011 
0012 LuaHighlighter::LuaHighlighter(QObject* parent): DefaultHighlighter(parent)
0013 {
0014     addKeywords (LuaKeywords::instance()->keywords());
0015     addFunctions(LuaKeywords::instance()->functions());
0016     addVariables(LuaKeywords::instance()->variables());
0017 
0018     addRule(QRegularExpression(QStringLiteral("[A-Za-z0-9_]+(?=\\()"))    , functionFormat());
0019     addRule(QRegularExpression(QStringLiteral("\"[^\"]*\""))              , stringFormat());
0020     addRule(QRegularExpression(QStringLiteral("'[^\'].*'"))               , stringFormat());
0021     addRule(QRegularExpression(QStringLiteral("--[^\n]*"))                , commentFormat());
0022     // did not add support for the multiline comment or multiline string
0023 }