public override void Execute(EpsInterpreter interpreter) { var operandStack = interpreter.OperandStack; var stringVal = operandStack.PopStringValue(); byte[] bytes = System.Text.Encoding.ASCII.GetBytes(stringVal); var memoryStream = new MemoryStream(bytes); var scriptReader = new StreamReader(memoryStream); var fileReader = new EpsStreamReader(scriptReader); var parser = new Parser(fileReader); var operand = parser.GetNextOperand(); if (operand != null) { var post = scriptReader.ReadToEnd(); var postOp = new StringOperand(post); operandStack.Push(postOp); operandStack.Push(operand); var boolOp = new BooleanOperand(true); operandStack.Push(boolOp); } else { var boolOp = new BooleanOperand(false); operandStack.Push(boolOp); } scriptReader.Dispose(); memoryStream.Dispose(); }
/// <summary> /// Read over until the given end is found /// </summary> private void SkipUntil(EpsStreamReader reader, string end) { string line = reader.ReadLine(); while (!line.StartsWith(end)) { line = reader.ReadLine(); } }
/// <summary> /// Run the interpreter /// </summary> public GraphicGroup Run(StreamReader scriptStream, int postscriptVersion) { PrepareStandardDictionaries(postscriptVersion); AllCommands.Register(this); InitGraphic(); FileReader = new EpsStreamReader(scriptStream); parser = new Parser(FileReader); Run(); return(ReturnGraphicGroup); }