Permalink
Switch branches/tags
4.1-dont-hardcode-numbers-in-objc-block-sil 5.0-dont-hardcode-numbers-in-objc-block-sil Character-test-patch Compare-types-with-equal-equal SR-2545 TensorFlowLite UnicodeEncoding add-test-for-asan-compiler-crash anotherdayanothercommit asyncawait bananaphone builtin-int128 cherr42 codable_test_comment_fix core-team-resolution-2017-05-10 dabrahams-append-contentsOf-replaceRange dcci-build-script-backend demangledmepatatino distributed-test dwa-where-clause-cleanup empty-collection-debugPrecondition external-swift-stdlib _fastCStringContents fix-macos-build-runtime fixmeSC generic-typealias-1-lldb gsb-superclass gyb-nested-expand hoist-to-stringprotocol hoist-to-stringprotocol.1 inhibit-implicit-conversions inline-ASCII-grapheme-fastpaths is-swift-bit-5 latest-emacs-fix-fix marcrasi-const-evaluator-part-1 marcrasi-const-evaluator-part-2 marcrasi-const-evaluator-part-3 marcrasi-last-irgen-attrs marcrasi-static-assert master-llvm-swift5-transition master-next master move-debugging-executables-into-its-own-section no-6-figure-benchmarks owned_fix patatinomio pr-66bbf1369684fc75517cfe6a12718d3cdf6a09d6 pr-94ee6e6c6e2d268f47f17dead77e4feb169c24e6 preservesugar rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch readme-add-tf-gpu remotemirrorsfixmacho remove-narrow-perf-hack revert-12818-cover-model revert-12843-force-on-named-lazy-member-loading revert-13168-large_type_lldb_workaround revert-13438-re-cover-model revert-13597-master revert-14840-concat_thin revert-14846-rdar-37790062-alt revert-15421-disable_autolinkextract revert-15602-deserialize-clang-importer-witness-tables-4.2 revert-16072-disable_failing_test revert-16149-rdar39629937-master revert-16188-assert-metadata-mangled-name-roundtrip revert-17271-DIOptWritePR revert-17370-raj-cp-allargs revert-17668-master revert-18066-sr8022-workaround revert-18156-generalized-accessors revert-18226-42480588 revert-18315-fix-argument-convention revert-18500-swift-syntax-dependency revert-18624-unbreak_unified_linux_builds revert-19006-error-bridging-integer-type revert-19050-revert-19006-error-bridging-integer-type revert-19097-fluctuation-of-the-pupil revert-19130-run-remote-run revert-19138-revert-19130-run-remote-run revert-19202-rework-type-checking-designated-protocol revert-19253-serialize-generic-typealias revert-19300-explicit-implicit-conversion revert-19447-fix-req-diagnstics-not-to-print-special-names revert-19500-updateValue-but-not-the-key revert-19689-keep-sourcekitd-response-alive-while-variant-lives revert-20129-make-nsobject-hashvalue-final revert-20187-another-42247881 revert-20191-revert-20190-rdar45708367 revert-20444-rdar-45659733-5.0 revert-20561-multi-payload-xi revert-20846-swift-5.0-default-to-gold-linker revert-20956-irgen-invariant-load revert-21199-14 rst-to-markdown runtime-fix-swift-error-box-comparison rxwei-patch-1 sequence=collection shahmishal-patch-1 shahmishal/swift-4.2-branch-update shahmishal/test-swift-4.2-branch shahmishal/5.0-update-plist silgen-tests-should-build-modules silgen-transform-null-context-3.0 stable static-rangereplaceable-plus stdlib-BidirectionalCollection.removeLast stdlib-default-RangeReplaceableCollection.SubSequence-3.0 stdlib-indexing stdlib-manual stdlib-swift4-build substring-views substring swift-2.2-branch swift-2.2-with-migration-attributes swift-2.3-branch swift-3.0-branch swift-3.0-preview-1-branch swift-3.0-preview-2-branch swift-3.0-preview-3-branch swift-3.0-preview-4-branch swift-3.0-preview-5-branch swift-3.0-preview-5-speculative swift-3.0.1-preview-2-branch swift-3.1-branch swift-4.0-branch-04-18-2017 swift-4.0-branch-06-02-2017 swift-4.0-branch-06-23-2017 swift-4.0-branch-07-11-2017 swift-4.0-branch-10-10-2017 swift-4.0-branch swift-4.1-branch swift-4.2-branch-03-26-2018 swift-4.2-branch-04-20-2018 swift-4.2-branch-04-30-2018 swift-4.2-branch-06-11-2018 swift-4.2-branch swift-4.2-xcode-10-beta-5 swift-5.0-branch-10-15-2018 swift-5.0-branch-11-16-2018 swift-5.0-branch-12-12-2018 swift-5.0-branch swift-master-xcode-10-beta-5 swiftstringview-specialization tensorflow-merge tensorflow the-runtime-stands-alone-5 typelist-existential unicode-rethink unioc update-checkout-swift-5
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
158 lines (139 sloc) 3.96 KB
%{
from gyb_syntax_support import *
# -*- mode: C++ -*-
# Ignore the following admonition; it applies to the resulting .cpp file only
}%
//// Automatically Generated From SyntaxKind.cpp.gyb.
//// Do Not Edit Directly!
//===-------------- SyntaxKind.cpp - Syntax Kind definitions --------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "swift/Syntax/SyntaxKind.h"
#include "swift/Syntax/TokenKinds.h"
#include "llvm/Support/raw_ostream.h"
namespace swift {
static StringRef getTokenTextInternal(tok kind) {
switch(kind) {
% for token in SYNTAX_TOKENS:
% if token.text:
case tok::${token.kind}: return "${token.text}";
% end
% end
default: return StringRef();
}
}
bool isTokenTextDetermined(tok kind) {
return !getTokenTextInternal(kind).empty();
}
StringRef getTokenText(tok kind) {
auto text = getTokenTextInternal(kind);
assert(!text.empty() && "token kind cannot be determined");
return text;
}
bool parserShallOmitWhenNoChildren(syntax::SyntaxKind Kind) {
switch(Kind) {
% for node in SYNTAX_NODES:
% if node.shall_be_omitted_when_empty():
case syntax::SyntaxKind::${node.syntax_kind}:
% end
% end
return true;
default:
return false;
}
}
namespace syntax {
void dumpSyntaxKind(llvm::raw_ostream &os, const SyntaxKind kind) {
switch (kind) {
case SyntaxKind::Token:
os << "Token";
break;
case SyntaxKind::Unknown:
os << "Unknown";
break;
% for node in SYNTAX_NODES:
case SyntaxKind::${node.syntax_kind}:
os << "${node.syntax_kind}";
break;
% end
}
}
bool isCollectionKind(SyntaxKind Kind) {
switch(Kind) {
% for node in SYNTAX_NODES:
% if node.is_syntax_collection():
case SyntaxKind::${node.syntax_kind}:
% end
% end
return true;
default:
return false;
}
}
bool isDeclKind(SyntaxKind Kind) {
return Kind >= SyntaxKind::First_Decl && Kind <= SyntaxKind::Last_Decl;
}
bool isTypeKind(SyntaxKind Kind) {
return Kind >= SyntaxKind::First_Type && Kind <= SyntaxKind::Last_Type;
}
bool isStmtKind(SyntaxKind Kind) {
return Kind >= SyntaxKind::First_Stmt && Kind <= SyntaxKind::Last_Stmt;
}
bool isExprKind(SyntaxKind Kind) {
return Kind >= SyntaxKind::First_Expr && Kind <= SyntaxKind::Last_Expr;
}
bool isPatternKind(SyntaxKind Kind) {
return Kind >= SyntaxKind::First_Pattern &&
Kind <= SyntaxKind::Last_Pattern;
}
bool isTokenKind(SyntaxKind Kind) {
return Kind == SyntaxKind::Token;
}
bool isUnknownKind(SyntaxKind Kind) {
return Kind == SyntaxKind::Unknown ||
Kind == SyntaxKind::UnknownDecl ||
Kind == SyntaxKind::UnknownExpr ||
Kind == SyntaxKind::UnknownStmt ||
Kind == SyntaxKind::UnknownType ||
Kind == SyntaxKind::UnknownPattern;
}
SyntaxKind getUnknownKind(SyntaxKind Kind) {
if (isExprKind(Kind))
return SyntaxKind::UnknownExpr;
if (isStmtKind(Kind))
return SyntaxKind::UnknownStmt;
if (isDeclKind(Kind))
return SyntaxKind::UnknownDecl;
if (isTypeKind(Kind))
return SyntaxKind::UnknownType;
if (isPatternKind(Kind))
return SyntaxKind::UnknownPattern;
return SyntaxKind::Unknown;
}
} // end namespace syntax
} // end namespace swift
llvm::raw_ostream &llvm::operator<<(llvm::raw_ostream &OS,
swift::syntax::SyntaxKind Kind) {
switch (Kind) {
% for node in SYNTAX_NODES:
case swift::syntax::SyntaxKind::${node.syntax_kind}:
OS << "${node.syntax_kind}";
break;
% end
case swift::syntax::SyntaxKind::Token:
OS << "TokenSyntax";
break;
case swift::syntax::SyntaxKind::Unknown:
OS << "UnknownSyntax";
break;
}
return OS;
}