Move syntax interfaces to separate file, add IDirective interface

This commit is contained in:
Yoshi Askharoun
2024-02-04 18:50:45 -06:00
parent cf3419c435
commit 1b1148bd58
2 changed files with 25 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
namespace Microsoft.Iris.Asm.Models;
public interface IAsmItem
{
public int Line { get; set; }
public int Column { get; set; }
}
public abstract record AsmItem : IAsmItem
{
public int Line { get; set; } = -1;
public int Column { get; set; } = -1;
}
public interface IDirective : IAsmItem;
public abstract record Directive : AsmItem, IDirective;
public interface IImport : IDirective;
public abstract record Import : Directive;
public interface IBodyItem : IAsmItem;
public abstract record BodyItem : AsmItem, IBodyItem;
+3 -6
View File
@@ -5,10 +5,7 @@ using System.Text;
namespace Microsoft.Iris.Asm.Models;
public interface IBodyItem { }
public interface IImport { }
public record Instruction(string Mnemonic, IEnumerable<Operand> Operands) : IBodyItem
public record Instruction(string Mnemonic, IEnumerable<Operand> Operands) : BodyItem
{
public Instruction(OpCode opCode, OperationType? operationType, IEnumerable<Operand> Operands)
: this(LexerMaps.GetMnemonic(opCode, operationType), Operands)
@@ -27,12 +24,12 @@ public record Instruction(string Mnemonic, IEnumerable<Operand> Operands) : IBod
: Mnemonic;
}
public record Label(string Name) : IBodyItem
public record Label(string Name) : BodyItem
{
public override string ToString() => $"{Name}:";
}
public record Operand(object Value, string Content = null)
public record Operand(object Value, string Content = null) : AsmItem
{
public override string ToString() => Content ?? Value.ToString();
}