diff --git a/Mond.Tests/Expressions/DecoratorTests.cs b/Mond.Tests/Expressions/DecoratorTests.cs index 70be4e5..893e215 100644 --- a/Mond.Tests/Expressions/DecoratorTests.cs +++ b/Mond.Tests/Expressions/DecoratorTests.cs @@ -5,6 +5,19 @@ namespace Mond.Tests.Expressions [TestFixture] public class DecoratorTests { + [Test] + public void Decorator_ParsesTrailingSemicolon() + { + Assert.Throws(() => Script.Run(@" + fun identity(x) -> x; + + @identity + fun add(x, y) -> x + y + + return add(2, 2); + ")); + } + [Test] public void FunctionDecorator() { diff --git a/Mond/Compiler/Instruction.cs b/Mond/Compiler/Instruction.cs index 1602dd1..9581ec6 100644 --- a/Mond/Compiler/Instruction.cs +++ b/Mond/Compiler/Instruction.cs @@ -100,11 +100,10 @@ public int Length public void Print() { - if (Type >= InstructionType.DebugInfo) - return; - if (Type == InstructionType.Label) Console.ForegroundColor = ConsoleColor.DarkGreen; + else if (Type >= InstructionType.DebugInfo) + Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("{0:X4} {1,-15} ", Offset, Type.ToString().ToLower()); diff --git a/Mond/Compiler/InstructionOperands.cs b/Mond/Compiler/InstructionOperands.cs index cbed55f..4727623 100644 --- a/Mond/Compiler/InstructionOperands.cs +++ b/Mond/Compiler/InstructionOperands.cs @@ -226,7 +226,11 @@ public DebugIdentifierOperand(ConstantOperand name, bool isReadOnly, int Id = id; } - public virtual void Print() => throw new NotSupportedException(); + public virtual void Print() + { + var desc = $"{FrameIndex}:{Id}={Name.Value}[{(IsReadOnly ? "r" : "rw")}]"; + Console.Write("{0,-30} (dbgident)", desc); + } public int Length => 0; diff --git a/Mond/Compiler/Parselets/Statements/DecoratorParselet.cs b/Mond/Compiler/Parselets/Statements/DecoratorParselet.cs index 990a25c..f4dc605 100644 --- a/Mond/Compiler/Parselets/Statements/DecoratorParselet.cs +++ b/Mond/Compiler/Parselets/Statements/DecoratorParselet.cs @@ -18,7 +18,7 @@ public Expression Parse(Parser parser, Token token, out bool trailingSemicolon) while (parser.MatchAndTake(TokenType.Decorator)) exprs.Add(parser.ParseExpression()); - var stmt = parser.ParseStatement(trailingSemicolon); + var stmt = parser.ParseStatement(); if (stmt is VarExpression varExpr) {