• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# lang.PushbackTextReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中clojure.lang.PushbackTextReader的典型用法代码示例。如果您正苦于以下问题:C# PushbackTextReader类的具体用法?C# PushbackTextReader怎么用?C# PushbackTextReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PushbackTextReader类属于clojure.lang命名空间,在下文中一共展示了PushbackTextReader类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadFromStream

        public object LoadFromStream(PushbackTextReader rdr, bool addPrint)
        {
            object ret = null;
            object eofVal = new object();
            object form;
            while ((form = LispReader.read(rdr, false, eofVal, false)) != eofVal)
            {
                try
                {
                    LambdaExpression ast = Compiler.GenerateLambda(form, addPrint);
                    ret = ast.Compile().DynamicInvoke();
                }
                catch (Exception ex)
                {
                    if (addPrint)
                    {
                        Exception root = ex;
                        while (root.InnerException != null)
                            root = root.InnerException;

                        Console.WriteLine("Error evaluating {0}: {1}", form, root.Message);
                        Console.WriteLine(root.StackTrace);
                    }
                }
            }
            return ret;
        }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:27,代码来源:SimpleConsole.cs


示例2: ParseFile

        internal object ParseFile()
        {
            IPersistentVector pv = PersistentVector.EMPTY;

            StringReader sr = new StringReader(_text);
            PushbackTextReader pr = new PushbackTextReader(sr);

            pv = pv.cons(Compiler.DO);

            object eofVal = new object();
            object form;
            while ((form = LispReader.read(pr, false, eofVal, false)) != eofVal)
                pv = pv.cons(form);

            return pv.seq();
        }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:16,代码来源:ClojureParser.cs


示例3: Read

            protected override object Read(PushbackTextReader r, char doublequote)
            {
                StringBuilder sb = new StringBuilder();

                for (int ch = r.Read(); ch != '"'; ch = r.Read())
                {
                    if (ch == -1)
                        throw new EndOfStreamException("EOF while reading string");
                    if (ch == '\\')	//escape
                    {
                        ch = r.Read();
                        if (ch == -1)
                            throw new EndOfStreamException("EOF while reading string");
                        switch (ch)
                        {
                            case 't':
                                ch = '\t';
                                break;
                            case 'r':
                                ch = '\r';
                                break;
                            case 'n':
                                ch = '\n';
                                break;
                            case '\\':
                                break;
                            case '"':
                                break;
                            case 'b':
                                ch = '\b';
                                break;
                            case 'f':
                                ch = '\f';
                                break;
                            case 'u':
                                ch = r.Read();
                                if (CharValueInRadix(ch, 16) == -1)
                                    throw new Exception("Invalid unicode escape: \\u" + (char)ch);
                                ch = readUnicodeChar((PushbackTextReader)r, ch, 16, 4, true);
                                break;
                            default:
                                {
                                    if (CharValueInRadix(ch, 8) != -1)
                                    {
                                        ch = readUnicodeChar((PushbackTextReader)r, ch, 8, 3, false);
                                        if (ch > 255) //octal377
                                            throw new Exception("Octal escape sequence must be in range [0, 377].");
                                    }
                                    else
                                        throw new Exception("Unsupported escape character: \\" + (char)ch);
                                }
                                break;
                        }
                    }
                    sb.Append((char)ch);
                }
                return sb.ToString();
            }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:58,代码来源:LispReader.cs


