예제 #1
0
        /// <summary>
        /// Ignora todos os símbolos vazios consecutivos.
        /// </summary>
        /// <param name="symbolReader">O leito de símbolos.</param>
        private void IgnoreVoids(ISymbolReader <string, string> symbolReader)
        {
            ISymbol <string, string> symbol = symbolReader.Peek();

            while (voids.Contains(symbol.SymbolType))
            {
                symbolReader.Get();
                symbol = symbolReader.Peek();
            }
        }
예제 #2
0
        private void IgnoreVoids(ISymbolReader <string, string> reader)
        {
            var readed = reader.Peek();

            while (readed.SymbolType == "blancks" || readed.SymbolType == "carriage_return" || readed.SymbolType == "new_line")
            {
                reader.Get();
                readed = reader.Peek();
            }
        }
예제 #3
0
        /// <summary>
        /// Função de transição "enquanto" - estado 2.
        /// </summary>
        /// <param name="reader">O leitor de símbolos.</param>
        /// <returns>O próximo estado.</returns>
        private IState <string, string> WhileTransition(ISymbolReader <string, string> reader)
        {
            this.IgnoreVoids(reader);
            var readed             = reader.Peek();
            var topScopeDefinition = this.scopeDefinitionStack.Pop();

            if (readed.SymbolType == "eof")
            {
                this.currentResult.InterpreterMessageStatus = EMathematicsInterpreterStatus.WAITING;
                this.currentResult.InterpreterResultMessage = "Incomplete expression.";
                return(this.stateList[1]);
            }
            else if (readed.SymbolType == "left_brace")
            {
                reader.Get();
                topScopeDefinition.ExecuteInScope = topScopeDefinition.ConditionExpression.AssertCondition();
                topScopeDefinition.HasBraces      = true;
                if (topScopeDefinition.ExecuteInScope)
                {
                    topScopeDefinition.ScopeStartMemento = (reader as MementoSymbolReader <CharSymbolReader <string>, string, string>).SaveToMemento();
                    this.scopeDefinitionStack.Push(topScopeDefinition);
                }

                return(this.stateList[0]);
            }
            else if (readed.SymbolType == "semi_colon")
            {
                topScopeDefinition.ExecuteInScope = topScopeDefinition.ConditionExpression.AssertCondition();
                if (topScopeDefinition.ExecuteInScope)
                {
                    this.scopeDefinitionStack.Push(topScopeDefinition);
                    return(this.stateList[2]);
                }
                else
                {
                    return(this.stateList[0]);
                }
            }
            else
            {
                topScopeDefinition.ExecuteInScope = topScopeDefinition.ConditionExpression.AssertCondition();
                if (topScopeDefinition.ExecuteInScope)
                {
                    topScopeDefinition.ScopeStartMemento = (reader as MementoSymbolReader <CharSymbolReader <string>, string, string>).SaveToMemento();
                    this.scopeDefinitionStack.Push(topScopeDefinition);
                    return(this.stateList[0]);
                }
                else
                {
                    this.scopeDefinitionStack.Push(topScopeDefinition);
                    return(this.stateList[11]);
                }
            }
        }