diff --git a/Amogulator.csproj b/Amogulator.csproj
index 196bb0d..57cda42 100644
--- a/Amogulator.csproj
+++ b/Amogulator.csproj
@@ -7,10 +7,6 @@
true
-
-
-
-
diff --git a/AmogulatorVM.cs b/AmogulatorVM.cs
index d2422ac..3e35364 100644
--- a/AmogulatorVM.cs
+++ b/AmogulatorVM.cs
@@ -1,6 +1,8 @@
using Amogulator.Suslang;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using System;
+using System.Linq;
namespace Amogulator;
public partial class AmogulatorVM : ObservableObject {
@@ -10,13 +12,17 @@ public partial class AmogulatorVM : ObservableObject {
[RelayCommand]
private void run() {
- var ast = new Parser(this.Input, new Lexer(this.Input)).parseExpr();
- var compiler = new Compiler();
- compiler.compileExpr(ast);
- var bytecode = compiler.result();
- var vm = new VM(bytecode);
- vm.evaluate();
- this.Output = ast.astString(0) + "\n\nresult = " + ((IntValue) vm.stack.Peek()).value;
+ try {
+ var ast = new Parser(this.Input, new Lexer(this.Input)).parseExpr();
+ var compiler = new Compiler();
+ compiler.compileExpr(ast);
+ var bytecode = compiler.result();
+ var vm = new VM(bytecode);
+ vm.evaluate();
+ this.Output = $"ast = {ast.astString(0)}\n\nbytecode = [\n{string.Join("", bytecode.Select((op) => " " + op.operationString() + "\n"))}]\n\nresult = {vm.stack.Peek().valueString()}";
+ } catch (Exception e) {
+ this.Output = $"error = {e.Message}";
+ }
}
}
diff --git a/MainWindow.xaml b/MainWindow.xaml
index b4b8011..67772d8 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -39,6 +39,8 @@
FontFamily="Consolas monospace"
Background="Black"
Foreground="White"
+ TextWrapping="Wrap"
+ AcceptsReturn="True"
/>