From cf27c2336f49c9052aacb839bb07ae83cc41c269 Mon Sep 17 00:00:00 2001 From: ninemine <106434473+NINEMINEsigma@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:20:29 +0800 Subject: [PATCH] EP 0.1.1 --- Convention/[Symbolization]/Detail/Keyword.cs | 119 +++++++++---------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/Convention/[Symbolization]/Detail/Keyword.cs b/Convention/[Symbolization]/Detail/Keyword.cs index 6f9942f..7e112e4 100644 --- a/Convention/[Symbolization]/Detail/Keyword.cs +++ b/Convention/[Symbolization]/Detail/Keyword.cs @@ -14,8 +14,6 @@ namespace Convention.Symbolization.Internal } public static readonly Dictionary Keywords = new(); - - public abstract SymbolizationContext Execute(SymbolizationContext context, Variable[] leftParameters, Variable[] rightParameters); } public abstract class Keyword : Keyword where T:Keyword,new() @@ -44,114 +42,103 @@ namespace Convention.Symbolization.Internal namespace Convention.Symbolization.Keyword { + /// + /// namespace-expression + /// + public sealed class Import : Internal.Keyword + { + public Import() : base("import") + { + } + } + + /// + /// name + /// public sealed class Namespace : Internal.Keyword { public Namespace() : base("namespace") { } - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) + } + + /// + /// FunctionName(type1 arg1, type args...) -> return-type + /// + public sealed class FunctionDef : Internal.Keyword + { + public FunctionDef() : base("def") { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - if (rightParameters.Length != 1) - throw new InvalidGrammarException($"{this}: needs to have one and only one object"); - Internal.Namespace subNamespace = context.CurrentNamespace.CreateOrGetSubNamespace(rightParameters[0].ToString()); - subNamespace.BeginUpdate(); - SymbolizationContext subContext = new(context, subNamespace); - return subContext; } } + /// + /// symbol + /// public sealed class Return : Internal.Keyword { public Return() : base("return") { } + } - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) + /// + /// (bool-expression) + /// + public sealed class If : Internal.Keyword + { + public If() : base("if") { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - if (rightParameters.Length > 1) - throw new InvalidGrammarException($"{this}: has invalid object"); - // Inject return command to context - return context; } } + /// + /// expression expression + /// + public sealed class Else : Internal.Keyword + { + public Else() : base("else") + { + } + } + + /// + /// (bool-expression) + /// public sealed class While : Internal.Keyword { public While() : base("while") { } - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) - { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: needs to have one and only one subject"); - if (rightParameters.Length != 1) - throw new InvalidGrammarException($"{this}: has invalid object"); - SymbolizationContext subContext - return context; - } } + /// + /// + /// public sealed class Break : Internal.Keyword { public Break() : base("break") { } - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) - { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - if (rightParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid object"); - return context; - } } + /// + /// + /// public sealed class Continue : Internal.Keyword { public Continue() : base("continue") { } - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) - { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - if (rightParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid object"); - return context; - } } + /// + /// structureName + /// public sealed class Structure : Internal.Keyword { public Structure() : base("struct") { } - - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) - { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - if (rightParameters.Length != 1) - throw new InvalidGrammarException($"{this}: needs to have one and only one object"); - return context; - } - - public sealed class Function : Internal.Keyword - { - public Function() : base("def") - { - } - - public override SymbolizationContext Execute(SymbolizationContext context, Internal.Variable[] leftParameters, Internal.Variable[] rightParameters) - { - if (leftParameters.Length != 0) - throw new InvalidGrammarException($"{this}: has invalid subject"); - - } - } } }