diff --git a/YololAssembler/Grammar/AST/Program.cs b/YololAssembler/Grammar/AST/Program.cs index dc7e809..ac1cb8b 100644 --- a/YololAssembler/Grammar/AST/Program.cs +++ b/YololAssembler/Grammar/AST/Program.cs @@ -25,6 +25,9 @@ public Result Compile(bool compress = true) // Replace line labels lines = Apply(Labels().ToArray(), lines.ToArray()).ToArray(); + // Replace implicit line labels + lines = ApplyImplicitLabels(lines).ToArray(); + // Early out if compression should not be applied var yolol = string.Join("\n", lines); if (!compress) @@ -39,6 +42,16 @@ public Result Compile(bool compress = true) return new Result(Compress(parsedYolol.Ok)); } + private IEnumerable ApplyImplicitLabels(IEnumerable lines) + { + var lineNum = 1; + foreach (var line in lines) + { + yield return line.Replace("@", lineNum.ToString()); + lineNum++; + } + } + private static string Compress(Yolol.Grammar.AST.Program yolol) { //todo: compress diff --git a/YololAssembler/YololAssembler.csproj b/YololAssembler/YololAssembler.csproj index a8f0b42..39745ea 100644 --- a/YololAssembler/YololAssembler.csproj +++ b/YololAssembler/YololAssembler.csproj @@ -4,6 +4,9 @@ Exe netcoreapp3.1 enable + YololAssembler.Program + Martin Evans + Cylon