Пример #1
0
        public override BrainfuckToken GetNext(BrainfuckMemoryTape memoryTape)
        {
            if (memoryTape.Current == 0)
            {
                return(NextIndexToken);
            }

            return(LeftBracketToken);
        }
Пример #2
0
 public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream)
 {
     memoryTape.Decrement();
 }
Пример #3
0
        public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream)
        {
            var c = Console.Read();

            memoryTape.Current = (int)c;
        }
Пример #4
0
 public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream)
 {
 }
Пример #5
0
 public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream)
 {
     memoryTape.RightShift();
 }
Пример #6
0
        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();
        }
Пример #7
0
 public virtual BrainfuckToken GetNext(BrainfuckMemoryTape memoryTape) => NextIndexToken;
Пример #8
0
 public abstract void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream);
Пример #9
0
 public override void Operate(BrainfuckMemoryTape memoryTape, IBrainfuckStream stream)
 {
     stream.Write((char)memoryTape.Current);
 }