public Expr OnParseThrow()
        {
            var tokenIt        = this._parser.TokenIt;
            var initiatorToken = tokenIt.NextToken;
            var expr           = new ThrowExpr();

            // <codeThrow>

            tokenIt.Expect(Tokens.Throw);
            expr.Exp = this._parser.ParseExpression(Terminators.ExpStatementEnd, true, false, true, true, false);

            // </codeThrow>
            this._parser.SetupContext(expr, initiatorToken);
            return(expr);
        }
        /// <summary>
        /// Execute
        /// </summary>
        public object VisitThrow(ThrowExpr expr)
        {
            var message = "";

            if (expr.Exp != null)
            {
                var result = expr.Exp.Evaluate(this) as LObject;
                if (result != LObjects.Null)
                {
                    message = result.GetValue().ToString();
                }
            }

            throw new LangException("TypeError", message, expr.Ref.ScriptName, expr.Ref.Line);
        }
 /// <summary>
 /// Visits the try statement tree.
 /// </summary>
 /// <param name="tryExpr"></param>
 public object VisitThrow(ThrowExpr expr)
 {
     _callBackOnNodeStart(expr);
     return(null);
 }
Beispiel #4
0
 /// <summary>
 /// Visits the try statement tree.
 /// </summary>
 /// <param name="tryExpr"></param>
 public object VisitThrow(ThrowExpr expr)
 {
     _callBackOnNodeStart(expr);
     return null;
 }
Beispiel #5
0
        public static void Main()
        {
            Console.WriteLine("----------------------------");
            Console.WriteLine("C#7 -- Binary Literals & Digit Separators");
            Console.WriteLine("----------------------------");
            BinLitDigSep.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Tuples & Deconstruction");
            Console.WriteLine("----------------------------");
            Tuples.Main();
            DeconstructEG.Main();

            Console.WriteLine("----------------------------");
            Console.WriteLine("C#7 -- Local Functions");
            Console.WriteLine("----------------------------");
            LocalFunc.Main();

            Console.WriteLine("----------------------------");
            Console.WriteLine("C#7 -- Pattern Matching");
            Console.WriteLine("----------------------------");
            PatternMatch.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Out variables");
            Console.WriteLine("----------------------------");
            OutVarDecl.Main();

            Console.WriteLine("----------------------------");
            Console.WriteLine("C#7 -- Expression bodied getters and setters");
            Console.WriteLine("----------------------------");
            ExprBodyGetSet.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Expression bodied constructors and finalizers");
            Console.WriteLine("----------------------------");
            ExprBodyConstrFinalizer.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Throw Expressions");
            Console.WriteLine("----------------------------");
            ThrowExpr.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Discards");
            Console.WriteLine("----------------------------");
            DiscardsEG.Main();

            Console.WriteLine("----------------------------");
            Console.WriteLine("C#7 -- Generalized async return types");
            Console.WriteLine("----------------------------");
            Console.WriteLine("See the source filed named \"GenAsyncReturn.cs\" ");

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("C#7 -- Ref returns and locals");
            Console.WriteLine("----------------------------");
            RefLocal.Main();

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("----------------------------");
        }