Files
swift-mirror/include/swift/AST/PatternNodes.def
Chris Lattner 468ead25a6 allow 'var' and 'let' to appear in patterns (not just matching patterns).
This allows them to appear in argument lists of functions, enabling behavior
like this:

func test_arguments(a : Int, var b : Int, let c : Int) {
  a = 1  // ok (for now).
  b = 2  // ok.
  c = 3  // expected-error {{cannot assign to the result of this expression}}
}



Swift SVN r11746
2013-12-30 21:48:06 +00:00

44 lines
1.5 KiB
C++

//===--- PatternNodes.def - Swift Pattern AST Metaprogramming ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with patterns.
//
//===----------------------------------------------------------------------===//
/// PATTERN(Id, Parent)
/// The pattern's enumerator value is PatternKind::Id. The pattern's
/// class name is Id##Pattern, and the name of its base class is Parent.
#ifndef PATTERN
# error Included PatternNodes.def without defining PATTERN!
#endif
/// REFUTABLE_PATTERN(Id, Parent)
/// Matching this pattern can fail. These patterns cannot appear syntactically
/// in variable declarations, assignments, or function declarations.
#ifndef REFUTABLE_PATTERN
# define REFUTABLE_PATTERN(Id, Parent) PATTERN(Id, Parent)
#endif
PATTERN(Paren, Pattern)
PATTERN(Tuple, Pattern)
PATTERN(Named, Pattern)
PATTERN(Any, Pattern)
PATTERN(Typed, Pattern)
PATTERN(Var, Pattern)
REFUTABLE_PATTERN(Isa, Pattern)
REFUTABLE_PATTERN(NominalType, Pattern)
REFUTABLE_PATTERN(EnumElement, Pattern)
REFUTABLE_PATTERN(Expr, Pattern)
#undef PATTERN
#undef REFUTABLE_PATTERN