Files
swift-mirror/include/swift/AST/MagicIdentifierKinds.def
Doug Gregor 9d24f447b7 Remove special handling of __FILE__, __LINE__, etc.
These were replaced by `#file`, `#line`, etc. with SE-0028, prior to
Swift 3. We don't need this custom error message any more, and they
shouldn't be keywords. Stop treating them as keywords in the lexer.
2022-12-10 15:38:09 -08:00

100 lines
3.3 KiB
C++

//===--- MagicIdentifierKinds.def - Swift #ident metaprogramming -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with magic
// identifier literals.
//
//===----------------------------------------------------------------------===//
// Used for any magic identifier.
#ifndef MAGIC_IDENTIFIER
#define MAGIC_IDENTIFIER(NAME, STRING, SYNTAX_KIND)
#endif
// Used for magic identifiers which produce string literals.
#ifndef MAGIC_STRING_IDENTIFIER
#define MAGIC_STRING_IDENTIFIER(NAME, STRING, SYNTAX_KIND) MAGIC_IDENTIFIER(NAME, STRING, SYNTAX_KIND)
#endif
// Used for magic identifiers which produce integer literals.
#ifndef MAGIC_INT_IDENTIFIER
#define MAGIC_INT_IDENTIFIER(NAME, STRING, SYNTAX_KIND) MAGIC_IDENTIFIER(NAME, STRING, SYNTAX_KIND)
#endif
// Used for magic identifiers which produce raw pointers.
#ifndef MAGIC_POINTER_IDENTIFIER
#define MAGIC_POINTER_IDENTIFIER(NAME, STRING, SYNTAX_KIND) MAGIC_IDENTIFIER(NAME, STRING, SYNTAX_KIND)
#endif
// Used when a given token always maps to a particular magic identifier kind.
#ifndef MAGIC_IDENTIFIER_TOKEN
#define MAGIC_IDENTIFIER_TOKEN(NAME, TOKEN)
#endif
//
// Magic string literals
//
/// The \c #fileID magic identifier literal.
MAGIC_STRING_IDENTIFIER(FileID, "#fileID", PoundFileIDExpr)
MAGIC_IDENTIFIER_TOKEN(FileID, pound_fileID)
/// The \c #file magic identifier literal, written in code where it is
/// a synonym for \c #fileID (i.e. "Swift 6 mode" code).
MAGIC_STRING_IDENTIFIER(FileIDSpelledAsFile, "#file", PoundFileExpr)
// tok::pound_file is shared with FilePathSpelledAsFile; please write custom
// code paths for it.
/// The \c #filePath magic identifier literal.
MAGIC_STRING_IDENTIFIER(FilePath, "#filePath", PoundFilePathExpr)
MAGIC_IDENTIFIER_TOKEN(FilePath, pound_filePath)
/// The \c #file magic identifier literal, written in code where it is
/// a synonym for \c #filePath (i.e. Swift 5 mode code).
MAGIC_STRING_IDENTIFIER(FilePathSpelledAsFile, "#file", PoundFileExpr)
// tok::pound_file is shared with FileIDSpelledAsFile; please write custom
// code paths for it.
/// The \c #function magic identifier literal.
MAGIC_STRING_IDENTIFIER(Function, "#function", PoundFunctionExpr)
MAGIC_IDENTIFIER_TOKEN(Function, pound_function)
//
// Magic integer literals
//
/// The \c #line magic identifier literal.
MAGIC_INT_IDENTIFIER(Line, "#line", PoundLineExpr)
MAGIC_IDENTIFIER_TOKEN(Line, pound_line)
/// The \c #column magic identifier literal.
MAGIC_INT_IDENTIFIER(Column, "#column", PoundColumnExpr)
MAGIC_IDENTIFIER_TOKEN(Column, pound_column)
//
// Magic raw pointer literals
//
/// The \c #dsohandle magic identifier literal.
MAGIC_POINTER_IDENTIFIER(DSOHandle, "#dsohandle", PoundDsohandleExpr)
MAGIC_IDENTIFIER_TOKEN(DSOHandle, pound_dsohandle)
#undef MAGIC_IDENTIFIER
#undef MAGIC_STRING_IDENTIFIER
#undef MAGIC_INT_IDENTIFIER
#undef MAGIC_POINTER_IDENTIFIER
#undef MAGIC_IDENTIFIER_TOKEN