Пример #1
0
 /// <summary>
 /// Initializes a new <see cref="AccessorExpr"/>.
 /// </summary>
 /// <param name="location">Location of this expression.</param>
 /// <param name="left">Left access.</param>
 /// <param name="isStatement">True if this expression is a statement.</param>
 /// <param name="isBreakable">True to allow breaking on this type of expession.</param>
 protected AccessorExpr( SourceLocation location, Expr left, bool isStatement, bool isBreakable )
     : base(location, isStatement, isBreakable)
 {
     Left = left;
 }
Пример #2
0
 /// <summary>
 /// Creates a new <see cref="AccessorMemberExpr"/> for a field or a variable.
 /// </summary>
 /// <param name="left">Left scope. Can be null for unbound reference.</param>
 /// <param name="fieldOrVariableName">Field, variable or function name.</param>
 public AccessorMemberExpr( SourceLocation location, Expr left, string fieldOrVariableName, bool isStatement )
     : base( location, left, isStatement, false )
 {
     Name = fieldOrVariableName;
 }
Пример #3
0
 public WithExpr(SourceLocation location, Expr objExpr, Expr code)
     : base(location, code.IsStatement, true)
 {
     Obj  = objExpr;
     Code = code;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new <see cref="AccessorExpr"/>.
 /// </summary>
 /// <param name="location">Location of this expression.</param>
 /// <param name="left">Left access.</param>
 /// <param name="isStatement">True if this expression is a statement.</param>
 /// <param name="isBreakable">True to allow breaking on this type of expession.</param>
 protected AccessorExpr(SourceLocation location, Expr left, bool isStatement, bool isBreakable)
     : base(location, isStatement, isBreakable)
 {
     Left = left;
 }
Пример #5
0
 Expr HandleNud()
 {
     if (_parser.IsErrorOrEndOfInput)
     {
         return(new SyntaxErrorExpr(_parser.Location, "Error: " + _parser.ErrorCode.ToString()));
     }
     Debug.Assert(!_parser.IsErrorOrEndOfInput);
     if (_parser.IsNumber)
     {
         return(new ConstantExpr(_parser.Location, _parser.ReadDouble(), _parser.Match(TokenizerToken.SemiColon)));
     }
     if (_parser.IsString)
     {
         return(new ConstantExpr(_parser.Location, _parser.ReadString(), _parser.Match(TokenizerToken.SemiColon)));
     }
     if (_parser.IsUnaryOperatorOrPlusOrMinus)
     {
         return(HandleUnaryExpr());
     }
     if (_parser.IsIdentifier)
     {
         if (_parser.MatchIdentifier("if"))
         {
             return(HandleIf());
         }
         if (_parser.MatchIdentifier("let"))
         {
             return(HandleLet());
         }
         if (_parser.MatchIdentifier("while"))
         {
             return(HandleWhile());
         }
         if (_parser.MatchIdentifier("break"))
         {
             return(new FlowBreakingExpr(_parser.PrevNonCommentLocation, false));
         }
         if (_parser.MatchIdentifier("continue"))
         {
             return(new FlowBreakingExpr(_parser.PrevNonCommentLocation, true));
         }
         if (_parser.MatchIdentifier("return"))
         {
             return(new FlowBreakingExpr(_parser.PrevNonCommentLocation, Expression(0), false));
         }
         if (_parser.MatchIdentifier("throw"))
         {
             return(new FlowBreakingExpr(_parser.PrevNonCommentLocation, Expression(0), true));
         }
         if (_parser.MatchIdentifier("do"))
         {
             return(HandleDoWhile());
         }
         if (_parser.MatchIdentifier("foreach"))
         {
             return(HandleForeach());
         }
         if (_parser.MatchIdentifier("function"))
         {
             return(HandleFunction());
         }
         if (_parser.MatchIdentifier("try"))
         {
             return(HandleTryCatch());
         }
         if (_parser.MatchIdentifier("with"))
         {
             return(HandleWith());
         }
         return(HandleIdentifier());
     }
     if (_parser.Match(TokenizerToken.OpenCurly))
     {
         return(HandleBlock());
     }
     if (_parser.Match(TokenizerToken.OpenPar))
     {
         SourceLocation location = _parser.PrevNonCommentLocation;
         Expr           e        = Expression(0);
         if (e is SyntaxErrorExpr)
         {
             return(e);
         }
         return(_parser.Match(TokenizerToken.ClosePar) ? e : new SyntaxErrorExpr(_parser.Location, "Expected ')' opened at {0}.", location));
     }
     if (_parser.Match(TokenizerToken.SemiColon))
     {
         return(NopExpr.Statement);
     }
     return(new SyntaxErrorExpr(_parser.Location, "Syntax Error."));
 }