-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathReservedKeywords.cs
33 lines (29 loc) · 1.33 KB
/
ReservedKeywords.cs
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
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
namespace Meadow.SolCodeGen
{
public static class ReservedKeywords
{
static readonly ImmutableHashSet<string> RESERVED = new HashSet<string>(new[]
{
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class",
"const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event",
"explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if",
"implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new",
"null", "object", "operator", "out", "override", "params", "private", "protected", "public",
"readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static",
"string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong",
"unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
}).ToImmutableHashSet();
public static string EscapeIdentifier(string name)
{
if (RESERVED.Contains(name))
{
return "@" + name;
}
return name;
}
}
}