UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

152 lines (151 loc) 3.43 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { Target } from "../Target.js"; class CppTarget extends Target { static { __name(this, "CppTarget"); } static targetCharValueEscape = /* @__PURE__ */ new Map([ // https://stackoverflow.com/a/10220539/1046374 [7, "a"], [8, "b"], [11, "v"], [27, "e"], [63, "?"] ]); static reservedWords = /* @__PURE__ */ new Set([ "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "class", "compl", "concept", "const", "constexpr", "const_cast", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "NULL", "operator", "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", "requires", "return", "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "template", "this", "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq", "rule", "parserRule" ]); getTargetCharValueEscape() { return new Map([...Target.defaultCharValueEscape, ...CppTarget.targetCharValueEscape]); } needsHeader() { return true; } getRecognizerFileName(header) { const extST = this.templates.getInstanceOf(header ? "headerFileExtension" : "codeFileExtension"); const recognizerName = this.gen.g.getRecognizerName(); return recognizerName + extST.render(); } getListenerFileName(header) { const extST = this.templates.getInstanceOf(header ? "headerFileExtension" : "codeFileExtension"); const listenerName = this.gen.g.name + "Listener"; return listenerName + extST.render(); } getVisitorFileName(header) { const extST = this.templates.getInstanceOf(header ? "headerFileExtension" : "codeFileExtension"); const listenerName = this.gen.g.name + "Visitor"; return listenerName + extST.render(); } getBaseListenerFileName(header) { const extST = this.templates.getInstanceOf(header ? "headerFileExtension" : "codeFileExtension"); const listenerName = this.gen.g.name + "BaseListener"; return listenerName + extST.render(); } getBaseVisitorFileName(header) { const extST = this.templates.getInstanceOf(header ? "headerFileExtension" : "codeFileExtension"); const listenerName = this.gen.g.name + "BaseVisitor"; return listenerName + extST.render(); } get reservedWords() { return CppTarget.reservedWords; } shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(codePoint) { if (codePoint === 63) { return true; } else { return super.shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(codePoint); } } } export { CppTarget };