Ejemplo n.º 1
0
        private GPCSymbolItem buildSymbolItem(GPCSymbolItem rCurSymbol, int begin, ref int end)
        {
            if (originData[begin] == '{')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ObjStart, Value = "{"
                });
            }
            else if (originData[begin] == '}')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ObjEnd, Value = "}"
                });
            }
            else if (originData[begin] == '(')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ArgsStart, Value = "("
                });
            }
            else if (originData[begin] == ')')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ArgsEnd, Value = ")"
                });
            }
            else if (originData[begin] == ',')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ArgsSplit, Value = ","
                });
            }
            else if (originData[begin] == ';')
            {
                end = begin + 1;
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.ElementSplit, Value = ";"
                });
            }

            string tempWord = "";

            if (!string.IsNullOrEmpty(tempWord = LexicalAnalysis.IsNotKeywordIdentifer(originData, begin, ref end)))
            {
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.Identifer, Value = tempWord
                });
            }
            if (!string.IsNullOrEmpty(tempWord = LexicalAnalysis.isString(originData, begin, ref end)))
            {
                tempWord = tempWord.Substring(1, tempWord.Length - 2);
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.Arg, Value = tempWord
                });
            }
            if (!string.IsNullOrEmpty(tempWord = LexicalAnalysis.isKeyword(originData, begin, ref end)))
            {
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.Arg, Value = tempWord
                });
            }
            if (!string.IsNullOrEmpty(tempWord = LexicalAnalysis.isDigit(originData, begin, ref end)))
            {
                return(new GPCSymbolItem()
                {
                    Type = GPCSymbolType.Arg, Value = tempWord
                });
            }
            return(null);
        }