コード例 #1
0
        private Token PopToken()
        {
            StackToken _StackToken = _tokens.Pop();

            _currentMode = _StackToken._LexMode;

            return(_StackToken._Token);
        }
コード例 #2
0
        private Token DequeueToken()
        {
            StackToken _StackToken = _que.Dequeue();

            _currentMode = _StackToken._LexMode;

            return(_StackToken._Token);
        }
コード例 #3
0
        private void QueueToken(Token _token, LexMode _LexMode)
        {
            StackToken _StackToken = new StackToken();

            _StackToken._Token   = _token;
            _StackToken._LexMode = _LexMode;

            _que.Enqueue(_StackToken);
        }
コード例 #4
0
        private void PushToken(Token _token, LexMode _LexMode)
        {
            StackToken _StackToken = new StackToken();

            _StackToken._Token   = _token;
            _StackToken._LexMode = _LexMode;

            _tokens.Push(_StackToken);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-Us");

            var sw = new Stopwatch();

            sw.Start();
            string file;

            using (var s = File.OpenRead("./input.eps"))
                using (var sr = new StreamReader(s)) {
                    file = sr.ReadToEnd();
                    sw.Stop();
                }
            Ext.WriteLinePurple($"reading the file took {sw.ElapsedMilliseconds}ms/{sw.ElapsedTicks}t");

            var tokenizer = new Tokenizer(file.ToCharArray());

            var _ = new StackToken();

            sw.Restart();
            Token t;

            while ((t = tokenizer.GetNextToken()).Type != TokenType.EOF)
            {
                Ext.WritePurple($"[{sw.ElapsedMilliseconds:D4}ms] ");

                if (t.Type == TokenType.UNKNOWN)
                {
                    Ext.WriteLineRed(t.ToString());
                }
                else
                {
                    Console.WriteLine(t.ToString());
                }

                Machine.ProcessToken(in t);
            }

            sw.Restart();
            SVGBuilder.BuildSVG();
            sw.Stop();
            Ext.WriteLinePurple($"building the svg took {sw.ElapsedMilliseconds}ms/{sw.ElapsedTicks}t");
        }