Permalink
Browse files

AdventureSample - add expressions (2 ops)

  • Loading branch information...
bobbymcr committed Apr 22, 2018
1 parent 4739366 commit 93b2311305831f8036c681338bd479507f51f0bd
@@ -55,11 +55,12 @@ public void Line(int number, BasicStatement[] list)
public void Assign(BasicExpression left, BasicExpression right)
{
ExpressionNode x = new ExpressionNode(this.generator, this.vars, this.methods);
left.Accept(x);
ExpressionNode y = new ExpressionNode(this.generator, this.vars, this.methods);
right.Accept(y);
this.lines.Add(this.lineNumber, this.generator.AssignmentStatement(x.Value, y.Value));
ExpressionNode expr = new ExpressionNode(this.generator, this.vars, this.methods);
left.Accept(expr);
SyntaxNode lval = expr.Value;
right.Accept(expr);
SyntaxNode rval = expr.Value;
this.lines.Add(this.lineNumber, this.generator.AssignmentStatement(lval, rval));
}
public void For(BasicExpression v, BasicExpression start, BasicExpression end, BasicExpression step)
@@ -0,0 +1,30 @@
// <copyright file="AddExpressions.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace GWBas2CS.Test
{
using FluentAssertions;
using Xunit;
public sealed class AddExpressions
{
[Fact]
public void TwoNumericOperands()
{
const string Input = @"10 A=A+1";
const string Expected = @"*
private bool Main()
{
this.Init();
A_n = ((A_n) + (1));
return false;
}
*";
string actual = Test.Translate("MyProg", Input);
actual.Should().Match(Expected);
}
}
}

0 comments on commit 93b2311

Please sign in to comment.