示例4: read

        // There is really no reason for the main entry point to have an isRecursive flag, is there?
        public static object read(PushbackTextReader r,
            bool eofIsError,
            object eofValue,
            bool isRecursive)
        {
            try
            {
                for (; ; )
                {
                    int ch = r.Read();

                    while (isWhitespace(ch))
                        ch = r.Read();

                    if (ch == -1)
                    {
                        if (eofIsError)
                            throw new EndOfStreamException("EOF while reading");
                        return eofValue;
                    }

                    if (Char.IsDigit((char)ch))
                    {
                        object n = readNumber(r, (char)ch);
                        return RT.suppressRead() ? null : n;
                    }

                    IFn macroFn = getMacro(ch);
                    if (macroFn != null)
                    {
                        object ret = macroFn.invoke(r, (char)ch);
                        if (RT.suppressRead())
                            return null;
                        // no op macros return the reader
                        if (ret == r)
                            continue;
                        return ret;
                    }

                    if (ch == '+' || ch == '-')
                    {
                        int ch2 = r.Read();
                        if (Char.IsDigit((char)ch2))
                        {
                            Unread(r, ch2);
                            object n = readNumber(r, (char)ch);
                            return RT.suppressRead() ? null : n;
                        }
                        Unread(r, ch2);
                    }

                    string token = readToken(r, (char)ch);
                    return RT.suppressRead() ? null : interpretToken(token);
                }
            }
            catch (Exception e)
            {
                if (isRecursive || !(r is LineNumberingTextReader))
                    throw e;
                LineNumberingTextReader rdr = r as LineNumberingTextReader;
                throw new ReaderException(rdr.LineNumber, e);
            }
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:64,代码来源:LispReader.cs


示例5: readDelimitedList

        public static List<Object> readDelimitedList(char delim, PushbackTextReader r, bool isRecursive)
        {
            List<Object> a = new List<object>();

            for (; ; )
            {
                int ch = r.Read();

                while (isWhitespace(ch))
                    ch = r.Read();

                if (ch == -1)
                    throw new EndOfStreamException("EOF while reading");

                if (ch == delim)
                {
                    break;
                }

                IFn macroFn = getMacro(ch);
                if (macroFn != null)
                {
                    Object mret = macroFn.invoke(r, (char)ch);
                    //no op macros return the reader
                    if (mret != r)
                        a.Add(mret);
                }
                else
                {
                    Unread(r, ch);
                    object o = read(r, true, null, isRecursive);
                    if (o != r)
                        a.Add(o);
                }
            }

            return a;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:38,代码来源:LispReader.cs


示例6: ReadAux

 private static object ReadAux(PushbackTextReader r)
 {
     return read(r, true, null, true);
 }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:4,代码来源:LispReader.cs


示例7: readNumber

        static object readNumber(PushbackTextReader r, char initch)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(initch);

            for (; ; )
            {
                int ch = r.Read();
                if (ch == -1 || isWhitespace(ch) || isMacro(ch))
                {
                    Unread(r, ch);
                    break;
                }
                sb.Append((char)ch);
            }

            string s = sb.ToString();
            object n = matchNumber(s);
            if (n == null)
                throw new FormatException("Invalid number: " + s);
            return n;
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:22,代码来源:LispReader.cs


示例8: readToken

        static string readToken(PushbackTextReader r, char initch)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(initch);

            for(; ;)
            {
                int ch = r.Read();
                if(ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch))
                {
                    Unread(r, ch);
                    return sb.ToString();
                }
                sb.Append((char) ch);
            }
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:16,代码来源:LispReader.cs


示例9: readUnicodeChar

 static int readUnicodeChar(PushbackTextReader r, int initch, int radix, int length, bool exact)
 {
     int uc = CharValueInRadix(initch, radix);
     if (uc == -1)
         throw new ArgumentException("Invalid digit: " + initch);
     int i = 1;
     for (; i < length; ++i)
     {
         int ch = r.Read();
         if (ch == -1 || isWhitespace(ch) || isMacro(ch))
         {
             Unread(r, ch);
             break;
         }
         int d = CharValueInRadix(ch, radix);
         if (d == -1)
             throw new ArgumentException("Invalid digit: " + (char)ch);
         uc = uc * radix + d;
     }
     if (i != length && exact)
         throw new ArgumentException("Invalid character length: " + i + ", should be: " + length);
     return uc;
 }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:23,代码来源:LispReader.cs


示例10: Unread

 static void Unread(PushbackTextReader r, int ch)
 {
     if (ch != -1)
         r.Unread(ch);
 }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:5,代码来源:LispReader.cs



注:本文中的clojure.lang.PushbackTextReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# lang.Symbol类代码示例发布时间:2022-05-26
下一篇:
C# lang.Namespace类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap