Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
roger.alsing committed Feb 28, 2010
1 parent 8534503 commit 0dac3c0
Show file tree
Hide file tree
Showing 38 changed files with 1,266 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Structural/Structural.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Structural", "Structural\Structural.csproj", "{6DFAFA58-AA4D-452B-98DB-760780828E50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6DFAFA58-AA4D-452B-98DB-760780828E50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DFAFA58-AA4D-452B-98DB-760780828E50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DFAFA58-AA4D-452B-98DB-760780828E50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DFAFA58-AA4D-452B-98DB-760780828E50}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added Structural/Structural.suo
Binary file not shown.
16 changes: 16 additions & 0 deletions Structural/Structural/AST/AstKeyAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
public class AstKeyAttribute : Attribute
{
public string Name { get; set; }
public AstKeyAttribute(string name)
{
Name = name;
}
}
}
18 changes: 18 additions & 0 deletions Structural/Structural/AST/Body.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
[AstKey("body")]
public class Body : AstNode
{
public List<Statement> Statements { get; set; }

public Body()
{
Statements = new List<Statement>();
}
}
}
14 changes: 14 additions & 0 deletions Structural/Structural/AST/Expression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace Structural.AST
{
[AstKey("exp")]
public class Expression : Value
{
public List<AstNode> Operands { get; set; }
public Expression()
{
Operands = new List<AstNode>();
}
}
}
20 changes: 20 additions & 0 deletions Structural/Structural/AST/If.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
[AstKey("if")]
public class If : Statement
{
public Expression Condition { get; set; }
public Body Body { get; set; }
public If Next { get; set; }

public If()
{
Body = new Body();
}
}
}
8 changes: 8 additions & 0 deletions Structural/Structural/AST/IntegerLiteral.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Structural.AST
{
[AstKey("int")]
public class IntegerLiteral : Value
{
public int Value { get; set; }
}
}
6 changes: 6 additions & 0 deletions Structural/Structural/AST/Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Structural.AST
{
public abstract class AstNode
{
}
}
34 changes: 34 additions & 0 deletions Structural/Structural/AST/Operator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Structural.AST
{

public abstract class Operator : Value
{
public Value LeftOperand { get; set; }

public Value RightOperand { get; set; }
}

[AstKey("+")]
public class AddOperator : Operator
{

}

[AstKey("-")]
public class SubOperator : Operator
{

}

[AstKey("*")]
public class MulOperator : Operator
{

}

[AstKey("/")]
public class DivOperator : Operator
{

}
}
7 changes: 7 additions & 0 deletions Structural/Structural/AST/Print.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Structural.AST
{
public class Print : Statement
{
public Value Value { get; set; }
}
}
17 changes: 17 additions & 0 deletions Structural/Structural/AST/Root.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
public class Root : AstNode
{
public Body Body { get; set; }

public Root()
{
Body = new Body();
}
}
}
11 changes: 11 additions & 0 deletions Structural/Structural/AST/Statement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
public class Statement : AstNode
{
}
}
8 changes: 8 additions & 0 deletions Structural/Structural/AST/StringLiteral.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Structural.AST
{
[AstKey("string")]
public class StringLiteral : Value
{
public string Value { get; set; }
}
}
12 changes: 12 additions & 0 deletions Structural/Structural/AST/Value.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Structural.AST
{
public class Value : AstNode
{
public static readonly EmptyValue Empty = new EmptyValue();
}

public class EmptyValue : Value
{

}
}
14 changes: 14 additions & 0 deletions Structural/Structural/AST/VariableDeclaration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Structural.AST
{
[AstKey("var")]
public class VariableDeclaration : Statement
{
public string Name { get; set; }
public Expression InitialValue { get; set; }
}
}
49 changes: 49 additions & 0 deletions Structural/Structural/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions Structural/Structural/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Structural.AST;
using Structural.Projections;

namespace Structural
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs args)
{

}

private void Form1_Paint(object sender, PaintEventArgs args)
{
var e = new StructureEngine();

var i = new If();

i.Condition = null;
e.Root.Body.Statements.Add(i);

var v = new VariableDeclaration();
v.Name = null;
v.InitialValue = null;

var p = new Print();

var s1 = new StringLiteral
{
Value = "hej du glade Tag en spade och..."
};
var s2 = new StringLiteral
{
Value = "Mer text",
};

var exp = new AddOperator()
{
LeftOperand = s1,
RightOperand = s2,
};

p.Value = exp;

i.Body.Statements.Add(v);
i.Body.Statements.Add(p);

args.Graphics.Clear(Color.White);
e.Render(args.Graphics);

}
}
}
Loading

0 comments on commit 0dac3c0

Please sign in to comment.