| %{ |
| # -*- mode: Swift -*- |
| from gyb_syntax_support import * |
| # Ignore the following admonition it applies to the resulting .def file only |
| }% |
| //// Automatically Generated From TokenKinds.def.gyb. |
| //// Do Not Edit Directly! |
| //===--- TokenKinds.def - Swift Tokenizer Metaprogramming -----------------===// |
| // |
| // This source file is part of the Swift.org open source project |
| // |
| // Copyright (c) 2014 - 2017 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 x-macros used for metaprogramming with lexer tokens. |
| /// |
| /// TOKEN(name) |
| /// KEYWORD(kw) |
| /// SWIFT_KEYWORD(kw) |
| /// DECL_KEYWORD(kw) |
| /// STMT_KEYWORD(kw) |
| /// EXPR_KEYWORD(kw) |
| /// PAT_KEYWORD(kw) |
| /// SIL_KEYWORD(kw) |
| /// POUND_KEYWORD(kw) |
| /// POUND_OBJECT_LITERAL(kw, desc, proto) |
| /// POUND_CONFIG(kw) |
| /// POUND_DIRECTIVE_KEYWORD(kw) |
| /// POUND_COND_DIRECTIVE_KEYWORD(kw) |
| /// PUNCTUATOR(name, str) |
| /// LITERAL(name) |
| /// MISC(name) |
| /// |
| //===----------------------------------------------------------------------===// |
| |
| /// TOKEN(name) |
| /// Expands by default for every token kind. |
| #ifndef TOKEN |
| #define TOKEN(name) |
| #endif |
| |
| /// KEYWORD(kw) |
| /// Expands by default for every Swift keyword and every SIL keyword, such as |
| /// 'if', 'else', 'sil_global', etc. If you only want to use Swift keywords |
| /// see SWIFT_KEYWORD. |
| #ifndef KEYWORD |
| #define KEYWORD(kw) TOKEN(kw_ ## kw) |
| #endif |
| |
| /// SWIFT_KEYWORD(kw) |
| /// Expands for every Swift keyword. |
| #ifndef SWIFT_KEYWORD |
| #define SWIFT_KEYWORD(kw) KEYWORD(kw) |
| #endif |
| |
| /// DECL_KEYWORD(kw) |
| /// Expands for every Swift keyword that can be used in a declaration. |
| #ifndef DECL_KEYWORD |
| #define DECL_KEYWORD(kw) SWIFT_KEYWORD(kw) |
| #endif |
| |
| /// STMT_KEYWORD(kw) |
| /// Expands for every Swift keyword used in statement grammar. |
| #ifndef STMT_KEYWORD |
| #define STMT_KEYWORD(kw) SWIFT_KEYWORD(kw) |
| #endif |
| |
| /// EXPR_KEYWORD(kw) |
| /// Expands for every Swift keyword used in an expression, such as 'true', |
| /// 'false', and 'as' |
| #ifndef EXPR_KEYWORD |
| #define EXPR_KEYWORD(kw) SWIFT_KEYWORD(kw) |
| #endif |
| |
| /// PAT_KEYWORD(kw) |
| /// Expands for every Swift keyword used in a pattern, which is currently |
| /// limited to '_' |
| #ifndef PAT_KEYWORD |
| #define PAT_KEYWORD(kw) SWIFT_KEYWORD(kw) |
| #endif |
| |
| /// SIL_KEYWORD(kw) |
| /// Expands for every SIL keyword. These are only keywords when parsing SIL. |
| #ifndef SIL_KEYWORD |
| #define SIL_KEYWORD(kw) KEYWORD(kw) |
| #endif |
| |
| /// POUND_KEYWORD(kw) |
| /// Every keyword prefixed with a '#'. |
| #ifndef POUND_KEYWORD |
| #define POUND_KEYWORD(kw) TOKEN(pound_ ## kw) |
| #endif |
| |
| /// POUND_OBJECT_LITERAL(kw, desc, proto) |
| /// Every keyword prefixed with a '#' representing an object literal. |
| #ifndef POUND_OBJECT_LITERAL |
| #define POUND_OBJECT_LITERAL(kw, desc, proto) POUND_KEYWORD(kw) |
| #endif |
| |
| /// POUND_CONFIG(kw) |
| /// Every keyword prefixed with a '#' representing a configuration. |
| #ifndef POUND_CONFIG |
| #define POUND_CONFIG(kw) POUND_KEYWORD(kw) |
| #endif |
| |
| /// POUND_DIRECTIVE_KEYWORD(kw) |
| /// Every keyword prefixed with a '#' that is a compiler control directive. |
| #ifndef POUND_DIRECTIVE_KEYWORD |
| #define POUND_DIRECTIVE_KEYWORD(kw) POUND_KEYWORD(kw) |
| #endif |
| |
| /// POUND_COND_DIRECTIVE_KEYWORD(kw) |
| /// Every keyword prefixed with a '#' that is part of conditional compilation |
| /// control. |
| #ifndef POUND_COND_DIRECTIVE_KEYWORD |
| #define POUND_COND_DIRECTIVE_KEYWORD(kw) POUND_DIRECTIVE_KEYWORD(kw) |
| #endif |
| |
| /// PUNCTUATOR(name, str) |
| /// Expands for every Swift punctuator. |
| /// \param name The symbolic name of the punctuator, such as |
| /// 'l_paren' or 'arrow'. |
| /// \param str A string literal containing the spelling of the punctuator, |
| /// such as '"("' or '"->"'. |
| #ifndef PUNCTUATOR |
| #define PUNCTUATOR(name, str) TOKEN(name) |
| #endif |
| |
| /// LITERAL(name) |
| /// Tokens representing literal values, e.g. 'integer_literal'. |
| #ifndef LITERAL |
| #define LITERAL(name) TOKEN(name) |
| #endif |
| |
| /// MISC(name) |
| /// Miscellaneous tokens, e.g. 'eof' and 'unknown'. |
| #ifndef MISC |
| #define MISC(name) TOKEN(name) |
| #endif |
| |
| // Keywords that start decls. |
| % for token in SYNTAX_TOKENS: |
| % if isinstance(token, Token.Punctuator): |
| ${token.macro_name()}(${token.unprefixed_kind}, "${token.text}") |
| % elif isinstance(token, Token.PoundObjectLiteral): |
| ${token.macro_name()}(${token.unprefixed_kind}, "${token.description}", ${token.protocol}) |
| % else: |
| ${token.macro_name()}(${token.unprefixed_kind}) |
| % end |
| % end |
| |
| // The following tokens are irrelevant for swiftSyntax and thus only declared |
| // in this .def file |
| |
| SIL_KEYWORD(undef) |
| SIL_KEYWORD(sil) |
| SIL_KEYWORD(sil_stage) |
| SIL_KEYWORD(sil_property) |
| SIL_KEYWORD(sil_vtable) |
| SIL_KEYWORD(sil_global) |
| SIL_KEYWORD(sil_witness_table) |
| SIL_KEYWORD(sil_default_witness_table) |
| SIL_KEYWORD(sil_differentiability_witness) |
| SIL_KEYWORD(sil_coverage_map) |
| SIL_KEYWORD(sil_scope) |
| |
| PUNCTUATOR(sil_dollar, "$") // Only in SIL mode. |
| PUNCTUATOR(sil_exclamation, "!") // Only in SIL mode. |
| |
| MISC(eof) |
| MISC(code_complete) |
| MISC(sil_local_name) // %42 in SIL mode. |
| MISC(comment) |
| |
| |
| #undef TOKEN |
| #undef KEYWORD |
| #undef SWIFT_KEYWORD |
| #undef DECL_KEYWORD |
| #undef STMT_KEYWORD |
| #undef EXPR_KEYWORD |
| #undef PAT_KEYWORD |
| #undef SIL_KEYWORD |
| #undef POUND_KEYWORD |
| #undef POUND_OBJECT_LITERAL |
| #undef POUND_CONFIG |
| #undef POUND_DIRECTIVE_KEYWORD |
| #undef POUND_COND_DIRECTIVE_KEYWORD |
| #undef PUNCTUATOR |
| #undef LITERAL |
| #undef MISC |