Esempio n. 1
0
        /** From a chunk of text holding the definitions of the attributes,
         *  pull them apart and create an Attribute for each one.  Add to
         *  the list of attributes for this scope.  Pass in the character
         *  that terminates a definition such as ',' or ';'.  For example,
         *
         *  scope symbols {
         *      int n;
         *      List names;
         *  }
         *
         *  would pass in definitions equal to the text in between {...} and
         *  separator=';'.  It results in two Attribute objects.
         */
        public virtual void AddAttributes(string definitions, int separator)
        {
            IList <string> attrs = new List <string>();

            CodeGenerator.GetListOfArgumentsFromAction(definitions, 0, -1, separator, attrs);
            foreach (string a in attrs)
            {
                Attribute attr = new Attribute(a);
                if (!isReturnScope && attr.InitValue != null)
                {
                    ErrorManager.GrammarError(ErrorManager.MSG_ARG_INIT_VALUES_ILLEGAL,
                                              grammar,
                                              derivedFromToken,
                                              attr.Name);
                    attr.InitValue = null; // wipe it out
                }
                for (int i = 0; i <= attributes.Count; i++)
                {
                    if (i < attributes.Count)
                    {
                        if (attributes[i].Name == attr.Name)
                        {
                            attributes[i] = attr;
                            break;
                        }
                    }
                    else
                    {
                        attributes.Add(attr);
                        // *must* break since the count changed
                        break;
                        //attributes.put( attr.Name, attr );
                    }
                }
            }
        }