Example #1
0
        private void DoGrouping()
        {
            ReportEvent(TEvent.EEventGroupingStarted, SymToken.NullToken());

            bool lexerFinished = false;

            do
            {
                // Count how many tokens we have...
                lock (this)
                {
                    iMastermind.PerformGrouping();
                    lexerFinished = iLexerFinished;
                }

                // Wait until there are more items to process
                if (lexerFinished == false)
                {
                    ReportEvent(TEvent.EEventGroupingPaused, SymToken.NullToken());
                    iSemaphore.Wait();
                    ReportEvent(TEvent.EEventGroupingStarted, SymToken.NullToken());
                }
            }while (lexerFinished == false);

            ReportEvent(TEvent.EEventGroupingComplete, SymToken.NullToken());
        }
Example #2
0
        private void DoLexing()
        {
            ReportEvent(TEvent.EEventLexingStarted, SymToken.NullToken());

            while (!Stream.EOF)
            {
                char character = Stream.ReadChar();
                ProcessCharacter(character);
            }

            ReportEvent(TEvent.EEventLexingComplete, SymToken.NullToken());
        }
        public virtual void RegisterFunctionParserTokens()
        {
            // Base class registration
            RegisterBalancerTokens();

            // These are the important tokens relating to function arguments
            SymToken bracketTokenOpening         = new SymToken("(", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);
            SymToken bracketTokenClosing         = new SymToken(")", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);
            SymToken squareBracketTokenOpening   = new SymToken("[", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);
            SymToken squareBracketTokenClosing   = new SymToken("]", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);
            SymToken templateBracketTokenOpening = new SymToken("<", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);
            SymToken templateBracketTokenClosing = new SymToken(">", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);

            // We want to track levels for square brackets and template arguments in order to ensure we balance correctly.
            // We don't want to remove any redundancy here as these may have special meaning.
            RegisterOpeningToken(squareBracketTokenOpening, squareBracketTokenClosing, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone);
            RegisterClosingToken(squareBracketTokenClosing, squareBracketTokenOpening, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone);
            RegisterOpeningToken(templateBracketTokenOpening, templateBracketTokenClosing, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone);
            RegisterClosingToken(templateBracketTokenClosing, templateBracketTokenOpening, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone);

            // Define our argument separation token(s).
            TAssociatedBehaviour flags = TAssociatedBehaviour.EBehaviourNone;

            flags |= TAssociatedBehaviour.EBehaviourCreateSubTree;
            flags |= TAssociatedBehaviour.EBehaviourRemoveReduntantBracketing;
            //
            SymToken commaDelimiterToken = new SymToken(",", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified);

            RegisterArgumentSeparatorToken(commaDelimiterToken, new SymTokenBalancerMatchCriteria(SymToken.NullToken(), false, true, TLevelExpectations.ELevelExpectationsAtLevel, 1, flags));
            RegisterArgumentSeparatorToken(commaDelimiterToken, new SymTokenBalancerMatchCriteria(SymToken.NullToken(), true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 1, TAssociatedBehaviour.EBehaviourNone));
        }
Example #4
0
 public SymParserWorkerContext(SymParserDocumentContext aDocumentContext, SymParserWorker aParent)
     : this(aDocumentContext, aParent, SymToken.NullToken())
 {
 }