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); + } +}