コード例 #1
0
        public static Symbol ReadBranch(LispReader stream, bool hasTest, BranchMode mode, ref Vector branch)
        {
            var haveFeatures = false;

            if (hasTest)
            {
                var test = stream.Read();
                switch (mode)
                {
                case BranchMode.False:
                {
                    haveFeatures = false;
                    break;
                }

                case BranchMode.True:
                {
                    haveFeatures = true;
                    break;
                }

                case BranchMode.Eval:
                default:
                {
                    haveFeatures = EvalFeatureExpr(test);
                    break;
                }
                }
            }
            else
            {
                haveFeatures = mode == BranchMode.True;
            }

            if (haveFeatures)
            {
                branch = new Vector();
            }

            while (true)
            {
                var obj = haveFeatures ? stream.Read() : stream.ReadSuppressed();

                if (obj == Symbols.HashElif || obj == Symbols.HashElse || obj == Symbols.HashEndif)
                {
                    return((Symbol)obj);
                }
                else if (haveFeatures)
                {
                    branch.Add(obj);
                }
            }
        }
コード例 #2
0
        public static object ReadPlusExprHandler(LispReader stream, string ch, int arg)
        {
            object test         = stream.Read();
            bool   haveFeatures = EvalFeatureExpr(test);

            if (!haveFeatures)
            {
                stream.ReadSuppressed();
                return(VOID.Value);
            }
            else
            {
                return(stream.Read());
            }
        }
コード例 #3
0
        public static object ReadCommaHandler(LispReader stream, char ch)
        {
            var ch2 = stream.ReadChar();

            if (ch2 == '@' || ch2 == '.')
            {
                // Destructive splicing is handled as ordinary splicing
                return(MakeList(Symbols.UnquoteSplicing, stream.Read()));
            }
            else
            {
                stream.UnreadChar();
                return(MakeList(Symbols.Unquote, stream.Read()));
            }
        }
コード例 #4
0
        public static object ReadQuasiQuoteHandler(LispReader stream, char ch)
        {
            var exp1 = stream.Read();
            var exp2 = QuasiQuoteExpandRest(exp1);

            return(exp2);
        }
コード例 #5
0
        public static object ReadCharacterHandler(LispReader stream, string ch, int arg)
        {
            stream.UnreadChar();
            var name = MakeString(stream.Read());
            var chr  = DecodeCharacterName(name);

            return(chr);
        }
コード例 #6
0
        public static object ReadExecuteHandler(LispReader stream, string ch, int arg)
        {
            var expr     = stream.Read();
            var readEval = GetDynamic(Symbols.ReadEval);

            if (readEval == null)
            {
                readEval = false; //stream.loading;
            }
            if (!ToBool(readEval))
            {
                throw stream.MakeScannerException("Invalid use of '#.' (prohibited by $read-eval variable)");
            }
            var value = Eval(expr);

            return(value);
        }
コード例 #7
0
 public static object ReadQuoteHandler(LispReader stream, char ch)
 {
     return(MakeList(Symbols.Quote, stream.Read()));
 }
コード例 #8
0
 public static object ReadQuasiQuoteHandler(LispReader stream, char ch)
 {
     var exp1 = stream.Read();
     var exp2 = QuasiQuoteExpandRest(exp1);
     return exp2;
 }
コード例 #9
0
 public static object ReadQuoteHandler(LispReader stream, char ch)
 {
     return MakeList(Symbols.Quote, stream.Read());
 }
コード例 #10
0
 public static object ReadPlusExprHandler(LispReader stream, string ch, int arg)
 {
     object test = stream.Read();
     bool haveFeatures = EvalFeatureExpr(test);
     if (!haveFeatures)
     {
         stream.ReadSuppressed();
         return VOID.Value;
     }
     else
     {
         return stream.Read();
     }
 }
コード例 #11
0
 public static object ReadExecuteHandler(LispReader stream, string ch, int arg)
 {
     var expr = stream.Read();
     var readEval = GetDynamic(Symbols.ReadEval);
     if (readEval == null)
     {
         readEval = false; //stream.loading;
     }
     if (!ToBool(readEval))
     {
         throw stream.MakeScannerException("Invalid use of '#.' (prohibited by $read-eval variable)");
     }
     var value = Eval(expr);
     return value;
 }
コード例 #12
0
        public static object ReadCommaHandler(LispReader stream, char ch)
        {
            var ch2 = stream.ReadChar();

            if (ch2 == '@' || ch2 == '.')
            {
                // Destructive splicing is handled as ordinary splicing
                return MakeList(Symbols.UnquoteSplicing, stream.Read());
            }
            else
            {
                stream.UnreadChar();
                return MakeList(Symbols.Unquote, stream.Read());
            }
        }
コード例 #13
0
 public static object ReadCharacterHandler(LispReader stream, string ch, int arg)
 {
     stream.UnreadChar();
     var name = MakeString(stream.Read());
     var chr = DecodeCharacterName(name);
     return chr;
 }
コード例 #14
0
        public static Symbol ReadBranch(LispReader stream, bool hasTest, BranchMode mode, ref Vector branch)
        {
            var haveFeatures = false;

            if (hasTest)
            {
                var test = stream.Read();
                switch (mode)
                {
                    case BranchMode.False:
                        {
                            haveFeatures = false;
                            break;
                        }
                    case BranchMode.True:
                        {
                            haveFeatures = true;
                            break;
                        }
                    case BranchMode.Eval:
                    default:
                        {
                            haveFeatures = EvalFeatureExpr(test);
                            break;
                        }
                }
            }
            else
            {
                haveFeatures = mode == BranchMode.True;
            }

            if (haveFeatures)
            {
                branch = new Vector();
            }

            while (true)
            {
                var obj = haveFeatures ? stream.Read() : stream.ReadSuppressed();

                if (obj == Symbols.HashElif || obj == Symbols.HashElse || obj == Symbols.HashEndif)
                {
                    return (Symbol)obj;
                }
                else if (haveFeatures)
                {
                    branch.Add(obj);
                }
            }
        }