From ba20fc818759ee0996257b27ebb50c2be69d1c8c Mon Sep 17 00:00:00 2001 From: routersys Date: Fri, 3 Jul 2026 21:30:44 +0900 Subject: [PATCH] =?UTF-8?q?Lua=E4=BA=88=E7=B4=84=E8=AA=9E=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripting/Syntax/LuaKeywords.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 LuaScript.Compat/Scripting/Syntax/LuaKeywords.cs diff --git a/LuaScript.Compat/Scripting/Syntax/LuaKeywords.cs b/LuaScript.Compat/Scripting/Syntax/LuaKeywords.cs new file mode 100644 index 0000000..972f01b --- /dev/null +++ b/LuaScript.Compat/Scripting/Syntax/LuaKeywords.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace LuaScript.Compat.Syntax +{ + internal static class LuaKeywords + { + private static readonly HashSet Reserved = new() + { + "and", "break", "do", "else", "elseif", "end", "false", "for", "function", + "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", + "then", "true", "until", "while", + }; + + private static readonly HashSet ExpressionSafe = new() + { + "and", "or", "not", "nil", "true", "false", + }; + + public static bool IsReserved(string name) => Reserved.Contains(name); + + public static bool IsExpressionBoundary(string name) => Reserved.Contains(name) && !ExpressionSafe.Contains(name); + } +}