Example #1
0
        public bool put(string strId, string strToken, string strValue)
        {
            IDENTIFIER idTemp = (IDENTIFIER)hashSymbolTable[strId];

            if (idTemp == null || idTemp.Scope == "NULL" && idTemp.Lexeme == "NULL")
            {
                IndexOutOfRangeException e = new IndexOutOfRangeException();

                throw e;
            }

            if (strToken != KEEP)
            {
                idTemp.Token = strToken;
                idTemp.CheckForArr();
            }

            if (strValue != KEEP)
            {
                idTemp.Value = strValue;
                idTemp.CheckForArr();
            }

            hashSymbolTable[strId] = idTemp;

            return(true);
        }
Example #2
0
        /* This method will let you change the token, or array value value of the desired table entry.
         * if you do not wish to change the the token or the value for the string of token or
         * value use the string "KEEP".
         */

        /* for variable destripts see other put method comments
         * Variable             Type                Purpose
         * intValue             int                 stores index to be change in array of desired identifier
         */
        public bool put(string strId, string strToken, int intValue, string strValue)
        {
            IDENTIFIER idTemp = (IDENTIFIER)hashSymbolTable[strId];

            if (idTemp == null || idTemp.Scope == "NULL" && idTemp.Lexeme == "NULL")
            {
                IndexOutOfRangeException e = new IndexOutOfRangeException();

                throw e;
            }

            if (strToken != KEEP)
            {
                idTemp.Token = strToken;
                idTemp.CheckForArr();
            }

            if (strValue != KEEP)
            {
                string[] strArray  = new string[100];
                char[]   charArray = new char[1];

                charArray[0] = ' ';

                strArray = idTemp.Value.Split(charArray);

                try
                {
                    strArray[intValue] = strValue;
                }
                catch (IndexOutOfRangeException)
                {
                    return(false);
                }

                idTemp.Value = "";

                for (int intI = 0; intI < strArray.Length; intI++)
                {
                    idTemp.Value += strArray[intI] + " ";
                }

                //idTemp.Value = idTemp.Value.Substring(1, idTemp.Value.Length - 1);
            }

            hashSymbolTable[strId] = idTemp;

            return(true);
        }