-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
roger.alsing
committed
Feb 28, 2010
1 parent
8534503
commit 0dac3c0
Showing
38 changed files
with
1,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Structural.AST | ||
{ | ||
public abstract class AstNode | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.