Merge branch 'master' into master
This commit is contained in:
commit
168882d942
|
@ -251,4 +251,7 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2020/05/25, graknol, Sindre van der Linden, graknol@gmail.com
|
||||
2020/05/31, d-markey, David Markey, dmarkey@free.fr
|
||||
2020/06/02, cohomology, Kilian Kilger, kkilger AT gmail.com
|
||||
2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com
|
||||
2020/06/04, IohannRabeson, Iohann Rabeson, iotaka6@gmail.com
|
||||
2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com
|
||||
2020/08/22, stevenjohnstone, Steven Johnstone, steven.james.johnstone@gmail.com
|
||||
2020/09/06, ArthurSonzogni, Sonzogni Arthur, arthursonzogni@gmail.com
|
|
@ -65,7 +65,7 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
tree::ParseTree *tree = parser.key();
|
||||
TreeShapeListener listener;
|
||||
tree::ParseTreeWalker::DEFAULT->walk(&listener, tree);
|
||||
tree::ParseTreeWalker::DEFAULT.walk(&listener, tree);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ if(NOT WITH_DEMO)
|
|||
FORCE)
|
||||
endif(NOT WITH_DEMO)
|
||||
|
||||
option(WITH_LIBCXX "Building with clang++ and libc++(in Linux). To enable with: -DWITH_LIBCXX=On" On)
|
||||
option(WITH_LIBCXX "Building with clang++ and libc++(in Linux). To enable with: -DWITH_LIBCXX=On" Off)
|
||||
option(WITH_STATIC_CRT "(Visual C++) Enable to statically link CRT, which avoids requiring users to install the redistribution package.
|
||||
To disable with: -DWITH_STATIC_CRT=Off" On)
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -201,6 +202,7 @@
|
|||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -220,6 +222,7 @@
|
|||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -239,6 +242,7 @@
|
|||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -259,6 +263,7 @@
|
|||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -281,6 +286,7 @@
|
|||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -303,6 +309,7 @@
|
|||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -325,6 +332,7 @@
|
|||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
|
@ -17,7 +17,11 @@ using namespace antlrcpp;
|
|||
|
||||
using misc::Interval;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
ANTLRInputStream::ANTLRInputStream(std::string_view input) {
|
||||
#else
|
||||
ANTLRInputStream::ANTLRInputStream(const std::string &input) {
|
||||
#endif
|
||||
InitializeInstanceFields();
|
||||
load(input);
|
||||
}
|
||||
|
@ -31,6 +35,16 @@ ANTLRInputStream::ANTLRInputStream(std::istream &stream) {
|
|||
load(stream);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
void ANTLRInputStream::load(std::string_view input) {
|
||||
// Remove the UTF-8 BOM if present.
|
||||
constexpr std::string_view bom = "\xef\xbb\xbf";
|
||||
if (input.compare(0, 3, bom) == 0)
|
||||
input.remove_prefix(3);
|
||||
_data = antlrcpp::utf8_to_utf32(input.data(), input.data() + input.size());
|
||||
p = 0;
|
||||
}
|
||||
#else
|
||||
void ANTLRInputStream::load(const std::string &input) {
|
||||
// Remove the UTF-8 BOM if present.
|
||||
const char bom[4] = "\xef\xbb\xbf";
|
||||
|
@ -40,6 +54,7 @@ void ANTLRInputStream::load(const std::string &input) {
|
|||
_data = antlrcpp::utf8_to_utf32(input.data(), input.data() + input.size());
|
||||
p = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ANTLRInputStream::load(std::istream &stream) {
|
||||
if (!stream.good() || stream.eof()) // No fail, bad or EOF.
|
||||
|
|
|
@ -25,11 +25,19 @@ namespace antlr4 {
|
|||
/// What is name or source of this char stream?
|
||||
std::string name;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
ANTLRInputStream(std::string_view input = "");
|
||||
#else
|
||||
ANTLRInputStream(const std::string &input = "");
|
||||
#endif
|
||||
ANTLRInputStream(const char data_[], size_t numberOfActualCharsInArray);
|
||||
ANTLRInputStream(std::istream &stream);
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
virtual void load(std::string_view input);
|
||||
#else
|
||||
virtual void load(const std::string &input);
|
||||
#endif
|
||||
virtual void load(std::istream &stream);
|
||||
|
||||
/// Reset the stream so that it's in the same state it was
|
||||
|
|
|
@ -22,8 +22,7 @@ Vocabulary::Vocabulary(const std::vector<std::string> &literalNames,
|
|||
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
|
||||
}
|
||||
|
||||
Vocabulary::~Vocabulary() {
|
||||
}
|
||||
Vocabulary::~Vocabulary() = default;
|
||||
|
||||
Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
|
||||
if (tokenNames.empty()) {
|
||||
|
@ -34,25 +33,18 @@ Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames
|
|||
std::vector<std::string> symbolicNames = tokenNames;
|
||||
std::locale locale;
|
||||
for (size_t i = 0; i < tokenNames.size(); i++) {
|
||||
std::string tokenName = tokenNames[i];
|
||||
if (tokenName == "") {
|
||||
const std::string& tokenName = tokenNames[i];
|
||||
if (tokenName.empty()) {
|
||||
continue;
|
||||
} else if (tokenName.front() == '\'') {
|
||||
symbolicNames[i].clear();
|
||||
} else if (std::isupper(tokenName.front(), locale)) {
|
||||
literalNames[i].clear();
|
||||
} else {
|
||||
// wasn't a literal or symbolic name
|
||||
literalNames[i].clear();
|
||||
symbolicNames[i].clear();
|
||||
}
|
||||
|
||||
if (!tokenName.empty()) {
|
||||
char firstChar = tokenName[0];
|
||||
if (firstChar == '\'') {
|
||||
symbolicNames[i] = "";
|
||||
continue;
|
||||
} else if (std::isupper(firstChar, locale)) {
|
||||
literalNames[i] = "";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// wasn't a literal or symbolic name
|
||||
literalNames[i] = "";
|
||||
symbolicNames[i] = "";
|
||||
}
|
||||
|
||||
return Vocabulary(literalNames, symbolicNames, tokenNames);
|
||||
|
|
|
@ -14,9 +14,6 @@ namespace dfa {
|
|||
/// interface.
|
||||
class ANTLR4CPP_PUBLIC Vocabulary {
|
||||
public:
|
||||
Vocabulary(Vocabulary const&) = default;
|
||||
virtual ~Vocabulary();
|
||||
|
||||
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
||||
///
|
||||
/// <para>
|
||||
|
@ -25,7 +22,9 @@ namespace dfa {
|
|||
/// except <seealso cref="Token#EOF"/>.</para>
|
||||
static const Vocabulary EMPTY_VOCABULARY;
|
||||
|
||||
Vocabulary() {}
|
||||
Vocabulary() = default;
|
||||
Vocabulary(Vocabulary const&) = default;
|
||||
virtual ~Vocabulary();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
};
|
||||
<endif>
|
||||
|
||||
<lexer.name>(antlr4::CharStream *input);
|
||||
explicit <lexer.name>(antlr4::CharStream *input);
|
||||
~<lexer.name>();
|
||||
|
||||
<namedActions.members>
|
||||
|
@ -192,23 +192,23 @@ atn::ATN <lexer.name>::_atn;
|
|||
std::vector\<uint16_t> <lexer.name>::_serializedATN;
|
||||
|
||||
std::vector\<std::string> <lexer.name>::_ruleNames = {
|
||||
<lexer.ruleNames: {r | u8"<r>"}; separator = ", ", wrap, anchor>
|
||||
<lexer.ruleNames: {r | "<r>"}; separator = ", ", wrap, anchor>
|
||||
};
|
||||
|
||||
std::vector\<std::string> <lexer.name>::_channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"<if (lexer.channels)>, <lexer.channels: {c | u8"<c>"}; separator = ", ", wrap, anchor><endif>
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"<if (lexer.channels)>, <lexer.channels: {c | "<c>"}; separator = ", ", wrap, anchor><endif>
|
||||
};
|
||||
|
||||
std::vector\<std::string> <lexer.name>::_modeNames = {
|
||||
<lexer.modes: {m | u8"<m>"}; separator = ", ", wrap, anchor>
|
||||
<lexer.modes: {m | "<m>"}; separator = ", ", wrap, anchor>
|
||||
};
|
||||
|
||||
std::vector\<std::string> <lexer.name>::_literalNames = {
|
||||
<lexer.literalNames: {t | u8<t>}; null = "\"\"", separator = ", ", wrap, anchor>
|
||||
<lexer.literalNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
|
||||
};
|
||||
|
||||
std::vector\<std::string> <lexer.name>::_symbolicNames = {
|
||||
<lexer.symbolicNames: {t | u8<t>}; null = "\"\"", separator = ", ", wrap, anchor>
|
||||
<lexer.symbolicNames: {t | <t>}; null = "\"\"", separator = ", ", wrap, anchor>
|
||||
};
|
||||
|
||||
dfa::Vocabulary <lexer.name>::_vocabulary(_literalNames, _symbolicNames);
|
||||
|
@ -290,7 +290,7 @@ public:
|
|||
};
|
||||
<endif>
|
||||
|
||||
<parser.name>(antlr4::TokenStream *input);
|
||||
explicit <parser.name>(antlr4::TokenStream *input);
|
||||
~<parser.name>();
|
||||
|
||||
virtual std::string getGrammarFileName() const override;
|
||||
|
@ -710,6 +710,8 @@ switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <cho
|
|||
break;
|
||||
\}
|
||||
}; separator="\n">
|
||||
default:
|
||||
break;
|
||||
}
|
||||
>>
|
||||
|
||||
|
@ -724,6 +726,8 @@ switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <cho
|
|||
break;
|
||||
\}
|
||||
}; separator = "\n">
|
||||
default:
|
||||
break;
|
||||
}
|
||||
>>
|
||||
|
||||
|
|
Loading…
Reference in New Issue