From d85091f70d72cc4fe8130bd848a7e60bd179c87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 21 Apr 2025 18:13:01 -0300 Subject: [PATCH] Add FixScript syntax highlighting (SpartanJ/ecode#416). --- .../src/eepp/ui/doc/languages/fixscript.cpp | 63 +++++++++++++++++++ .../src/eepp/ui/doc/languages/fixscript.hpp | 10 +++ .../ui/doc/languagessyntaxhighlighting.cpp | 2 + src/tools/ecode/ecode.cpp | 2 +- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.cpp create mode 100644 src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.hpp diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.cpp new file mode 100644 index 000000000..8efdcb739 --- /dev/null +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.cpp @@ -0,0 +1,63 @@ +#include +#include + +namespace EE { namespace UI { namespace Doc { namespace Language { + +void addFixScript() { + + auto& sd = SyntaxDefinitionManager::instance()->add( + + { "FixScript", + { "%.fix$" }, + { + { { "//.-\n" }, "comment" }, + { { "/%*", "%*/" }, "comment" }, + { { "\"", "\"", "\\" }, "string" }, + { { "'", "'", "\\" }, "string" }, + { { "common_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, + { { "(class)%s+([@%a_][%w_]+)(%s*%:%s*)([%a_][%w_]+)" }, + { "keyword", "keyword", "keyword2", "operator", "keyword2" } }, + { { "(class)%s+([@%a_][%w_]+)" }, { "keyword", "keyword", "keyword2" } }, + { { "(struct)%s+([@%a_][%w_]+)" }, { "keyword", "keyword", "keyword2" } }, + { { "([@%a_][%w_]+)::([%a_][%w_]+)%f[(]" }, { "operator", "keyword2", "function" } }, + { { "[%+%-=/%*%^%%<>!~|&@]" }, "operator" }, + { { "[%a_][%w_]*%f[(]" }, "function" }, + { { "[%a_][%w_]*" }, "symbol" }, + + }, + { + + { "do", "keyword" }, { "if", "keyword" }, { "for", "keyword" }, + { "use", "keyword" }, { "var", "keyword" }, { "case", "keyword" }, + { "else", "keyword" }, { "break", "keyword" }, { "const", "keyword" }, + { "while", "keyword" }, { "import", "keyword" }, { "return", "keyword" }, + { "switch", "keyword" }, { "default", "keyword" }, { "continue", "keyword" }, + { "function", "function" }, + + { "macro", "keyword" }, { "generate", "keyword" }, { "output", "keyword" }, + + { "foreach", "keyword" }, { "class", "keyword" }, { "struct", "keyword" }, + { "static", "keyword" }, { "virtual", "keyword" }, { "override", "keyword" }, + { "new", "keyword" }, { "in", "keyword" }, { "as", "keyword" }, + { "throw", "keyword" }, { "constructor", "keyword" }, { "operator", "keyword" }, + { "super", "keyword" }, { "this", "keyword" }, + + { "optional", "keyword" }, { "transaction", "keyword" }, + + { "Dynamic", "keyword2" }, { "Void", "keyword2" }, { "Byte", "keyword2" }, + { "Short", "keyword2" }, { "Integer", "keyword2" }, { "Float", "keyword2" }, + { "Boolean", "keyword2" }, { "String", "keyword2" }, { "Long", "keyword2" }, + { "Double", "keyword2" }, + + { "true", "literal" }, { "false", "literal" }, { "null", "literal" }, + + }, + "//", + {} + + } ); + + sd.setFoldRangeType( FoldRangeType::Braces ).setFoldBraces( { { '{', '}' } } ); +} + +}}}} // namespace EE::UI::Doc::Language diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.hpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.hpp new file mode 100644 index 000000000..3494c22f9 --- /dev/null +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/fixscript.hpp @@ -0,0 +1,10 @@ +#ifndef EE_UI_DOC_FixScript +#define EE_UI_DOC_FixScript + +namespace EE { namespace UI { namespace Doc { namespace Language { + +extern void addFixScript(); + +}}}} // namespace EE::UI::Doc::Language + +#endif diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp index 124e0e178..ea626aea0 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,7 @@ void LanguagesSyntaxHighlighting::load() { addEnvironmentFile(); addFantom(); addFennel(); + addFixScript(); addFlow9(); addFortran(); addFstab(); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index f7cfffc12..260bebf98 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -3536,7 +3536,7 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mThreadPool->run( [this] { // Load language definitions Clock defClock; - SyntaxDefinitionManager::createSingleton( 125 ); + SyntaxDefinitionManager::createSingleton( 126 ); Language::LanguagesSyntaxHighlighting::load(); SyntaxDefinitionManager::instance()->setLanguageExtensionsPriority( mConfig.languagesExtensions.priorities );