示例#1
0
        private TypeDesc SimpleExpression(HashSet <SymbolEnum> followers)
        {
            bool hasPrefixSign = false;

            if (CurrentSymbol == SymbolEnum.Minus || CurrentSymbol == SymbolEnum.Plus)
            {
                hasPrefixSign = true;
                NextSymbol();
            }

            var firstOperandType = NeutralizerDecoratorWithReturn(Term, Starters.Term, Followers.Term, 6, followers);

            if (hasPrefixSign)
            {
                if (!TypeValidator.SupportsSign(firstOperandType))
                {
                    Error(211);
                }
            }

            while (CurrentSymbol == SymbolEnum.Plus ||
                   CurrentSymbol == SymbolEnum.Minus ||
                   CurrentSymbol == SymbolEnum.OrSy)
            {
                var operation = CurrentSymbol;
                NextSymbol();
                var secondOperandType = NeutralizerDecoratorWithReturn(Term, Starters.Term, Followers.Term, 6, followers);
                var expressionType    = TypeValidator.GetTypeAfterAddition(firstOperandType, secondOperandType, operation);
                if (expressionType == null)
                {
                    Error(328);
                }

                return(expressionType);
            }

            return(firstOperandType);
        }