public static void Display() { Context context = new Context(); var expression = new NonterminalExpression(); expression.Interpret(context); }
/// <summary> /// NonterminalExpression を作成する. /// </summary> /// <param name="name"></param> /// <returns></returns> public static GeneratedExpression CreateNonterminal(string name) { NonterminalExpression exp = new NonterminalExpression(); exp.Type = ExpressionType.Nonterminal; exp.Name = name; return(exp); }
void Main() { Context context = new Context(); NonterminalExpression expression = new NonterminalExpression(); expression.Interpret(context); }
static public void Run() { Console.WriteLine("------------Interpreter------------"); Context context = new Context(); var expression = new NonterminalExpression(); expression.Interpret(context); }
public UseCase() { Context context = new Context(); AbstractExpression expression = new NonterminalExpression(); context.Vocabulary = 'a'; context.Source = "aba"; expression.Interpret(context); }
/// <summary> /// interpreter pattern /// </summary> private static void InterpreterRun() { ContextI cont = new ContextI(); cont.SetVariable("x", 33); cont.SetVariable("y", 133); AbstractExpression exp = new NonterminalExpression(new TerminalExpression("x"), new TerminalExpression("y")); int res = (int)exp.Interpret(cont); Console.WriteLine(res); }
/// <summary> /// Sets up a test expression rule of "big" and "scary" and "pink". /// </summary> public InterpreterTest() { var term1 = new TerminalExpression("big"); var term2 = new TerminalExpression("scary"); var term3 = new TerminalExpression("pink"); // Non-Terminal expression of "big" AND "scary" var nonTerm1 = new NonterminalExpression(term1, term2); // Non-Terminal expression of ("big" AND "scary") AND "pink" _testExpression = new NonterminalExpression(nonTerm1, term3); }
static void Main(string[] args) { // Abstract factory IFactory concreteFactory = new WindowsFactory(); var obj1 = concreteFactory.CreateCloneable(); var obj2 = concreteFactory.CreateComparable(); // Builder IBuilder builder = new Builder1(); var director = new Director(builder); var product = director.Construct <IProduct>(); // Factory method Application app = new DrawingApplication(); Document document = app.CreateDocument(); // Prototype Prototype prototype = new ConcretePrototype1(); Prototype newObject = prototype.Clone(); // Command Receiver receiver = new Receiver(); Command command = new ConcreteCommand(receiver); Invoker invoker = new Invoker(); invoker.SetCommand(command); invoker.ExecuteCommand(); // Interpreter var context = new Context(); AbstrcatExpression experssion1 = new NonterminalExpression(); AbstrcatExpression expression2 = new TerminalExpression(); experssion1.Interpret(context); expression2.Interpret(context); // Mediator ConcreteMediator m = new ConcreteMediator(); ConcreteColleague1 c1 = new ConcreteColleague1(m); ConcreteColleague2 c2 = new ConcreteColleague2(m); m.Colleague1 = c1; m.Colleague2 = c2; c1.Send("How are you?"); c2.Send("Fine, thanks"); // Memoto Originator o = new Originator(); o.State = "On"; // Store internal state Caretaker c = new Caretaker(); c.Memento = o.CreateMemento(); // Continue changing originator o.State = "Off"; // Restore saved state o.SetMemento(c.Memento); // Observer ConcreteSubject s = new ConcreteSubject(); s.Attach(new ConcreteObserver(s, "X")); s.Attach(new ConcreteObserver(s, "Y")); s.Attach(new ConcreteObserver(s, "Z")); // Change subject and notify observers s.SubjectState = "ABC"; s.Notify(); }