internal RantTableLoadException(string origin, int line, int col, string messageType, params object[] messageArgs)
     : base($"{Txtres.GetString("src-line-col", origin, line, col)} {Txtres.GetString(messageType, messageArgs)}")
 {
     Line   = line;
     Column = col;
     Origin = origin;
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the RantDictionaryTable class with the specified name and term count.
        /// </summary>
        /// <param name="name">The name of the table.</param>
        /// <param name="termsPerEntry">The number of terms to store in each entry.</param>
        /// <param name="hidden">Collection of hidden classes.</param>
        public RantDictionaryTable(string name, int termsPerEntry, HashSet <string> hidden = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (termsPerEntry <= 0)
            {
                throw new ArgumentException(Txtres.GetString("err-bad-term-count"));
            }
            if (!Util.ValidateName(name))
            {
                throw new ArgumentException(Txtres.GetString("err-invalid-tablename", name));
            }
            if (hidden != null)
            {
                _hidden = hidden;
            }
            _cache        = new ClassCache();
            TermsPerEntry = termsPerEntry;
            Name          = name;

            CreateSyllableBuckets();
        }
Beispiel #3
0
        internal IEnumerator <RST> Run(Sandbox sb)
        {
            if (Name == null)
            {
                yield break;
            }
            if (sb.Engine.Dictionary == null)
            {
                sb.Print(Txtres.GetString("missing-table"));
                yield break;
            }

            var result = sb.Engine.Dictionary.Query(sb, this, sb.CarrierState);

            if (result == null)
            {
                sb.Print("[No Match]");
            }
            else
            {
                if (result.IsSplit)
                {
                    if (this.Complement == null)
                    {
                        sb.Print(result.LeftSide);
                        sb.Print(sb.Format.WritingSystem.Space);
                        sb.Print(result.RightSide);
                    }
                    else if (result.ValueSplitIndex == 0)                     // Pushes complement to the left of the query result
                    {
                        long l = sb.SizeLimit.Value;
                        yield return(this.Complement);

                        if (sb.SizeLimit.Value > l)
                        {
                            sb.Print(sb.Format.WritingSystem.Space);
                        }
                        sb.Print(result.Value);
                    }
                    else if (result.ValueSplitIndex == result.Value.Length)
                    {
                        sb.Print(result.Value);
                        long l = sb.SizeLimit.Value;
                        var  t = sb.Output.InsertAnonymousTarget();
                        yield return(this.Complement);

                        if (sb.SizeLimit.Value > l)
                        {
                            sb.Output.PrintToTarget(t, sb.Format.WritingSystem.Space);
                        }
                    }
                    else                     // Complement goes inside phrase
                    {
                        sb.Print(result.LeftSide);
                        sb.Print(sb.Format.WritingSystem.Space);
                        long l = sb.SizeLimit.Value;
                        yield return(this.Complement);

                        if (sb.SizeLimit.Value > l)
                        {
                            sb.Print(sb.Format.WritingSystem.Space);
                        }
                        sb.Print(result.RightSide);
                    }
                }
                else
                {
                    sb.Print(result.Value);
                    if (this.Complement != null)
                    {
                        long l = sb.SizeLimit.Value;
                        var  t = sb.Output.InsertAnonymousTarget();
                        yield return(this.Complement);

                        if (sb.SizeLimit.Value > l)
                        {
                            sb.Output.PrintToTarget(t, sb.Format.WritingSystem.Space);
                        }
                    }
                }
            }
        }
Beispiel #4
0
 internal RantInternalException(string message, Exception inner)
     : base(Txtres.GetString("err-internal-error-msg", message), inner)
 {
 }
Beispiel #5
0
 internal RantInternalException(Exception inner)
     : base(Txtres.GetString("err-internal-error"), inner)
 {
 }