Files
swift-mirror/include/swift/AST/PatternNodes.def
2015-12-31 23:28:40 +00:00

46 lines
1.6 KiB
C++

//===--- PatternNodes.def - Swift Pattern AST Metaprogramming ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 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(Is, Pattern)
REFUTABLE_PATTERN(NominalType, Pattern)
REFUTABLE_PATTERN(EnumElement, Pattern)
REFUTABLE_PATTERN(OptionalSome, Pattern)
REFUTABLE_PATTERN(Bool, Pattern)
REFUTABLE_PATTERN(Expr, Pattern)
#undef PATTERN
#undef REFUTABLE_PATTERN