Example #1
0
 private static bool IsLikelyEbcdic(String canonName, bool asciiSuperset)
 {
     if(!asciiSuperset) {
         return canonName.StartsWithInvariant("cp") || canonName.StartsWithInvariant("ibm") || canonName.StartsWithInvariant("xibm");
     }
     return false;
 }
Example #2
0
 private String ParseEscapeSequence(String str)
 {
     if (str[0] != '\\')
     {
         return str;
     }
     str = str.Substring(1);
     if (str.StartsWithInvariant("$("))
     {
         this._codes.Add(ParseEscapeSequences(str.Substring(1)));
         return "{" + (this._codes.Count - 1) + "}";
     }
     else if (str.StartsWithInvariant("M-\\C-") || str.StartsWithInvariant("C-\\M-"))
     {
         return ((Char) (ParseEscapeSequence(str.Substring(4))[0] & 0x9f | 0x80)).ToString();
     }
     else if (str.StartsWithInvariant("C-"))
     {
         return ((Char) (ParseEscapeSequence(str.Substring(2))[0] & 0x9f)).ToString();
     }
     else if (str.StartsWithInvariant("M-"))
     {
         return ((Char) (ParseEscapeSequence(str.Substring(2))[0] & 0xff | 0x80)).ToString();
     }
     else if (str[0] == 'u' && str.Length > 1)
     {
         return ((Char) System.Convert.ToInt32(str.Substring(1), 16)).ToString();
     }
     else if (str[0] == 'U' && str.Length > 1)
     {
         return ((Char) System.Convert.ToInt32(str.Substring(1), 16)).ToString();
     }
     else if (Char.IsDigit(str, 0))
     {
         return ((Char) System.Convert.ToInt32(str, 8)).ToString();
     }
     else if (str[0] == 'x' && str.Length > 1)
     {
         return ((Char) System.Convert.ToInt32(str.Substring(1), 16)).ToString();
     }
     else
     {
         switch (str[0])
         {
             case 'a':
                 return "\a";
             case 'b':
                 return "\b";
             case 'e':
                 return "\x1b";
             case 'f':
                 return "\f";
             case 'n':
                 return "\n";
             case 'r':
                 return "\r";
             case 's':
                 return " ";
             case 't':
                 return "\t";
             case 'v':
                 return "\v";
             case 'N':
                 return Environment.NewLine;
             default:
                 return str;
         }
     }
 }
Example #3
0
 private static bool IsBanned(String lowerCasePreferredIanaName)
 {
     if(lowerCasePreferredIanaName.StartsWithInvariant("xibm")) {
         return true;
     }
     return Array.BinarySearch(BANNED, lowerCasePreferredIanaName) > -1;
 }
Example #4
0
        private static Expression Load(SymbolTable symbols, Object obj, String name)
        {
            if (name.StartsWithInvariant(CtsPrefix))
            {
                return Expression.Constant(((IEnumerable<IGrouping<String, Type>>) obj)
                    .Select(g => g.Key.Apply(k => symbols[k] = YacqExpression.TypeCandidate(symbols, g)))
                    .ToArray()
                );
            }
            else
            {
                var stream = (Stream) obj;
                switch (Path.GetExtension(name).ToLowerInvariant())
                {
                    case ".dll":
#if SILVERLIGHT
                        throw new NotImplementedException("Loading DLL is not implemented in Sliverlight environment.");
#else
                        return Expression.Constant(new Byte[stream.Length].Apply(b => stream.Read(b, 0, b.Length))
                            .Let(Assembly.Load)
                            .Apply(a => a.GetTypes()
                                .Where(t => t.IsPublic)
                                .ForEach(symbols.Import)
                            )
                        );
#endif
                    case ".yacb":
                        throw new NotImplementedException("YACQ Binary code is not implemented.");
                    default:
                        return new StreamReader(stream, true)
                            .Dispose(r => YacqServices.Parse(symbols, r.ReadToEnd()));
                }
            }
        }