Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/CommonTokenFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

using namespace antlr4;

const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
const std::unique_ptr<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT(new CommonTokenFactory);

CommonTokenFactory::CommonTokenFactory(bool copyText_) : copyText(copyText_) {
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/CommonTokenFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace antlr4 {
* This token factory does not explicitly copy token text when constructing
* tokens.</p>
*/
static const Ref<TokenFactory<CommonToken>> DEFAULT;
static const std::unique_ptr<TokenFactory<CommonToken>> DEFAULT;

protected:
/**
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ size_t Lexer::popMode() {
}


Ref<TokenFactory<CommonToken>> Lexer::getTokenFactory() {
TokenFactory<CommonToken>* Lexer::getTokenFactory() {
return _factory;
}

Expand Down Expand Up @@ -284,7 +284,7 @@ size_t Lexer::getNumberOfSyntaxErrors() {
void Lexer::InitializeInstanceFields() {
_syntaxErrors = 0;
token = nullptr;
_factory = CommonTokenFactory::DEFAULT;
_factory = CommonTokenFactory::DEFAULT.get();
tokenStartCharIndex = INVALID_INDEX;
tokenStartLine = 0;
tokenStartCharPositionInLine = 0;
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace antlr4 {

protected:
/// How to create token objects.
Ref<TokenFactory<CommonToken>> _factory;
TokenFactory<CommonToken> *_factory;

public:
/// The goal of all lexer rules/methods is to create a token object.
Expand Down Expand Up @@ -100,7 +100,7 @@ namespace antlr4 {
this->_factory = factory;
}

virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
virtual TokenFactory<CommonToken>* getTokenFactory() override;

/// Set the char stream and reset the lexer
virtual void setInputStream(IntStream *input) override;
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/ListTokenSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ std::string ListTokenSource::getSourceName() {
return "List";
}

Ref<TokenFactory<CommonToken>> ListTokenSource::getTokenFactory() {
TokenFactory<CommonToken>* ListTokenSource::getTokenFactory() {
return _factory;
}

void ListTokenSource::InitializeInstanceFields() {
i = 0;
_factory = CommonTokenFactory::DEFAULT;
_factory = CommonTokenFactory::DEFAULT.get();
}
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/ListTokenSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace antlr4 {
private:
/// This is the backing field for <seealso cref="#getTokenFactory"/> and
/// <seealso cref="setTokenFactory"/>.
Ref<TokenFactory<CommonToken>> _factory = CommonTokenFactory::DEFAULT;
TokenFactory<CommonToken> *_factory = CommonTokenFactory::DEFAULT.get();

public:
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace antlr4 {
this->_factory = factory;
}

virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
virtual TokenFactory<CommonToken>* getTokenFactory() override;

private:
void InitializeInstanceFields();
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ size_t Parser::getNumberOfSyntaxErrors() {
return _syntaxErrors;
}

Ref<TokenFactory<CommonToken>> Parser::getTokenFactory() {
TokenFactory<CommonToken>* Parser::getTokenFactory() {
return _input->getTokenSource()->getTokenFactory();
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace antlr4 {
/// <seealso cref= #notifyErrorListeners </seealso>
virtual size_t getNumberOfSyntaxErrors();

virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
virtual TokenFactory<CommonToken>* getTokenFactory() override;

/// <summary>
/// Tell our token source and error strategy about a new way to create tokens. </summary>
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/Recognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace antlr4 {

virtual void setInputStream(IntStream *input) = 0;

virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
virtual TokenFactory<CommonToken>* getTokenFactory() = 0;

template<typename T1>
void setTokenFactory(TokenFactory<T1> *input);
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/TokenSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace antlr4 {
/// creating <seealso cref="Token"/> objects from the input.
/// </summary>
/// <returns> The <seealso cref="TokenFactory"/> currently used by this token source. </returns>
virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
virtual TokenFactory<CommonToken>* getTokenFactory() = 0;
};

} // namespace antlr4