Permalink
Browse files

AdventureSample - support END

  • Loading branch information...
bobbymcr committed Apr 23, 2018
1 parent b55b896 commit c5df9480f276535b2b824c32d58dca75ef427647
@@ -123,6 +123,9 @@ public void Void(string name)
case "Cls":
this.AddCls();
break;
case "End":
this.AddEnd();
break;
case "Return":
this.AddReturn();
break;
@@ -251,6 +254,12 @@ private void AddReturn()
this.lines.AddReturn(this.lineNumber);
}
private void AddEnd()
{
var ret = this.generator.ReturnStatement(this.generator.LiteralExpression(2));
this.lines.Add(this.lineNumber, ret);
}
private void AddRun()
{
var ret = this.generator.ReturnStatement(this.generator.LiteralExpression(1));
@@ -24,6 +24,44 @@ private int Sub_30()
return 0;
}
private int Main()
{
this.Init();
L10:
;
switch (Sub_30())
{
case 1:
return 1;
case 2:
return 2;
}
goto L10;
return 2;
}
*";
string actual = Test.Translate("MyProg", Input);
actual.Should().Match(Expected);
}
[Fact]
public void WithEnd()
{
const string Input =
@"10 GOSUB 30
20 GOTO 10
30 END
40 RETURN";
const string Expected = @"*
private int Sub_30()
{
return 2;
return 0;
}
private int Main()
{
this.Init();

0 comments on commit c5df948

Please sign in to comment.