Ejemplo n.º 1
0
    void TryParseBlock(LexSection section, string block, int blockBegin, ref int caret, ref ProtectLevel protectionLevel)
    {
        int locCaret = 0;
        bool isFunction = false;

        string firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (firstWord.Length == 0)
        {
            LexUnknown unkn = new LexUnknown()
            {
                begin = blockBegin,
                end = caret,
                data = block,
                protectLevel = protectionLevel,
                value = block
            };

            section.unknownBlocks.Add(unkn);
            return;
        }

        if (firstWord == "virtual")
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (firstWord == "static")
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (firstWord == "typename")
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (firstWord == "inline")
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (GetNextSymbol(block, locCaret, " \n\r\t") == '(')
        {
            string braces = ReadBraces(block, ref locCaret).Trim(' ', '\n', '\t', '\r', '(', ')');
            int tmpCaret = 0;
            string word = ReadWord(braces, ref tmpCaret);

            isFunction = GetNextSymbol(braces, tmpCaret, " \n\r\t") != ':';

            if (!isFunction && braces.StartsWith("std"))
                isFunction = true;
        }
        else
        {
            if (firstWord == "const")
                ReadWord(block, ref locCaret, " \n\r(){}[]");

            string thirdWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

            if (thirdWord == "operator")
                thirdWord = ReadWord(block, ref locCaret, " \n\r(){}");

            if (GetNextSymbol(block, locCaret, " \n\r\t") == '(')
                isFunction = true;
        }

        if (isFunction)
            section.functions.Add(ParseFunction(block, protectionLevel, blockBegin, caret));
        else
            section.variables.Add(ParseVariable(block, protectionLevel, blockBegin, caret));
    }
Ejemplo n.º 2
0
    void TryParseBlock(LexSection section, string block, int blockBegin, ref int caret, ref ProtectLevel protectionLevel)
    {
        int  locCaret   = 0;
        bool isFunction = false;

        string firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

        if (firstWord.Length == 0)
        {
            LexUnknown unkn = new LexUnknown()
            {
                begin        = blockBegin,
                end          = caret,
                data         = block,
                protectLevel = protectionLevel,
                value        = block
            };

            section.unknownBlocks.Add(unkn);
            return;
        }

        if (firstWord == "virtual")
        {
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");
        }

        if (firstWord == "static")
        {
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");
        }

        if (firstWord == "typename")
        {
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");
        }

        if (firstWord == "inline")
        {
            firstWord = ReadWord(block, ref locCaret, " \n\r(){}[]");
        }

        if (GetNextSymbol(block, locCaret, " \n\r\t") == '(')
        {
            string braces   = ReadBraces(block, ref locCaret).Trim(' ', '\n', '\t', '\r', '(', ')');
            int    tmpCaret = 0;
            string word     = ReadWord(braces, ref tmpCaret);

            isFunction = GetNextSymbol(braces, tmpCaret, " \n\r\t") != ':';

            if (!isFunction && braces.StartsWith("std"))
            {
                isFunction = true;
            }
        }
        else
        {
            if (firstWord == "const")
            {
                ReadWord(block, ref locCaret, " \n\r(){}[]");
            }

            string thirdWord = ReadWord(block, ref locCaret, " \n\r(){}[]");

            if (thirdWord == "operator")
            {
                thirdWord = ReadWord(block, ref locCaret, " \n\r(){}");
            }

            if (GetNextSymbol(block, locCaret, " \n\r\t") == '(')
            {
                isFunction = true;
            }
        }

        if (isFunction)
        {
            section.functions.Add(ParseFunction(block, protectionLevel, blockBegin, caret));
        }
        else
        {
            section.variables.Add(ParseVariable(block, protectionLevel, blockBegin, caret));
        }
    }