Skip to content

Commit

Permalink
abstract out the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
richorama committed Feb 26, 2024
1 parent 1edd800 commit 1340f46
Show file tree
Hide file tree
Showing 27 changed files with 213 additions and 180 deletions.
2 changes: 1 addition & 1 deletion IronBlock.BlazorSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static string Evaluate(string xml)
{
var printBlock = new CustomPrintBlock();

new IronBlock.Parser()
new IronBlock.XmlParser()
.AddStandardBlocks()
.AddBlock("text_print", printBlock)
.Parse(xml)
Expand Down
2 changes: 1 addition & 1 deletion IronBlock.Runner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Specify any of the following as a second argument
var xml = File.ReadAllText(filename);

var parser =
new Parser()
new XmlParser()
.AddStandardBlocks()
.Parse(xml);

Expand Down
12 changes: 6 additions & 6 deletions IronBlock.Tests/BugfixTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Issue_17()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -97,7 +97,7 @@ public void Issue_40()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -136,7 +136,7 @@ public void Issue_44()
</block>
</xml>";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -182,7 +182,7 @@ public void Issue_45_1()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -226,7 +226,7 @@ public void Issue_45_2()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -255,7 +255,7 @@ public void DemoVariable()

var context = new Context();
context.Variables.Add("x", "bar");
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate(context);
Expand Down
8 changes: 4 additions & 4 deletions IronBlock.Tests/ColourTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Test_Colour_Picker()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand All @@ -38,7 +38,7 @@ public void Test_Colour_Random()
</xml>
";

var program = new Parser()
var program = new XmlParser()
.AddStandardBlocks()
.Parse(xml);

Expand Down Expand Up @@ -78,7 +78,7 @@ public void Test_Colour_Rgb()
</xml>
";

var colour = new Parser()
var colour = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate() as string;
Expand Down Expand Up @@ -113,7 +113,7 @@ public void Test_Colour_Blend()
</xml>
";

var colour = new Parser()
var colour = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate() as string;
Expand Down
12 changes: 6 additions & 6 deletions IronBlock.Tests/ControlsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Test_Controls_If()
</block>
</xml>
";
new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -102,7 +102,7 @@ public void Test_Controls_WhileUntil()
</block>
</xml>
";
var parser = new Parser()
var parser = new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -159,7 +159,7 @@ public void Test_Controls_Flow_Continue()
</block>
</xml>
";
new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -216,7 +216,7 @@ public void Test_Controls_Flow_Break()
</block>
</xml>
";
new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -269,7 +269,7 @@ public void Test_Controls_For_Each()
</block>
</xml>
";
new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -320,7 +320,7 @@ public void Test_Controls_For()
</block>
</xml>
";
new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down
2 changes: 1 addition & 1 deletion IronBlock.Tests/CustomBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Test_Custom_Block()
";

var printBlock = new CustomPrintBlock();
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.AddBlock("text_print", printBlock)
.Parse(xml)
Expand Down
4 changes: 2 additions & 2 deletions IronBlock.Tests/ExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ExampleTests
public void Test_Example1()
{
var xml = File.ReadAllText("../../../Examples/example1.xml");
var parser = new Parser();
var parser = new XmlParser();

parser.AddStandardBlocks();
var printer = parser.AddDebugPrinter();
Expand All @@ -27,7 +27,7 @@ public void Test_Example1()
public void Test_Example2()
{
var xml = File.ReadAllText("../../../Examples/example2.xml");
var parser = new Parser();
var parser = new XmlParser();

parser.AddStandardBlocks();
var printer = parser.AddDebugPrinter();
Expand Down
6 changes: 3 additions & 3 deletions IronBlock.Tests/FunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Test_Procedure_No_Return()
</xml>
";

new Parser()
new XmlParser()
.AddStandardBlocks()
.AddDebugPrinter()
.Parse(xml)
Expand Down Expand Up @@ -86,7 +86,7 @@ public void Test_Procedure_Return()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -131,7 +131,7 @@ public void Test_Procedure_If_Return()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down
16 changes: 8 additions & 8 deletions IronBlock.Tests/ListsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Test_List_Create_With()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -68,7 +68,7 @@ public void Test_List_Split()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -114,7 +114,7 @@ public void Test_Lists_Join()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -151,7 +151,7 @@ public void Test_Lists_Length()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -181,7 +181,7 @@ public void Test_Lists_Repeat()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand All @@ -206,7 +206,7 @@ public void Test_Lists_IsEmpty()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -248,7 +248,7 @@ public void Test_Lists_IndexOf()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -291,7 +291,7 @@ public void Test_Lists_GetIndex()
</xml>
";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down
14 changes: 7 additions & 7 deletions IronBlock.Tests/LogicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Test_Logic_Boolean()
</block>
</xml>
";
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -50,7 +50,7 @@ public void Test_Logic_Operation_Or()
</block>
</xml>";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -78,7 +78,7 @@ public void Test_Logic_Operation_And()
</value>
</block>
</xml>";
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand All @@ -100,7 +100,7 @@ public void Test_Logic_Negate()
</value>
</block>
</xml>";
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand All @@ -116,7 +116,7 @@ public void Test_Logic_Null()
<xml>
<block type=""logic_null""></block>
</xml>";
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -148,7 +148,7 @@ public void Test_Logic_Ternary()
</value>
</block>
</xml>";
var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down Expand Up @@ -178,7 +178,7 @@ public void Test_Logic_Operation_Lte()
</block>
</xml>";

var output = new Parser()
var output = new XmlParser()
.AddStandardBlocks()
.Parse(xml)
.Evaluate();
Expand Down
Loading

0 comments on commit 1340f46

Please sign in to comment.