예제 #1
0
        protected internal virtual void resolveRule(JSGFRule r)
        {
            if (r is JSGFRuleToken)
            {
                return;
            }
            if (r is JSGFRuleAlternatives)
            {
                Iterator iterator = ((JSGFRuleAlternatives)r).getRules().iterator();
                while (iterator.hasNext())
                {
                    JSGFRule jsgfrule = (JSGFRule)iterator.next();
                    this.resolveRule(jsgfrule);
                }
                return;
            }
            if (r is JSGFRuleSequence)
            {
                Iterator iterator = ((JSGFRuleSequence)r).getRules().iterator();
                while (iterator.hasNext())
                {
                    JSGFRule jsgfrule = (JSGFRule)iterator.next();
                    this.resolveRule(jsgfrule);
                }
                return;
            }
            if (r is JSGFRuleCount)
            {
                this.resolveRule(((JSGFRuleCount)r).getRule());
                return;
            }
            if (r is JSGFRuleTag)
            {
                JSGFRuleTag jsgfruleTag = (JSGFRuleTag)r;
                JSGFRule    jsgfrule    = jsgfruleTag.getRule();
                string      text        = jsgfrule.toString();
                object      obj         = (Collection)this.__ruleTags.get(text);
                if ((Collection)obj == null)
                {
                    obj = new HashSet();
                    this.__ruleTags.put(text, (HashSet)obj);
                }
                object     obj2 = obj;
                object     tag  = jsgfruleTag.getTag();
                Collection collection;
                if (obj2 != null)
                {
                    if ((collection = (obj2 as Collection)) == null)
                    {
                        throw new IncompatibleClassChangeError();
                    }
                }
                else
                {
                    collection = null;
                }
                collection.add(tag);
                this.resolveRule(jsgfrule);
                return;
            }
            if (!(r is JSGFRuleName))
            {
                string message = "Unknown rule type";

                throw new JSGFGrammarException(message);
            }
            JSGFRuleName jsgfruleName  = (JSGFRuleName)r;
            JSGFRuleName jsgfruleName2 = this.resolve(jsgfruleName);

            if (jsgfruleName2 == null)
            {
                string message2 = new StringBuilder().append("Unresolvable rulename in grammar ").append(this.name).append(": ").append(jsgfruleName).toString();

                throw new JSGFGrammarException(message2);
            }
            jsgfruleName.resolvedRuleName = jsgfruleName2.getRuleName();
            jsgfruleName.setRuleName(jsgfruleName2.getRuleName());
        }