Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'override' in virtual methods of derived classes. #4790

Merged
merged 1 commit into from
Mar 9, 2025
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/ANTLRFileStream.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace antlr4 {

// Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM).
virtual void loadFromFile(const std::string &fileName);
virtual std::string getSourceName() const override;
std::string getSourceName() const override;

private:
std::string _fileName; // UTF-8 encoded file name.
Expand Down
20 changes: 10 additions & 10 deletions runtime/Cpp/runtime/src/ANTLRInputStream.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ namespace antlr4 {
/// when the object was created *except* the data array is not
/// touched.
virtual void reset();
virtual void consume() override;
virtual size_t LA(ssize_t i) override;
void consume() override;
size_t LA(ssize_t i) override;
virtual size_t LT(ssize_t i);

/// <summary>
/// Return the current input symbol index 0..n where n indicates the
/// last symbol has been read. The index is the index of char to
/// be returned from LA(1).
/// </summary>
virtual size_t index() override;
virtual size_t size() override;
size_t index() override;
size_t size() override;

/// <summary>
/// mark/release do nothing; we have entire buffer </summary>
virtual ssize_t mark() override;
virtual void release(ssize_t marker) override;
ssize_t mark() override;
void release(ssize_t marker) override;

/// <summary>
/// consume() ahead until p==index; can't just set p=index as we must
/// update line and charPositionInLine. If we seek backwards, just set p
/// </summary>
virtual void seek(size_t index) override;
virtual std::string getText(const misc::Interval &interval) override;
virtual std::string getSourceName() const override;
virtual std::string toString() const override;
void seek(size_t index) override;
std::string getText(const misc::Interval &interval) override;
std::string getSourceName() const override;
std::string toString() const override;

private:
void InitializeInstanceFields();
Expand Down
6 changes: 3 additions & 3 deletions runtime/Cpp/runtime/src/BailErrorStrategy.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ namespace antlr4 {
/// original <seealso cref="RecognitionException"/>.
/// </summary>
public:
virtual void recover(Parser *recognizer, std::exception_ptr e) override;
void recover(Parser *recognizer, std::exception_ptr e) override;

/// Make sure we don't attempt to recover inline; if the parser
/// successfully recovers, it won't throw an exception.
virtual Token* recoverInline(Parser *recognizer) override;
Token* recoverInline(Parser *recognizer) override;

/// <summary>
/// Make sure we don't attempt to recover from problems in subrules. </summary>
virtual void sync(Parser *recognizer) override;
void sync(Parser *recognizer) override;
};

} // namespace antlr4
8 changes: 4 additions & 4 deletions runtime/Cpp/runtime/src/BaseErrorListener.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ namespace antlr4 {
*/
class ANTLR4CPP_PUBLIC BaseErrorListener : public ANTLRErrorListener {

virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
const std::string &msg, std::exception_ptr e) override;

virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override;

virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override;

virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
size_t prediction, atn::ATNConfigSet *configs) override;
};

