forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSharpKeywordDetector.cs
More file actions
102 lines (99 loc) · 4.29 KB
/
Copy pathCSharpKeywordDetector.cs
File metadata and controls
102 lines (99 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Web.Razor.Tokenizer.Symbols;
namespace System.Web.Razor.Tokenizer
{
internal static class CSharpKeywordDetector
{
private static readonly Dictionary<string, CSharpKeyword> _keywords = new Dictionary<string, CSharpKeyword>(StringComparer.Ordinal)
{
{ "abstract", CSharpKeyword.Abstract },
{ "byte", CSharpKeyword.Byte },
{ "class", CSharpKeyword.Class },
{ "delegate", CSharpKeyword.Delegate },
{ "event", CSharpKeyword.Event },
{ "fixed", CSharpKeyword.Fixed },
{ "if", CSharpKeyword.If },
{ "internal", CSharpKeyword.Internal },
{ "new", CSharpKeyword.New },
{ "override", CSharpKeyword.Override },
{ "readonly", CSharpKeyword.Readonly },
{ "short", CSharpKeyword.Short },
{ "struct", CSharpKeyword.Struct },
{ "try", CSharpKeyword.Try },
{ "unsafe", CSharpKeyword.Unsafe },
{ "volatile", CSharpKeyword.Volatile },
{ "as", CSharpKeyword.As },
{ "do", CSharpKeyword.Do },
{ "is", CSharpKeyword.Is },
{ "params", CSharpKeyword.Params },
{ "ref", CSharpKeyword.Ref },
{ "switch", CSharpKeyword.Switch },
{ "ushort", CSharpKeyword.Ushort },
{ "while", CSharpKeyword.While },
{ "case", CSharpKeyword.Case },
{ "const", CSharpKeyword.Const },
{ "explicit", CSharpKeyword.Explicit },
{ "float", CSharpKeyword.Float },
{ "null", CSharpKeyword.Null },
{ "sizeof", CSharpKeyword.Sizeof },
{ "typeof", CSharpKeyword.Typeof },
{ "implicit", CSharpKeyword.Implicit },
{ "private", CSharpKeyword.Private },
{ "this", CSharpKeyword.This },
{ "using", CSharpKeyword.Using },
{ "extern", CSharpKeyword.Extern },
{ "return", CSharpKeyword.Return },
{ "stackalloc", CSharpKeyword.Stackalloc },
{ "uint", CSharpKeyword.Uint },
{ "base", CSharpKeyword.Base },
{ "catch", CSharpKeyword.Catch },
{ "continue", CSharpKeyword.Continue },
{ "double", CSharpKeyword.Double },
{ "for", CSharpKeyword.For },
{ "in", CSharpKeyword.In },
{ "lock", CSharpKeyword.Lock },
{ "object", CSharpKeyword.Object },
{ "protected", CSharpKeyword.Protected },
{ "static", CSharpKeyword.Static },
{ "false", CSharpKeyword.False },
{ "public", CSharpKeyword.Public },
{ "sbyte", CSharpKeyword.Sbyte },
{ "throw", CSharpKeyword.Throw },
{ "virtual", CSharpKeyword.Virtual },
{ "decimal", CSharpKeyword.Decimal },
{ "else", CSharpKeyword.Else },
{ "operator", CSharpKeyword.Operator },
{ "string", CSharpKeyword.String },
{ "ulong", CSharpKeyword.Ulong },
{ "bool", CSharpKeyword.Bool },
{ "char", CSharpKeyword.Char },
{ "default", CSharpKeyword.Default },
{ "foreach", CSharpKeyword.Foreach },
{ "long", CSharpKeyword.Long },
{ "void", CSharpKeyword.Void },
{ "enum", CSharpKeyword.Enum },
{ "finally", CSharpKeyword.Finally },
{ "int", CSharpKeyword.Int },
{ "out", CSharpKeyword.Out },
{ "sealed", CSharpKeyword.Sealed },
{ "true", CSharpKeyword.True },
{ "goto", CSharpKeyword.Goto },
{ "unchecked", CSharpKeyword.Unchecked },
{ "interface", CSharpKeyword.Interface },
{ "break", CSharpKeyword.Break },
{ "checked", CSharpKeyword.Checked },
{ "namespace", CSharpKeyword.Namespace }
};
public static CSharpKeyword? SymbolTypeForIdentifier(string id)
{
CSharpKeyword type;
if (!_keywords.TryGetValue(id, out type))
{
return null;
}
return type;
}
}
}