EP 0.1.1 Symbolization
This commit is contained in:
44
Convention/[Symbolization]/Internal/Functional.cs
Normal file
44
Convention/[Symbolization]/Internal/Functional.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Convention.Symbolization.Internal
|
||||||
|
{
|
||||||
|
public class Function : Variable
|
||||||
|
{
|
||||||
|
public Variable Invoke(Variable[] parameters)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly struct FunctionSymbol
|
||||||
|
{
|
||||||
|
public readonly string SymbolName;
|
||||||
|
public readonly Type ReturnType;
|
||||||
|
public readonly Type[] ParameterTypes;
|
||||||
|
public readonly Modification[] Modifiers;
|
||||||
|
public readonly string FullName;
|
||||||
|
|
||||||
|
public FunctionSymbol(string symbolName, Type returnType, Type[] parameterTypes, Modification[] modifiers)
|
||||||
|
{
|
||||||
|
this.SymbolName = symbolName;
|
||||||
|
this.ReturnType = returnType;
|
||||||
|
this.ParameterTypes = parameterTypes;
|
||||||
|
this.Modifiers = modifiers;
|
||||||
|
this.FullName = $"{returnType.FullName} {symbolName}({string.Join(',', parameterTypes.ToList().ConvertAll(x => x.FullName))}) {string.Join(' ', modifiers.ToList().ConvertAll(x => x.ToString()))}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(FunctionSymbol other)
|
||||||
|
{
|
||||||
|
return other.FullName.Equals(FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return FullName.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Convention/[Symbolization]/Internal/Modification.cs
Normal file
12
Convention/[Symbolization]/Internal/Modification.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Convention.Symbolization.Internal
|
||||||
|
{
|
||||||
|
public class Modification : Variable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
40
Convention/[Symbolization]/Internal/Variable.cs
Normal file
40
Convention/[Symbolization]/Internal/Variable.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Convention.Symbolization.Internal
|
||||||
|
{
|
||||||
|
public class Variable
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly struct VariableSymbol
|
||||||
|
{
|
||||||
|
public readonly string SymbolName;
|
||||||
|
public readonly Type VariableType;
|
||||||
|
|
||||||
|
public VariableSymbol(string symbolName, Type variableType)
|
||||||
|
{
|
||||||
|
this.SymbolName = symbolName;
|
||||||
|
this.VariableType = variableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(VariableSymbol other)
|
||||||
|
{
|
||||||
|
return other.SymbolName.Equals(SymbolName) && other.VariableType.Equals(VariableType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return new Tuple<string, Type>(SymbolName, VariableType).GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class VariableContext
|
||||||
|
{
|
||||||
|
public Dictionary<VariableSymbol, Variable> Variables = new();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Convention.Symbolization.Internal
|
|
||||||
{
|
|
||||||
internal class Reader
|
|
||||||
{
|
|
||||||
private ToolFile FileCore;
|
|
||||||
|
|
||||||
public Reader(string file)
|
|
||||||
{
|
|
||||||
FileCore = new(file);
|
|
||||||
if (FileCore.Exists() == false)
|
|
||||||
throw new FileNotFoundException($"{file} not exists");
|
|
||||||
FileCore.Open(FileMode.Open);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SymbolizationContext BuildContext()
|
|
||||||
{
|
|
||||||
SymbolizationContext context = new();
|
|
||||||
using StreamReader reader = new(FileCore.OriginControlStream);
|
|
||||||
for (; reader.EndOfStream==false;)
|
|
||||||
{
|
|
||||||
var line = reader.ReadLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,52 +6,26 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Convention.Symbolization
|
namespace Convention.Symbolization
|
||||||
{
|
{
|
||||||
public sealed class SymbolizationContext
|
public class SymbolizationContext
|
||||||
{
|
{
|
||||||
public SymbolizationContext() { }
|
public Internal.VariableContext Context = new();
|
||||||
public SymbolizationContext(SymbolizationContext forward)
|
|
||||||
{
|
|
||||||
ParentContext = forward;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly SymbolizationContext ParentContext;
|
public class SymbolizationRunner
|
||||||
|
|
||||||
public void Execute(string commandsBlock)
|
|
||||||
{
|
{
|
||||||
|
private readonly SymbolizationContext Context;
|
||||||
|
|
||||||
}
|
public SymbolizationRunner(SymbolizationContext context)
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class SymbolizationCore
|
|
||||||
{
|
{
|
||||||
internal SymbolizationCore(Internal.Reader reader)
|
Context = context;
|
||||||
|
}
|
||||||
|
public SymbolizationRunner() :this(new()){ }
|
||||||
|
|
||||||
|
public void Execute(string funcName)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SymbolizationContext Context { get; private set; }
|
public void Execute()=>Execute("main")
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Symbolization
|
|
||||||
{
|
|
||||||
public static SymbolizationCore Build(string file)
|
|
||||||
{
|
|
||||||
return new SymbolizationCore(new(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SymbolizationContext Execute(string commandsBlock)
|
|
||||||
{
|
|
||||||
SymbolizationContext context = new();
|
|
||||||
context.Execute(commandsBlock);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SymbolizationContext Execute(SymbolizationContext forward,string commandsBlock)
|
|
||||||
{
|
|
||||||
SymbolizationContext context = new(forward);
|
|
||||||
context.Execute(commandsBlock);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user