Expand Down
30 changes: 15 additions & 15 deletions runtime/Cpp/runtime/src/BufferedTokenStream.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ namespace antlr4 {

BufferedTokenStream& operator = (const BufferedTokenStream& other) = delete;

virtual TokenSource* getTokenSource() const override;
virtual size_t index() override;
virtual ssize_t mark() override;
TokenSource* getTokenSource() const override;
size_t index() override;
ssize_t mark() override;

virtual void release(ssize_t marker) override;
void release(ssize_t marker) override;
virtual void reset();
virtual void seek(size_t index) override;
void seek(size_t index) override;

virtual size_t size() override;
virtual void consume() override;
size_t size() override;
void consume() override;

virtual Token* get(size_t i) const override;
Token* get(size_t i) const override;

/// Get all tokens from start..stop inclusively.
virtual std::vector<Token *> get(size_t start, size_t stop);

virtual size_t LA(ssize_t i) override;
virtual Token* LT(ssize_t k) override;
size_t LA(ssize_t i) override;
Token* LT(ssize_t k) override;

/// Reset this token stream by setting its token source.
virtual void setTokenSource(TokenSource *tokenSource);
Expand Down Expand Up @@ -85,11 +85,11 @@ namespace antlr4 {
/// </summary>
virtual std::vector<Token *> getHiddenTokensToLeft(size_t tokenIndex);

virtual std::string getSourceName() const override;
virtual std::string getText() override;
virtual std::string getText(const misc::Interval &interval) override;
virtual std::string getText(RuleContext *ctx) override;
virtual std::string getText(Token *start, Token *stop) override;
std::string getSourceName() const override;
std::string getText() override;
std::string getText(const misc::Interval &interval) override;
std::string getText(RuleContext *ctx) override;
std::string getText(Token *start, Token *stop) override;

/// Get all tokens from lexer until EOF.
virtual void fill();
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/CharStream.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace antlr4 {
/// A source of characters for an ANTLR lexer.
class ANTLR4CPP_PUBLIC CharStream : public IntStream {
public:
virtual ~CharStream();
~CharStream() override;

/// This method returns the text for a range of characters within this input
/// stream. This method is guaranteed to not throw an exception if the
Expand Down
34 changes: 17 additions & 17 deletions runtime/Cpp/runtime/src/CommonToken.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace antlr4 {
*/
CommonToken(Token *oldToken);

virtual size_t getType() const override;
size_t getType() const override;

/**
* Explicitly set the text for this token. If {code text} is not
Expand All @@ -122,33 +122,33 @@ namespace antlr4 {
* should be obtained from the input along with the start and stop indexes
* of the token.
*/
virtual void setText(const std::string &text) override;
virtual std::string getText() const override;
void setText(const std::string &text) override;
std::string getText() const override;

virtual void setLine(size_t line) override;
virtual size_t getLine() const override;
void setLine(size_t line) override;
size_t getLine() const override;

virtual size_t getCharPositionInLine() const override;
virtual void setCharPositionInLine(size_t charPositionInLine) override;
size_t getCharPositionInLine() const override;
void setCharPositionInLine(size_t charPositionInLine) override;

virtual size_t getChannel() const override;
virtual void setChannel(size_t channel) override;
size_t getChannel() const override;
void setChannel(size_t channel) override;

virtual void setType(size_t type) override;
void setType(size_t type) override;

virtual size_t getStartIndex() const override;
size_t getStartIndex() const override;
virtual void setStartIndex(size_t start);

virtual size_t getStopIndex() const override;
size_t getStopIndex() const override;
virtual void setStopIndex(size_t stop);

virtual size_t getTokenIndex() const override;
virtual void setTokenIndex(size_t index) override;
size_t getTokenIndex() const override;
void setTokenIndex(size_t index) override;

virtual TokenSource *getTokenSource() const override;
virtual CharStream *getInputStream() const override;
TokenSource *getTokenSource() const override;
CharStream *getInputStream() const override;

virtual std::string toString() const override;
std::string toString() const override;

virtual std::string toString(Recognizer *r) const;
private:
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/CommonTokenFactory.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ namespace antlr4 {
*/
CommonTokenFactory();

virtual std::unique_ptr<CommonToken> create(std::pair<TokenSource*, CharStream*> source, size_t type,
std::unique_ptr<CommonToken> create(std::pair<TokenSource*, CharStream*> source, size_t type,
const std::string &text, size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) override;

virtual std::unique_ptr<CommonToken> create(size_t type, const std::string &text) override;
std::unique_ptr<CommonToken> create(size_t type, const std::string &text) override;
};

} // namespace antlr4
6 changes: 3 additions & 3 deletions runtime/Cpp/runtime/src/CommonTokenStream.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace antlr4 {
*/
CommonTokenStream(TokenSource *tokenSource, size_t channel);

virtual Token* LT(ssize_t k) override;
Token* LT(ssize_t k) override;

/// Count EOF just once.
virtual int getNumberOfOnChannelTokens();
Expand All @@ -70,9 +70,9 @@ namespace antlr4 {
*/
size_t channel;

virtual ssize_t adjustSeekIndex(size_t i) override;
ssize_t adjustSeekIndex(size_t i) override;

virtual Token* LB(size_t k) override;
Token* LB(size_t k) override;

};

Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/ConsoleErrorListener.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace antlr4 {
* line <em>line</em>:<em>charPositionInLine</em> <em>msg</em>
* </pre>
*/
virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine,
const std::string &msg, std::exception_ptr e) override;
};

Expand Down
16 changes: 8 additions & 8 deletions runtime/Cpp/runtime/src/DefaultErrorStrategy.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace antlr4 {
public:
DefaultErrorStrategy();
DefaultErrorStrategy(DefaultErrorStrategy const& other) = delete;
virtual ~DefaultErrorStrategy();
~DefaultErrorStrategy() override;

DefaultErrorStrategy& operator = (DefaultErrorStrategy const& other) = delete;

Expand Down Expand Up @@ -49,7 +49,7 @@ namespace antlr4 {
/// ensure that the handler is not in error recovery mode.
/// </summary>
public:
virtual void reset(Parser *recognizer) override;
void reset(Parser *recognizer) override;

/// <summary>
/// This method is called to enter error recovery mode when a recognition
Expand All @@ -63,7 +63,7 @@ namespace antlr4 {
/// {@inheritDoc}
/// </summary>
public:
virtual bool inErrorRecoveryMode(Parser *recognizer) override;
bool inErrorRecoveryMode(Parser *recognizer) override;

/// <summary>
/// This method is called to leave error recovery mode after recovering from
Expand All @@ -79,7 +79,7 @@ namespace antlr4 {
/// The default implementation simply calls <seealso cref="#endErrorCondition"/>.
/// </summary>
public:
virtual void reportMatch(Parser *recognizer) override;
void reportMatch(Parser *recognizer) override;

/// {@inheritDoc}
/// <p/>
Expand All @@ -98,7 +98,7 @@ namespace antlr4 {
/// <li>All other types: calls <seealso cref="Parser#notifyErrorListeners"/> to report
/// the exception</li>
/// </ul>
virtual void reportError(Parser *recognizer, const RecognitionException &e) override;
void reportError(Parser *recognizer, const RecognitionException &e) override;

/// <summary>
/// {@inheritDoc}
Expand All @@ -107,7 +107,7 @@ namespace antlr4 {
/// until we find one in the resynchronization set--loosely the set of tokens
/// that can follow the current rule.
/// </summary>
virtual void recover(Parser *recognizer, std::exception_ptr e) override;
void recover(Parser *recognizer, std::exception_ptr e) override;

/**
* The default implementation of {@link ANTLRErrorStrategy#sync} makes sure
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace antlr4 {
* some reason speed is suffering for you, you can turn off this
* functionality by simply overriding this method as a blank { }.</p>
*/
virtual void sync(Parser *recognizer) override;
void sync(Parser *recognizer) override;

/// <summary>
/// This is called by <seealso cref="#reportError"/> when the exception is a
Expand Down Expand Up @@ -278,7 +278,7 @@ namespace antlr4 {
* is in the set of tokens that can follow the {@code ')'} token reference
* in rule {@code atom}. It can assume that you forgot the {@code ')'}.
*/
virtual Token* recoverInline(Parser *recognizer) override;
Token* recoverInline(Parser *recognizer) override;

/// <summary>
/// This method implements the single-token insertion inline error recovery
Expand Down
6 changes: 3 additions & 3 deletions runtime/Cpp/runtime/src/DiagnosticErrorListener.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ namespace antlr4 {
/// {@code false} to report all ambiguities. </param>
DiagnosticErrorListener(bool exactOnly);

virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact,
const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override;

virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override;

virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
size_t prediction, atn::ATNConfigSet *configs) override;

protected:
Expand Down
Loading
Loading