mirror of
https://github.com/creeperlv/SVM.git
synced 2026-01-11 21:09:53 +00:00
Working on the assembler.
This commit is contained in:
52
src/SVM.Assembler.Core/Assembler.cs
Normal file
52
src/SVM.Assembler.Core/Assembler.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/SVM.Assembler.Core/SVM.Assembler.Core.csproj
Normal file
8
src/SVM.Assembler.Core/SVM.Assembler.Core.csproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user