2025-07-02 15:21:26 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Convention.Symbolization.Internal
|
|
|
|
|
{
|
|
|
|
|
public abstract class Keyword : Variable
|
|
|
|
|
{
|
|
|
|
|
protected Keyword(string keyword, Type realType) : base(new(keyword, realType))
|
|
|
|
|
{
|
|
|
|
|
Keywords.Add(keyword, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly Dictionary<string, Keyword> Keywords = new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class Keyword<T> : Keyword where T:Keyword<T>,new()
|
|
|
|
|
{
|
|
|
|
|
private static T MyInstance = new();
|
|
|
|
|
|
|
|
|
|
public static T Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MyInstance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Keyword(string keyword) : base(keyword, typeof(T))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(Variable other)
|
|
|
|
|
{
|
|
|
|
|
return MyInstance == other;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Convention.Symbolization.Keyword
|
|
|
|
|
{
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <b><see langword="import"/> namespace-expression</b>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class Import : Internal.Keyword<Import>
|
|
|
|
|
{
|
|
|
|
|
public Import() : base("import")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="namespace"/> name { ... }</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public sealed class Namespace : Internal.Keyword<Namespace>
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public Namespace() : base("namespace")
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2025-07-02 21:20:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="def"/> FunctionName(parameter-list) -> return-type { ... return return-type-instance; }</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class FunctionDef : Internal.Keyword<FunctionDef>
|
|
|
|
|
{
|
|
|
|
|
public FunctionDef() : base("def")
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="return"/> symbol;</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public sealed class Return : Internal.Keyword<Return>
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public Return() : base("return")
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2025-07-02 21:20:29 +08:00
|
|
|
|
}
|
2025-07-02 18:46:09 +08:00
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="if"/>(bool-expression) expression</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class If : Internal.Keyword<If>
|
|
|
|
|
{
|
|
|
|
|
public If() : base("if")
|
2025-07-02 15:21:26 +08:00
|
|
|
|
{
|
2025-07-02 18:46:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <b><see langword="if"/> expression <see langword="else"/> expression</b>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class Else : Internal.Keyword<Else>
|
2025-07-02 18:46:09 +08:00
|
|
|
|
{
|
2025-07-02 21:20:29 +08:00
|
|
|
|
public Else() : base("else")
|
2025-07-02 18:46:09 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2025-07-02 21:20:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="while"/>(bool-expression) expression</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class While : Internal.Keyword<While>
|
|
|
|
|
{
|
|
|
|
|
public While() : base("while")
|
2025-07-02 18:46:09 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="break"/>;</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public sealed class Break : Internal.Keyword<Break>
|
|
|
|
|
{
|
|
|
|
|
public Break() : base("break")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="continue"/>;</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
2025-07-02 18:46:09 +08:00
|
|
|
|
public sealed class Continue : Internal.Keyword<Continue>
|
|
|
|
|
{
|
|
|
|
|
public Continue() : base("continue")
|
|
|
|
|
{
|
|
|
|
|
}
|
2025-07-02 15:21:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// <summary>
|
2025-07-03 18:46:52 +08:00
|
|
|
|
/// <b><see langword="struct"/> structureName { ... }</b>
|
2025-07-02 21:20:29 +08:00
|
|
|
|
/// </summary>
|
2025-07-02 15:21:26 +08:00
|
|
|
|
public sealed class Structure : Internal.Keyword<Structure>
|
|
|
|
|
{
|
|
|
|
|
public Structure() : base("struct")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|