Example #1
0
 public State(Interpreter ii, Source source, ChannelStack output)
 {
     _finished = false;
     _preBlueprints = new Stack<Blueprint>();
     _postBlueprints = new Stack<Blueprint>();
     _interpreter = ii;
     _output = output;
     _reader = new SourceReader(source);
     _sharesOutput = (output == _interpreter._output && _interpreter.PrevState != null) || (_interpreter._stateStack.Any() && output == _interpreter._stateStack.Peek().Output);
 }
Example #2
0
 private State(Interpreter ii, Source derivedSource, IEnumerable<Token<TokenType>> tokens,
     ChannelStack output)
 {
     _finished = false;
     _preBlueprints = new Stack<Blueprint>();
     _postBlueprints = new Stack<Blueprint>();
     _interpreter = ii;
     _output = output;
     _reader = new SourceReader(new Source(derivedSource.Name, derivedSource.Type, tokens, derivedSource.Code));
     _sharesOutput = (output == _interpreter._output && _interpreter.PrevState != null) || (_interpreter._stateStack.Any() && output == _interpreter._stateStack.Peek().Output);
 }
Example #3
0
 public static State CreateDerivedDistinct(Source derivedSource, IEnumerable<Token<TokenType>> tokens,
     Interpreter interpreter, ChannelStack output = null)
 {
     return new State(interpreter, derivedSource, tokens, output ?? new ChannelStack(interpreter.CharLimit));
 }
Example #4
0
 public Interpreter(Engine engine, Source input, RNG rng, int limitChars = 0)
 {
     _mainSource = input;
     _rng = rng;
     _engine = engine;
     _charLimit = new Limit<int>(0, limitChars, (a, b) => a + b, (a, b) => b == 0 || a <= b);
     _output = new ChannelStack(_charLimit);
     _mainState = State.Create(input, this);
 }