Working on the assembler.

This commit is contained in:
2025-07-18 12:43:42 +08:00
parent ae79862c07
commit 5701386dfb
19 changed files with 329 additions and 105 deletions

View File

@@ -0,0 +1,52 @@
using LibCLCC.NET.Lexer;
using System;
namespace SVM.Assembler.Core
{
public class Assembler
{
public const string LexDefinition =
@"
Match:
D [0-9]
Number {D}+
InstMath math
InstCvt cvt
InstSystem system
InstSys sys
InstSD sd
Register \${D}+
LabelCode \.code\:
LabelData \.data\:
string "".*""
LineEnd \n
OpAdd add
OpSub sub
OpMul mul
OpDiv div
Id:
InstMath inst
InstCvt inst
InstSystem inst
InstSys inst
InstSD sd
string String
Number Number
Register Register
OpAdd BOp
OpSub BOp
OpMul BOp
OpDiv BOp
LineEnd LE
";
LexerDefinition? definition;
public Assembler()
{
LexerDefinition.TryParse(LexDefinition, out definition);
}
}
}

View File

@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>