diff --git a/Upsilon/Binder/BoundBinaryExpression.cs b/Upsilon/Binder/BoundExpressions/BoundBinaryExpression.cs similarity index 100% rename from Upsilon/Binder/BoundBinaryExpression.cs rename to Upsilon/Binder/BoundExpressions/BoundBinaryExpression.cs diff --git a/Upsilon/Binder/BoundExpression.cs b/Upsilon/Binder/BoundExpressions/BoundExpression.cs similarity index 100% rename from Upsilon/Binder/BoundExpression.cs rename to Upsilon/Binder/BoundExpressions/BoundExpression.cs diff --git a/Upsilon/Binder/BoundLiteralExpression.cs b/Upsilon/Binder/BoundExpressions/BoundLiteralExpression.cs similarity index 100% rename from Upsilon/Binder/BoundLiteralExpression.cs rename to Upsilon/Binder/BoundExpressions/BoundLiteralExpression.cs diff --git a/Upsilon/Binder/BoundUnaryExpression.cs b/Upsilon/Binder/BoundExpressions/BoundUnaryExpression.cs similarity index 100% rename from Upsilon/Binder/BoundUnaryExpression.cs rename to Upsilon/Binder/BoundExpressions/BoundUnaryExpression.cs diff --git a/Upsilon/Binder/BoundVariableExpression.cs b/Upsilon/Binder/BoundExpressions/BoundVariableExpression.cs similarity index 100% rename from Upsilon/Binder/BoundVariableExpression.cs rename to Upsilon/Binder/BoundExpressions/BoundVariableExpression.cs diff --git a/Upsilon/Binder/BoundBlockStatement.cs b/Upsilon/Binder/BoundStatements/BoundBlockStatement.cs similarity index 100% rename from Upsilon/Binder/BoundBlockStatement.cs rename to Upsilon/Binder/BoundStatements/BoundBlockStatement.cs diff --git a/Upsilon/Binder/BoundExpressionStatement.cs b/Upsilon/Binder/BoundStatements/BoundExpressionStatement.cs similarity index 100% rename from Upsilon/Binder/BoundExpressionStatement.cs rename to Upsilon/Binder/BoundStatements/BoundExpressionStatement.cs diff --git a/Upsilon/Binder/BoundIfStatement.cs b/Upsilon/Binder/BoundStatements/BoundIfStatement.cs similarity index 100% rename from Upsilon/Binder/BoundIfStatement.cs rename to Upsilon/Binder/BoundStatements/BoundIfStatement.cs diff --git a/Upsilon/Binder/BoundScript.cs b/Upsilon/Binder/BoundStatements/BoundScript.cs similarity index 100% rename from Upsilon/Binder/BoundScript.cs rename to Upsilon/Binder/BoundStatements/BoundScript.cs diff --git a/Upsilon/Binder/BoundStatement.cs b/Upsilon/Binder/BoundStatements/BoundStatement.cs similarity index 100% rename from Upsilon/Binder/BoundStatement.cs rename to Upsilon/Binder/BoundStatements/BoundStatement.cs diff --git a/Upsilon/Binder/BoundVariableAssignment.cs b/Upsilon/Binder/BoundStatements/BoundVariableAssignment.cs similarity index 100% rename from Upsilon/Binder/BoundVariableAssignment.cs rename to Upsilon/Binder/BoundStatements/BoundVariableAssignment.cs diff --git a/Upsilon/Upsilon.csproj.DotSettings b/Upsilon/Upsilon.csproj.DotSettings index 4cddffc..c6e2e34 100644 --- a/Upsilon/Upsilon.csproj.DotSettings +++ b/Upsilon/Upsilon.csproj.DotSettings @@ -1,3 +1,5 @@  + True + True True True \ No newline at end of file diff --git a/UpsilonCompiler/Compiler.cs b/UpsilonCompiler/Compiler.cs index 7d61ca8..8050e71 100644 --- a/UpsilonCompiler/Compiler.cs +++ b/UpsilonCompiler/Compiler.cs @@ -2,58 +2,57 @@ using System; using System.Text; using Upsilon.BaseTypes.Number; using Upsilon.Binder; -using System.Collections.Immutable; using Type = Upsilon.BaseTypes.Type; namespace UpsilonCompiler { - public class Compiler + public class Transpiler { - public string CompileToCSharp(BoundScript script) + public string TranspilerToCSharp(BoundScript script) { var s = script.Statement; - return Compile(s); + return Transpile(s); } - private string Compile(BoundNode e) + private string Transpile(BoundNode e) { switch (e.Kind) { case BoundKind.BoundScript: throw new ArgumentOutOfRangeException(); case BoundKind.BoundLiteralExpression: - return CompileLiteralExpression((BoundLiteralExpression) e); + return TranspileLiteralExpression((BoundLiteralExpression) e); case BoundKind.BoundBinaryExpression: - return CompileBinaryExpression((BoundBinaryExpression) e); + return TranspileBinaryExpression((BoundBinaryExpression) e); case BoundKind.BoundUnaryExpression: case BoundKind.VariableExpression: case BoundKind.BoundAssignmentStatement: throw new ArgumentOutOfRangeException(); case BoundKind.BoundExpressionStatement: - return Compile(((BoundExpressionStatement)e).Expression); + return Transpile(((BoundExpressionStatement)e).Expression); case BoundKind.BoundBlockStatement: - return CompileBlockStatement((BoundBlockStatement) e); + return TranspileBlockStatement((BoundBlockStatement) e); case BoundKind.BoundIfStatement: - return CompileIfStatement((BoundIfStatement) e); + return TranspileIfStatement((BoundIfStatement) e); case BoundKind.BoundElseStatement: default: throw new ArgumentOutOfRangeException(e.Kind.ToString()); } } - private string CompileBlockStatement(BoundBlockStatement s) + private string TranspileBlockStatement(BoundBlockStatement s) { var sb = new StringBuilder(); foreach (var sStatement in s.Statements) { - var compile = Compile(sStatement); + var compile = Transpile(sStatement); sb.Append(compile); sb.Append(";\n"); } return sb.ToString(); } - private string CompileLiteralExpression(BoundLiteralExpression e) + private static string TranspileLiteralExpression(BoundLiteralExpression e) { switch (e.Type) { @@ -73,12 +72,12 @@ namespace UpsilonCompiler } } - private string CompileBinaryExpression(BoundBinaryExpression e) + private string TranspileBinaryExpression(BoundBinaryExpression e) { var sb = new StringBuilder(); sb.Append("("); - var compiledLeft = Compile(e.LeftExpression); - var compiledRight = Compile(e.RightExpression); + var compiledLeft = Transpile(e.LeftExpression); + var compiledRight = Transpile(e.RightExpression); sb.Append(compiledLeft); switch (e.Operator.Kind) { @@ -109,15 +108,15 @@ namespace UpsilonCompiler return sb.ToString(); } - private string CompileIfStatement(BoundIfStatement s, bool isElseIf = false) + private string TranspileIfStatement(BoundIfStatement s, bool isElseIf = false) { var sb = new StringBuilder(); var openToken = isElseIf ? "else if(" : "if("; sb.Append(openToken); - var compiledCondition = Compile(s.Condition); + var compiledCondition = Transpile(s.Condition); sb.Append(compiledCondition); sb.Append("){\n"); - var compiledBlock = Compile(s.Block); + var compiledBlock = Transpile(s.Block); sb.Append(compiledBlock); sb.Append("}"); return sb.ToString(); diff --git a/Yc/Program.cs b/Yc/Program.cs index 4d65d73..cedb457 100644 --- a/Yc/Program.cs +++ b/Yc/Program.cs @@ -35,8 +35,8 @@ namespace Yc continue; } - var compiler = new Compiler(); - var compiled = compiler.CompileToCSharp(parsed.Bind()); + var compiler = new Transpiler(); + var compiled = compiler.TranspilerToCSharp(parsed.Bind()); Console.WriteLine(compiled); /* var evaluate = parsed.Evaluate();