/* * This file is part of LuaScript * https://github.com/perbone/luascrip/ * * Copyright 2017-2024 Paulo Perbone * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ #include "lua_script_language.h" #include "constants.h" #include "debug.h" #include "core/config/engine.h" #include "core/config/project_settings.h" #ifdef TOOLS_ENABLED //#include "core/config/project_settings.h" //#include "editor/editor_file_system.h" #include "editor/editor_settings.h" #endif LuaScriptLanguage *LuaScriptLanguage::singleton = nullptr; LuaScriptLanguage::LuaScriptLanguage() { print_debug("LuaScriptLanguage::constructor"); ERR_FAIL_COND(singleton); this->singleton = this; } LuaScriptLanguage::~LuaScriptLanguage() { print_debug("LuaScriptLanguage::destructor"); if (this->singleton == this) { this->singleton = nullptr; } } // TODO void LuaScriptLanguage::init() { print_debug("LuaScriptLanguage::init"); } // TODO String LuaScriptLanguage::get_name() const { print_debug("LuaScriptLanguage::get_name"); return LUA_NAME; } String LuaScriptLanguage::get_type() const { print_debug("LuaScriptLanguage::get_type"); return LUA_SCRIPT_TYPE; } String LuaScriptLanguage::get_extension() const { print_debug("LuaScriptLanguage::get_extension"); return LUA_EXTENSION; } void LuaScriptLanguage::finish() { print_debug("LuaScriptLanguage::finish"); } // TODO void LuaScriptLanguage::get_reserved_words(List *p_words) const { print_debug("LuaScriptLanguage::get_reserved_words"); static const char *keywords[] = { "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while", nullptr }; const char **w = keywords; while (*w) { p_words->push_back(*w); w++; } } bool LuaScriptLanguage::is_control_flow_keyword(const String &p_string) const { return p_string == "break" || p_string == "else" || p_string == "elseif" || p_string == "do" || p_string == "for" || p_string == "goto" || p_string == "if" || p_string == "repeat" || p_string == "return" || p_string == "then" || p_string == "until" || p_string == "while"; } void LuaScriptLanguage::get_comment_delimiters(List *p_delimiters) const { print_debug("LuaScriptLanguage::get_comment_delimiters"); p_delimiters->push_back("--[[ ]]"); // Block comment starts with double shovel and runs until double close box p_delimiters->push_back("--"); // Single-line comment starts with a double hyphens } void LuaScriptLanguage::get_doc_comment_delimiters(List *p_delimiters) const { print_debug("LuaScriptLanguage::get_doc_comment_delimiters"); } void LuaScriptLanguage::get_string_delimiters(List *p_delimiters) const { print_debug("LuaScriptLanguage::get_string_delimiters"); p_delimiters->push_back("\" \""); p_delimiters->push_back("' '"); p_delimiters->push_back("[[ ]]"); // Mult-line strings } Ref