public TrueAndClassPartReturn IsMatch(string s)
        {
            Node   current = Head;
            string v       = null;
            string c       = null;

            while (current != null)
            {
                v = current.ValuePart;

                if (v == s)
                {
                    c = current.ClassPart;

                    TrueAndClassPartReturn abc = new TrueAndClassPartReturn
                    {
                        cp      = c,
                        isAvail = true
                    };
                    return(abc);

                    //get classPart content fron node and return variable of classPart
                    //get valuepart content from node and reurn variable of valuePart
                }
                current = current.NextValueAdd;
            }
            TrueAndClassPartReturn def = new TrueAndClassPartReturn
            {
                cp      = "inValid",
                isAvail = false
            };

            return(def);
        }
Пример #2
0
        private bool MatchBreakWord(string breakTempWord)
        {
            TrueAndClassPartReturn isKeyword = keywordList.l.IsMatch(breakTempWord);

            if (isKeyword.isAvail == true)
            {
                CLassPart = isKeyword.cp;

                return(true);
            }

            TrueAndClassPartReturn isPunct = punctList.PunctList.IsMatch(breakTempWord);

            if (isPunct.isAvail == true)
            {
                CLassPart = isPunct.cp;

                return(true);
            }

            TrueAndClassPartReturn isOperator = operatorList.OpList.IsMatch(breakTempWord);

            if (isOperator.isAvail == true)
            {
                CLassPart = isOperator.cp;

                return(true);
            }

            result_identifier = identifier.IsMatch(breakTempWord);
            result_int        = int_constant.IsMatch(breakTempWord);
            result_float      = float_constant.IsMatch(breakTempWord);
            result_char       = char_constant.IsMatch(breakTempWord);
            result_string     = string_constant.IsMatch(breakTempWord);

            if (result_identifier == true)
            {
                CLassPart = "ID";
                return(true);
            }
            if (result_int == true)
            {
                CLassPart = "INT_CONST";
                return(true);
            }
            if (result_float == true)
            {
                CLassPart = "FLOAT_CONST";
                return(true);
            }
            if (result_char == true)
            {
                CLassPart = "CHAR_CONST";
                return(true);
            }
            if (result_string == true)
            {
                CLassPart = "STRING_CONST";
                return(true);
            }

            else
            {
                return(false);
            }
        }