From 59dc1cf438e454d536e63e8695de9e2b46c49e7e Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 4 Mar 2022 08:11:08 -0800 Subject: [PATCH] [C++] Use camel case name in generated lexers and parsers --- .../Cpp/runtime/src/tree/xpath/XPathLexer.cpp | 26 +++++----- .../v4/tool/templates/codegen/Cpp/Cpp.stg | 48 +++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp b/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp index ab477aa7a4..5c2e8568a1 100644 --- a/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +++ b/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp @@ -37,11 +37,11 @@ struct XPathLexerStaticData final { std::unique_ptr atn; }; -std::once_flag XPathLexer_onceFlag; -XPathLexerStaticData *XPathLexerstaticData = nullptr; +std::once_flag xpathLexerOnceFlag; +XPathLexerStaticData *xpathLexerStaticData = nullptr; -void XPathLexer_initialize() { - assert(XPathLexerstaticData == nullptr); +void xpathLexerInitialize() { + assert(xpathLexerStaticData == nullptr); auto staticData = std::make_unique( std::vector{ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar", "NameStartChar", @@ -117,14 +117,14 @@ void XPathLexer_initialize() { for (size_t i = 0; i < count; i++) { staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i); } - XPathLexerstaticData = staticData.release(); + xpathLexerStaticData = staticData.release(); } } XPathLexer::XPathLexer(CharStream *input) : Lexer(input) { XPathLexer::initialize(); - _interpreter = new atn::LexerATNSimulator(this, *XPathLexerstaticData->atn, XPathLexerstaticData->decisionToDFA, XPathLexerstaticData->sharedContextCache); + _interpreter = new atn::LexerATNSimulator(this, *xpathLexerStaticData->atn, xpathLexerStaticData->decisionToDFA, xpathLexerStaticData->sharedContextCache); } XPathLexer::~XPathLexer() { @@ -136,27 +136,27 @@ std::string XPathLexer::getGrammarFileName() const { } const std::vector& XPathLexer::getRuleNames() const { - return XPathLexerstaticData->ruleNames; + return xpathLexerStaticData->ruleNames; } const std::vector& XPathLexer::getChannelNames() const { - return XPathLexerstaticData->channelNames; + return xpathLexerStaticData->channelNames; } const std::vector& XPathLexer::getModeNames() const { - return XPathLexerstaticData->modeNames; + return xpathLexerStaticData->modeNames; } const dfa::Vocabulary& XPathLexer::getVocabulary() const { - return XPathLexerstaticData->vocabulary; + return xpathLexerStaticData->vocabulary; } const std::vector& XPathLexer::getSerializedATN() const { - return XPathLexerstaticData->serializedATN; + return xpathLexerStaticData->serializedATN; } const atn::ATN& XPathLexer::getATN() const { - return *XPathLexerstaticData->atn; + return *xpathLexerStaticData->atn; } void XPathLexer::action(RuleContext *context, size_t ruleIndex, size_t actionIndex) { @@ -183,5 +183,5 @@ void XPathLexer::IDAction(antlr4::RuleContext *context, size_t actionIndex) { } void XPathLexer::initialize() { - std::call_once(XPathLexer_onceFlag, XPathLexer_initialize); + std::call_once(xpathLexerOnceFlag, xpathLexerInitialize); } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg index 1c9b443ec1..a5068e9407 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg @@ -142,11 +142,11 @@ struct StaticData final { std::unique_ptr\ atn; }; -std::once_flag _onceFlag; -StaticData *staticData = nullptr; +std::once_flag LexerOnceFlag; +StaticData *LexerStaticData = nullptr; -void _initialize() { - assert(staticData == nullptr); +void LexerInitialize() { + assert(LexerStaticData == nullptr); auto staticData = std::make_unique\<StaticData>( std::vector\{ "}; separator = ", ", wrap, anchor> @@ -165,14 +165,14 @@ void _initialize() { } ); - staticData = staticData.release(); + LexerStaticData = staticData.release(); } } ::(CharStream *input) : (input) { ::initialize(); - _interpreter = new atn::LexerATNSimulator(this, *staticData->atn, staticData->decisionToDFA, staticData->sharedContextCache); + _interpreter = new atn::LexerATNSimulator(this, *LexerStaticData->atn, LexerStaticData->decisionToDFA, LexerStaticData->sharedContextCache); } ::~() { @@ -184,27 +184,27 @@ std::string ::getGrammarFileName() const { } const std::vector\& ::getRuleNames() const { - return staticData->ruleNames; + return LexerStaticData->ruleNames; } const std::vector\& ::getChannelNames() const { - return staticData->channelNames; + return LexerStaticData->channelNames; } const std::vector\& ::getModeNames() const { - return staticData->modeNames; + return LexerStaticData->modeNames; } const dfa::Vocabulary& ::getVocabulary() const { - return staticData->vocabulary; + return LexerStaticData->vocabulary; } const std::vector\& ::getSerializedATN() const { - return staticData->serializedATN; + return LexerStaticData->serializedATN; } const atn::ATN& ::getATN() const { - return *staticData->atn; + return *LexerStaticData->atn; } @@ -237,7 +237,7 @@ bool ::sempred(RuleContext *context, size_t ruleIndex, size_t predic void ::initialize() { - std::call_once(_onceFlag, _initialize); + std::call_once(LexerOnceFlag, LexerInitialize); } >> @@ -360,11 +360,11 @@ struct StaticData final { std::unique_ptr\ atn; }; -std::once_flag _onceFlag; -StaticData *staticData = nullptr; +std::once_flag ParserOnceFlag; +StaticData *ParserStaticData = nullptr; -void _initialize() { - assert(staticData == nullptr); +void ParserInitialize() { + assert(ParserStaticData == nullptr); auto staticData = std::make_unique\<StaticData>( std::vector\{ "}; separator = ", ", wrap, anchor> @@ -377,14 +377,14 @@ void _initialize() { } ); - staticData = staticData.release(); + ParserStaticData = staticData.release(); } } ::(TokenStream *input) : (input) { ::initialize(); - _interpreter = new atn::ParserATNSimulator(this, *staticData->atn, staticData->decisionToDFA, staticData->sharedContextCache); + _interpreter = new atn::ParserATNSimulator(this, *ParserStaticData->atn, ParserStaticData->decisionToDFA, ParserStaticData->sharedContextCache); } ::~() { @@ -392,7 +392,7 @@ void _initialize() { } const atn::ATN& ::getATN() const { - return *staticData->atn; + return *ParserStaticData->atn; } std::string ::getGrammarFileName() const { @@ -400,15 +400,15 @@ std::string ::getGrammarFileName() const { } const std::vector\& ::getRuleNames() const { - return staticData->ruleNames; + return ParserStaticData->ruleNames; } const dfa::Vocabulary& ::getVocabulary() const { - return staticData->vocabulary; + return ParserStaticData->vocabulary; } const std::vector\& ::getSerializedATN() const { - return staticData->serializedATN; + return ParserStaticData->serializedATN; } @@ -430,7 +430,7 @@ bool ::sempred(RuleContext *context, size_t ruleIndex, size_t predi void ::initialize() { - std::call_once(_onceFlag, _initialize); + std::call_once(ParserOnceFlag, ParserInitialize); } >>