antlr-ng
Version:
Next generation ANTLR Tool
117 lines (116 loc) • 2.04 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
import { format } from "../../support/helpers.js";
import { Target } from "../Target.js";
class CSharpTarget extends Target {
static {
__name(this, "CSharpTarget");
}
static reservedWords = /* @__PURE__ */ new Set([
"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",
"values",
"void",
"volatile",
"while"
]);
static targetCharValueEscape = /* @__PURE__ */ new Map([
// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#string-escape-sequences
[0, "0"],
[7, "a"],
[8, "b"],
[11, "v"],
[27, "e"],
[63, "?"]
]);
getTargetCharValueEscape() {
return new Map([...Target.defaultCharValueEscape, ...CSharpTarget.targetCharValueEscape]);
}
isATNSerializedAsInts() {
return true;
}
get reservedWords() {
return CSharpTarget.reservedWords;
}
escapeWord(word) {
return "@" + word;
}
escapeChar(v) {
return format("\\x%X", v);
}
}
export {
CSharpTarget
};