forked from jasder/antlr
A few final touches to make runtime tests passing.
This commit is contained in:
parent
e68cdc3c0e
commit
dd48c0fbd5
|
@ -17,8 +17,7 @@ $ git push upstream :refs/tags/4.5.2
|
|||
Edit the repository looking for 4.5 or whatever and update it. Bump version in the following files:
|
||||
|
||||
* runtime/Cpp/VERSION
|
||||
* runtime/Cpp/runtime/antlr4cpp.vcxproj
|
||||
* runtime/Cpp/runtime/antlrcpp.xcodeproj
|
||||
* runtime/Cpp/RuntimeMetaData.cpp
|
||||
* runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
|
||||
* runtime/Python2/setup.py
|
||||
* runtime/Python2/src/antlr4/Recognizer.py
|
||||
|
|
|
@ -240,7 +240,7 @@ protected:
|
|||
};
|
||||
|
||||
public:
|
||||
virtual Token* nextToken() override {
|
||||
virtual std::unique_ptr\<Token> nextToken() override {
|
||||
if (dynamic_cast\<PositionAdjustingLexerATNSimulator *>(_interpreter) == nullptr) {
|
||||
delete _interpreter;
|
||||
_interpreter = new PositionAdjustingLexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
||||
|
@ -305,7 +305,7 @@ BasicListener(X) ::= <<
|
|||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void visitTerminal(Ref\<tree::TerminalNode> node) override {
|
||||
virtual void visitTerminal(Ref\<tree::TerminalNode> const& node) override {
|
||||
std::cout \<\< node->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4683,7 +4683,7 @@ public class TestLexerExec extends BaseCppTest {
|
|||
public void testPositionAdjustingLexer() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(2721);
|
||||
StringBuilder grammarBuilder = new StringBuilder(2737);
|
||||
grammarBuilder.append("lexer grammar PositionAdjustingLexer;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@members {\n");
|
||||
|
@ -4705,7 +4705,7 @@ public class TestLexerExec extends BaseCppTest {
|
|||
grammarBuilder.append(" };\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual Token* nextToken() override {\n");
|
||||
grammarBuilder.append(" virtual std::unique_ptr<Token> nextToken() override {\n");
|
||||
grammarBuilder.append(" if (dynamic_cast<PositionAdjustingLexerATNSimulator *>(_interpreter) == nullptr) {\n");
|
||||
grammarBuilder.append(" delete _interpreter;\n");
|
||||
grammarBuilder.append(" _interpreter = new PositionAdjustingLexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);\n");
|
||||
|
|
|
@ -13,13 +13,13 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(484);
|
||||
StringBuilder grammarBuilder = new StringBuilder(491);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void visitTerminal(Ref<tree::TerminalNode> node) override {\n");
|
||||
grammarBuilder.append(" virtual void visitTerminal(Ref<tree::TerminalNode> const& node) override {\n");
|
||||
grammarBuilder.append(" std::cout << node->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
|
|
|
@ -126,11 +126,12 @@ size_t BufferedTokenStream::fetch(size_t n) {
|
|||
}
|
||||
|
||||
_tokens.push_back(std::move(t));
|
||||
++i;
|
||||
|
||||
if (_tokens.back()->getType() == Token::EOF) {
|
||||
_fetchedEOF = true;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace antlr4 {
|
|||
virtual CharStream* getInputStream() override;
|
||||
|
||||
/// By default does not support multiple emits per nextToken invocation
|
||||
/// for efficiency reasons. Subclass and override this method, nextToken,
|
||||
/// for efficiency reasons. Subclasses can override this method, nextToken,
|
||||
/// and getToken (to push tokens into a list and pull from that list
|
||||
/// rather than a single variable as this implementation does).
|
||||
virtual void emit(std::unique_ptr<Token> token);
|
||||
|
|
|
@ -544,12 +544,12 @@ std::vector<std::string> Parser::getRuleInvocationStack() {
|
|||
}
|
||||
|
||||
std::vector<std::string> Parser::getRuleInvocationStack(Ref<RuleContext> const& p) {
|
||||
std::vector<std::string> ruleNames = getRuleNames();
|
||||
std::vector<std::string> stack = std::vector<std::string>();
|
||||
std::vector<std::string> const& ruleNames = getRuleNames();
|
||||
std::vector<std::string> stack;
|
||||
RuleContext *run = p.get();
|
||||
while (run != nullptr) {
|
||||
// compute what follows who invoked us
|
||||
ssize_t ruleIndex = p->getRuleIndex();
|
||||
ssize_t ruleIndex = run->getRuleIndex();
|
||||
if (ruleIndex < 0) {
|
||||
stack.push_back("n/a");
|
||||
} else {
|
||||
|
@ -610,7 +610,7 @@ Ref<atn::ParseInfo> Parser::getParseInfo() const {
|
|||
|
||||
void Parser::setProfile(bool profile) {
|
||||
atn::ParserATNSimulator *interp = getInterpreter<atn::ProfilingATNSimulator>();
|
||||
atn::PredictionMode saveMode = interp->getPredictionMode();
|
||||
atn::PredictionMode saveMode = interp != nullptr ? interp->getPredictionMode() : atn::PredictionMode::LL;
|
||||
if (profile) {
|
||||
if (!is<atn::ProfilingATNSimulator *>(interp)) {
|
||||
setInterpreter(new atn::ProfilingATNSimulator(this)); /* mem-check: replacing existing interpreter which gets deleted. */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
using namespace antlr4;
|
||||
|
||||
const std::string RuntimeMetaData::VERSION = "4.5.3";
|
||||
const std::string RuntimeMetaData::VERSION = "4.5.4";
|
||||
|
||||
std::string RuntimeMetaData::getRuntimeVersion() {
|
||||
return VERSION;
|
||||
|
|
Loading…
Reference in New Issue