private ExpressionNode parseCastExpression(bool force) { var filename = scanner.Filename; var line = scanner.StartLine; var column = scanner.StartColumn; var disabledWarnings = scanner.CodeErrorManager.DisabledWarnings; var startPosition = scanner.StartPosition; var restorePoint = this.createRestorePoint(); nextLexicalUnit(true); var type = parseType(false); if (type == null || lexicalUnit != LexicalUnit.CloseParenthesis || nextLexicalUnit(false) == LexicalUnit.EndOfStream) { if (force) { throw error(ParseErrorId.UnexpectedLexicalUnit); } this.restore(restorePoint); return null; } switch (lexicalUnit) { case Keyword: switch (scanner.Keyword) { case As: case Instanceof: if (!force) { this.restore(restorePoint); return null; } break; } break; case Identifier: case VerbatimIdentifier: case Complement: case Not: case OpenParenthesis: case DoubleLiteral: case FloatLiteral: case StringLiteral: case RealLiteral: case CharacterLiteral: case DecimalIntegerLiteral: case LongLiteral: case VerbatimStringLiteral: break; case ContextualKeyword: if (scanner.Keyword == Keyword.From) { var result = new CastExpressionNode { Filename = filename, Line = line, Column = column, DisabledWarnings = disabledWarnings, StartPosition = startPosition, TargetType = type }; result.Expression = parseQueryExpression(); result.EndPosition = result.Expression.EndPosition; return result; } break; default: if (!force) { this.restore(restorePoint); return null; } break; } var result = new CastExpressionNode { Filename = filename, Line = line, Column = column, DisabledWarnings = disabledWarnings, StartPosition = startPosition, TargetType = type }; result.Expression = parseUnaryExpression(); result.EndPosition = result.Expression.EndPosition; return result; }
protected virtual TResult handleCast(CastExpressionNode cast, TSource source, bool nested) { return(defaultHandler()); }