コード例 #1
0
ファイル: ICUService.cs プロジェクト: bdqnghi/j2cstranslator
        /// <summary>
        /// <p>
        /// Return a snapshot of the visible IDs for this service. This set will not
        /// change as Factories are added or removed, but the supported ids will, so
        /// there is no guarantee that all and only the ids in the returned set are
        /// visible and supported by the service in subsequent calls.
        /// </p>
        /// <p>
        /// matchID is passed to createKey to create a key. If the key is not null,
        /// it is used to filter out ids that don't have the key as a fallback.
        /// </summary>
        ///
        public ILOG.J2CsMapping.Collections.ISet GetVisibleIDs(String matchID)
        {
            ILOG.J2CsMapping.Collections.ISet result = new ILOG.J2CsMapping.Collections.ListSet(GetVisibleIDMap().Keys);

            ICUService.Key fallbackKey = CreateKey(matchID);

            if (fallbackKey != null)
            {
                ILOG.J2CsMapping.Collections.ISet temp = new HashedSet(result.Count);
                IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(result.GetEnumerator());
                while (iter.HasNext())
                {
                    String id_0 = (String)iter.Next();
                    if (fallbackKey.IsFallbackOf(id_0))
                    {
                        ILOG.J2CsMapping.Collections.Generics.Collections.Add(temp, id_0);
                    }
                }
                result = temp;
            }
            return(result);
        }
コード例 #2
0
ファイル: BNF.cs プロジェクト: bdqnghi/j2cstranslator
        public BNF Complete()
        {
            // check that the rules match the variables, except for $root in rules
            ILOG.J2CsMapping.Collections.ISet ruleSet = new ILOG.J2CsMapping.Collections.ListSet(map.Keys);
            // add also
            ILOG.J2CsMapping.Collections.Generics.Collections.Add(variables, "$root");
            ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(t.GetLookedUpItems(), variables);
            if (!ruleSet.Equals(variables))
            {
                String msg = ShowDiff(variables, ruleSet);
                if (msg.Length != 0)
                {
                    msg = "Error: Missing definitions for: " + msg;
                }
                String temp = ShowDiff(ruleSet, variables);
                if (temp.Length != 0)
                {
                    temp = "Warning: Defined but not used: " + temp;
                }
                if (msg.Length == 0)
                {
                    msg = temp;
                }
                else if (temp.Length != 0)
                {
                    msg = msg + "; " + temp;
                }
                Error(msg);
            }

            if (!ruleSet.Equals(variables))
            {
                String msg_0 = ShowDiff(variables, ruleSet);
                if (msg_0.Length != 0)
                {
                    msg_0 = "Missing definitions for: " + msg_0;
                }
                String temp_1 = ShowDiff(ruleSet, variables);
                if (temp_1.Length != 0)
                {
                    temp_1 = "Defined but not used: " + temp_1;
                }
                if (msg_0.Length == 0)
                {
                    msg_0 = temp_1;
                }
                else if (temp_1.Length != 0)
                {
                    msg_0 = msg_0 + "; " + temp_1;
                }
                Error(msg_0);
            }

            // replace variables by definitions
            IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(ruleSet.GetEnumerator());

            while (it.HasNext())
            {
                String    key        = (String)it.Next();
                Pick      expression = (Pick)ILOG.J2CsMapping.Collections.Collections.Get(map, key);
                IIterator it2        = new ILOG.J2CsMapping.Collections.IteratorAdapter(ruleSet.GetEnumerator());
                if (false && key.Equals("$crlf"))
                {
                    System.Console.Out.WriteLine("debug");
                }
                while (it2.HasNext())
                {
                    Object key2 = it2.Next();
                    if (key.Equals(key2))
                    {
                        continue;
                    }
                    Pick expression2 = (Pick)ILOG.J2CsMapping.Collections.Collections.Get(map, key2);
                    expression2.Replace(key, expression);
                }
            }
            pick   = (Pick)ILOG.J2CsMapping.Collections.Collections.Get(map, "$root");
            target = IBM.ICU.Charset.Pick.Target.Make(pick, random, quoter);
            // TODO remove temp collections
            return(this);
        }