mirror of
https://github.com/creeperlv/SVM.git
synced 2026-01-11 04:49:53 +00:00
53 lines
653 B
C#
53 lines
653 B
C#
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);
|
|
}
|
|
}
|
|
}
|