From c5da497bb3fc0a7c6d500545e2bada130fd34771 Mon Sep 17 00:00:00 2001 From: routersys Date: Fri, 3 Jul 2026 21:31:52 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AB=96=E7=90=86=E6=BC=94=E7=AE=97=E5=AD=90!/?= =?UTF-8?q?&&/||=E8=A6=8F=E5=89=87=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripting/Syntax/Rules/LuaLogicalRules.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 LuaScript.Compat/Scripting/Syntax/Rules/LuaLogicalRules.cs diff --git a/LuaScript.Compat/Scripting/Syntax/Rules/LuaLogicalRules.cs b/LuaScript.Compat/Scripting/Syntax/Rules/LuaLogicalRules.cs new file mode 100644 index 0000000..ca0a0ba --- /dev/null +++ b/LuaScript.Compat/Scripting/Syntax/Rules/LuaLogicalRules.cs @@ -0,0 +1,44 @@ +namespace LuaScript.Compat.Syntax.Rules +{ + [LuaSyntaxRule(40)] + internal sealed class LogicalNotRule : ILuaSyntaxRule + { + public bool TryApply(LuaRewriteContext context) + { + if (!context.Current.IsOperator("!")) + return false; + + context.Advance(); + context.EmitWord("not"); + return true; + } + } + + [LuaSyntaxRule(50)] + internal sealed class AndAliasRule : ILuaSyntaxRule + { + public bool TryApply(LuaRewriteContext context) + { + if (!context.Current.IsOperator("&&")) + return false; + + context.Advance(); + context.EmitWord("and"); + return true; + } + } + + [LuaSyntaxRule(60)] + internal sealed class OrAliasRule : ILuaSyntaxRule + { + public bool TryApply(LuaRewriteContext context) + { + if (!context.Current.IsOperator("||")) + return false; + + context.Advance(); + context.EmitWord("or"); + return true; + } + } +}