Created
October 30, 2013 19:10
-
-
Save mrcnkoba/7238312 to your computer and use it in GitHub Desktop.
jeszcze jedno z dynamicami
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
using System; | |
namespace SimplifyVisitor | |
{ | |
public class ConcreteVisitor : VisitorBase//<Node> | |
{ | |
protected override void Visit(ConstantNode node) | |
{ | |
Console.WriteLine("Visiting constant node"); | |
} | |
protected override void Visit(PlusNode node) | |
{ | |
Console.WriteLine("Visiting plus node"); | |
} | |
protected override void Visit(MinusNode node) | |
{ | |
Console.WriteLine("Visiting minus node"); | |
} | |
} | |
} | |
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
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace SimplifyVisitor | |
{ | |
public abstract class VisitorBase | |
{ | |
public void Dispatch(Node node) | |
{ | |
this.Visit((dynamic)node); | |
} | |
protected abstract void Visit(ConstantNode node); | |
protected abstract void Visit(PlusNode node); | |
protected abstract void Visit(MinusNode node); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment