示例#1
0
        private void LexerTokenHandler(SymLexer aLexer, SymLexer.TEvent aEvent, SymToken aToken)
        {
            if (aEvent == SymLexer.TEvent.EEventLexingToken)
            {
                // Store the token
                lock (this)
                {
                    iMastermind.EnqueueLexedToken(aToken);
                }

                // and signal the worker thread if it is waiting...
                if (iSemaphore.Count == 0)
                {
                    iSemaphore.Signal();
                }
            }
            else if (aEvent == SymLexer.TEvent.EEventLexingComplete)
            {
                lock (this)
                {
                    iLexerFinished = true;
                }

                // and signal the worker thread if it is waiting...
                if (iSemaphore.Count == 0)
                {
                    iSemaphore.Signal();
                }
            }
        }
示例#2
0
        public SymGrouper(SymLexer aLexer)
        {
            // The mastermind implements all the logic for grouping token runs into
            // more sophisticated/logical token groupings.
            iMastermind.MastermindObservers += new SymGrouperMastermind.MastermindObserver(MastermindObserver);

            // Observe the lexer for tokens
            aLexer.LexerObservers += new SymLexer.LexerObserver(LexerTokenHandler);

            // Prepare worker thread
            ThreadStart threadStart = new ThreadStart(DoGrouping);

            iWorkerThread              = new Thread(threadStart);
            iWorkerThread.Name         = "SymGrouperWorkerThread";
            iWorkerThread.IsBackground = true;
            iWorkerThread.Start();
        }