Пример #1
0
    public LexVariable Clone()
    {
        LexVariable copy = MemberwiseClone() as LexVariable;

        copy.type = type.Clone();
        return(copy);
    }
Пример #2
0
    LexVariable ParseVariable(string data, ProtectLevel protectLevel, int begin, int end)
    {
        LexVariable res = new LexVariable()
        {
            begin = begin,
            end = end,
            data = data
        };

        res.type = new LexVariableType();

        res.definition = data;

        int caret = 0;
        string typeWord = ReadWord(data, ref caret, " \n\r(){}[]");
        string typeDefinition = typeWord;

        if (typeWord == "static")
        {
            typeWord = ReadWord(data, ref caret, " \n\r(){}[]");
            typeDefinition += " " + typeWord;
            res.isStatic = true;
        }

        if (typeWord == "const")
        {
            typeWord = ReadWord(data, ref caret, " \n\r(){}[]");
            res.type.isContstant = true;

            typeDefinition += " " + typeWord;
        }

        if (typeWord.Last() == '&')
            res.type.type = LexVariableType.Type.Reference;

        if (typeWord.Last() == '*')
            res.type.type = LexVariableType.Type.Pointer;

        res.type.name = typeWord;
        res.type.definition = typeDefinition;

        res.protectLevel = protectLevel;

        if (GetNextSymbol(data, caret, " \n\r\t") == '(')
        {
            string braces = ReadBraces(data, ref caret).Trim(' ', '\r', '\t', '\t', '(', ')');
            string nexBraces = ReadBraces(data, ref caret).Trim(' ', '\r', '\t', '\t', '(', ')');

            int tmpCaret = 0;
            string bracesFirst = ReadWord(braces, ref tmpCaret);
            tmpCaret += 3;
            res.name = braces.Substring(tmpCaret);

            res.type.name = res.type.name + " (" + bracesFirst + "*)(" + nexBraces + ")";
            res.type.definition = res.type.name;
        }
        else
        {
            res.name = ReadWord(data, ref caret, " \n\r(){}[]");
        }

        return res;
    }
Пример #3
0
    LexVariable ParseVariable(string data, ProtectLevel protectLevel, int begin, int end)
    {
        LexVariable res = new LexVariable()
        {
            begin = begin,
            end   = end,
            data  = data
        };

        res.type = new LexVariableType();

        res.definition = data;

        int    caret          = 0;
        string typeWord       = ReadWord(data, ref caret, " \n\r(){}[]");
        string typeDefinition = typeWord;

        if (typeWord == "static")
        {
            typeWord        = ReadWord(data, ref caret, " \n\r(){}[]");
            typeDefinition += " " + typeWord;
            res.isStatic    = true;
        }

        if (typeWord == "const")
        {
            typeWord             = ReadWord(data, ref caret, " \n\r(){}[]");
            res.type.isContstant = true;

            typeDefinition += " " + typeWord;
        }

        if (typeWord.Last() == '&')
        {
            res.type.type = LexVariableType.Type.Reference;
        }

        if (typeWord.Last() == '*')
        {
            res.type.type = LexVariableType.Type.Pointer;
        }

        res.type.name       = typeWord;
        res.type.definition = typeDefinition;

        res.protectLevel = protectLevel;

        if (GetNextSymbol(data, caret, " \n\r\t") == '(')
        {
            string braces    = ReadBraces(data, ref caret).Trim(' ', '\r', '\t', '\t', '(', ')');
            string nexBraces = ReadBraces(data, ref caret).Trim(' ', '\r', '\t', '\t', '(', ')');

            int    tmpCaret    = 0;
            string bracesFirst = ReadWord(braces, ref tmpCaret);
            tmpCaret += 3;
            res.name  = braces.Substring(tmpCaret);

            res.type.name       = res.type.name + " (" + bracesFirst + "*)(" + nexBraces + ")";
            res.type.definition = res.type.name;
        }
        else
        {
            res.name = ReadWord(data, ref caret, " \n\r(){}[]");
        }

        return(res);
    }