public override BrainfuckToken GetNext(BrainfuckMemoryTape memoryTape) { if (memoryTape.Current == 0) { return(NextIndexToken); } return(LeftBracketToken); }
public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream) { memoryTape.Decrement(); }
public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream) { var c = Console.Read(); memoryTape.Current = (int)c; }
public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream) { }
public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream) { memoryTape.RightShift(); }
static void Main(string[] args) { var argsParser = new ArgsParser <Options>(); IArgsData <Options> options; try { options = argsParser.Parse(args); } catch (AnalysisException ex) { Console.WriteLine(ex.Message); return; } if (options.Option.Help) { throw new NotImplementedException(); } if (options.Has(x => x.Code) && options.Has(x => x.Source)) { throw new NotImplementedException(); } string src; var parser = new BrainfuckParser(); IEnumerable <BrainfuckToken> tokens; if (options.Has(x => x.Code)) { src = options.Option.Code; using (var sr = new StringReader(src)) { tokens = parser.Parse(sr); } } else if (options.Has(x => x.Source)) { using (var fs = new FileStream(options.Option.Source, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var sr = new StreamReader(fs)) { tokens = parser.Parse(sr); } } else { throw new NotImplementedException(); } var memoryTape = new BrainfuckMemoryTape(); var stream = new BrainfuckStream(); var steps = BrainfuckSteps.Create(tokens, memoryTape, stream); steps.Run(); }
public virtual BrainfuckToken GetNext(BrainfuckMemoryTape memoryTape) => NextIndexToken;
public abstract void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream);
public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream) { stream.Write((char)memoryTape.Current); }