private void DoElse(List <Token> tokenList)
        {
            Assert.Error(m_ifElseChainStack.Count > 0, Message.
                         Else_directive_without_preceeding_if____ifdef____or_ifndef_directive);
            Assert.Error(tokenList.Count == 2, TokenListToString(tokenList),
                         Message.Invalid_preprocessor_directive);

            IfElseChain ifElseChain = m_ifElseChainStack.Pop();

            Assert.Error(!ifElseChain.ElseStatus,
                         Message.Else_directive_after_else_directive);

            bool formerStatus = ifElseChain.FormerStatus;

            m_ifElseChainStack.Push(new IfElseChain(!formerStatus,
                                                    !formerStatus, true));
        }
Example #2
0
        private void DoElse(List <Token> tokenList)
        {
            Error.Check(m_ifElseChainStack.Count > 0, Message.
                        Else_directive_without_preceeding_if____ifdef____or_ifndef_directive);
            Error.Check(tokenList[2].Id == CCompiler_Pre.Tokens.END_OF_LINE,
                        TokenListToString(tokenList),
                        Message.Invalid_preprocessor_directive);

            IfElseChain ifElseChain = m_ifElseChainStack.Pop();

            Error.Check(!ifElseChain.ElseStatus,
                        Message.Else_directive_after_else_directive);

            bool formerStatus = ifElseChain.FormerStatus;

            m_ifElseChainStack.Push(new IfElseChain(!formerStatus,
                                                    !formerStatus, true));
        }
Example #3
0
        private void DoElseIf(List <Token> tokenList)
        {
            Error.Check(m_ifElseChainStack.Count > 0, Message.
                        Elif_directive_without_preceeding_if____ifdef____or_ifndef_directive);
            IfElseChain ifElseChain = m_ifElseChainStack.Pop();

            Error.Check(!ifElseChain.ElseStatus,
                        Message.Elif_directive_following_else_directive);

            if (ifElseChain.FormerStatus)
            {
                m_ifElseChainStack.Push(new IfElseChain(true, false, false));
            }
            else
            {
                bool result =
                    ParseExpression(TokenListToString
                                        (tokenList.GetRange(2, tokenList.Count - 2)));
                m_ifElseChainStack.Push(new IfElseChain(result, result, false));
            }
        }