public void Run(SyneryParser.ObserveBlockContext context) { List <IHandleBlockData> listOfHandleBlockData = new List <IHandleBlockData>(); foreach (var handleBlockContext in context.handleBlock()) { IHandleBlockData data = Controller.Interpret <SyneryParser.HandleBlockContext, IHandleBlockData>(handleBlockContext); listOfHandleBlockData.Add(data); } IObserveScope scope = new ObserveScope(Memory.CurrentScope, listOfHandleBlockData); Controller.Interpret <SyneryParser.BlockContext, INestedScope, INestedScope>(context.block(), scope); }
public static void InterpretHandleBlock(IInterpretationController controller, IHandleBlockData data, IValue eventRecord) { SyneryParser.BlockContext blockContext = data.Context as SyneryParser.BlockContext; if (blockContext != null) { // create a new block scope and set the parent scope of the OBSERVE-block as parent INestedScope blockScope = new BlockScope(data.ParentScope); // add the event record as local variable blockScope.DeclareVariable(data.ParameterName, eventRecord.Type); blockScope.AssignVariable(data.ParameterName, eventRecord.Value); // start interpreting the given HANDLE-block controller.Interpret <SyneryParser.BlockContext, INestedScope, INestedScope>(blockContext, blockScope); } else { throw new SyneryException("Can not interpret handle block because the given context is not a BlockContext"); } }