Merge pull request #2631 from mike-lischke/master

C++ code cleanup
This commit is contained in:
Terence Parr 2019-10-11 13:26:12 -07:00 committed by GitHub
commit ad2bd05285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 27 additions and 31 deletions

View File

@ -14,7 +14,7 @@ given input file during build.
The following table lists the parameters that can be used with the function:
Argument# | Required | Default | Use
----------|-----------|---------|--
----------|-----------|---------|---
0 | Yes | n/a | Unique target name. It is used to generate CMake Variables to reference the various outputs of the generation
1 | Yes | n/a | Input file containing the lexer/parser definition
2 | Yes | n/a | Type of Rules contained in the input: LEXER, PARSER or BOTH
@ -24,10 +24,10 @@ Argument# | Required | Default | Use
7 | No | none | Additional files on which the input depends
8 | No | none | Library path to use during generation
The `ANTLR4_JAR_LOCATION` CMake variable must be set to the location where the `antlr-4*-complete.jar` generator is located.
You can download the file from [here](http://www.antlr.org/download.html).
The `ANTLR4_JAR_LOCATION` CMake variable must be set to the location where the `antlr-4*-complete.jar` generator is located. You can download the file from [here](http://www.antlr.org/download.html).
Additional option to the ANTLR4 generator can be passed in the `ANTLR4_GENERATED_OPTIONS` variable
Additional options to the ANTLR4 generator can be passed in the `ANTLR4_GENERATED_OPTIONS` variable. Add the installation prefix of `antlr4-runtime` to `CMAKE_PREFIX_PATH` or set
`antlr4-runtime_DIR` to a directory containing the files.
The following CMake variables are available following a call to `antlr4_generate`

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -24,7 +24,7 @@ namespace antlr4 {
/// Implementations of this interface report syntax errors by calling
/// <seealso cref="Parser#notifyErrorListeners"/>.
/// <p/>
/// TO_DO: what to do about lexers
/// TODO: what to do about lexers
/// </summary>
class ANTLR4CPP_PUBLIC ANTLRErrorStrategy {
public:

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -273,7 +273,7 @@ std::string Lexer::getErrorDisplay(const std::string &s) {
}
void Lexer::recover(RecognitionException * /*re*/) {
// TO_DO: Do we lose character or line position information?
// TODO: Do we lose character or line position information?
_input->consume();
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -464,7 +464,7 @@ bool Parser::precpred(RuleContext * /*localctx*/, int precedence) {
}
bool Parser::inContext(const std::string &/*context*/) {
// TO_DO: useful in parser?
// TODO: useful in parser?
return false;
}

View File

@ -16,7 +16,6 @@ namespace dfa {
public:
Vocabulary(Vocabulary const&) = default;
virtual ~Vocabulary();
Vocabulary& operator=(Vocabulary const&) = default;
/// Gets an empty <seealso cref="Vocabulary"/> instance.
///

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -57,7 +57,7 @@ namespace atn {
* <p>
* closure() tracks the depth of how far we dip into the outer context:
* depth > 0. Note that it may not be totally accurate depth since I
* don't ever decrement. TO_DO: make it a boolean then</p>
* don't ever decrement. TODO: make it a boolean then</p>
*
* <p>
* For memory efficiency, the {@link #isPrecedenceFilterSuppressed} method
@ -87,7 +87,6 @@ namespace atn {
ATNConfig(ATNConfig const&) = default;
virtual ~ATNConfig();
ATNConfig& operator=(ATNConfig const&) = default;
virtual size_t hashCode() const;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -18,8 +18,8 @@ namespace atn {
/// Track the elements as they are added to the set; supports get(i)
std::vector<Ref<ATNConfig>> configs;
// TO_DO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
// TO_DO: can we track conflicts as they are added to save scanning configs later?
// TODO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
// TODO: can we track conflicts as they are added to save scanning configs later?
size_t uniqueAlt;
/** Currently this is only used when we detect SLL conflict; this does

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -10,7 +10,7 @@
namespace antlr4 {
namespace atn {
/// TO_DO: make all transitions sets? no, should remove set edges.
/// TODO: make all transitions sets? no, should remove set edges.
class ANTLR4CPP_PUBLIC AtomTransition final : public Transition {
public:
/// The token type or character value; or, signifies special label.

View File

@ -422,7 +422,7 @@ Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const
if (config->context == nullptr|| config->context->hasEmptyPath()) {
// execute actions anywhere in the start rule for a token.
//
// TO_DO: if the entry rule is invoked recursively, some
// TODO: if the entry rule is invoked recursively, some
// actions may be executed during the recursive call. The
// problem can appear when hasEmptyPath() is true but
// isEmpty() is false. In this case, the config needs to be

View File

@ -922,7 +922,7 @@ void ParserATNSimulator::closure_(Ref<ATNConfig> const& config, ATNConfigSet *co
}
}
configs->dipsIntoOuterContext = true; // TO_DO: can remove? only care when we add to set per middle of this method
configs->dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
assert(newDepth > INT_MIN);
newDepth--;

View File

@ -760,7 +760,7 @@ namespace atn {
virtual bool evalSemanticContext(Ref<SemanticContext> const& pred, ParserRuleContext *parserCallStack,
size_t alt, bool fullCtx);
/* TO_DO: If we are doing predicates, there is no point in pursuing
/* TODO: If we are doing predicates, there is no point in pursuing
closure operations if we reach a DFA state that uniquely predicts
alternative. We will not be caching that DFA state and it is a
waste to pursue the closure. Might have to advance when we do

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -11,7 +11,7 @@
namespace antlr4 {
namespace atn {
/// TO_DO: this is old comment:
/// TODO: this is old comment:
/// A tree of semantic predicates from the grammar AST if label==SEMPRED.
/// In the ATN, labels will always be exactly one predicate, but the DFA
/// may have to combine a bunch of them as it collects predicates from

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -335,7 +335,7 @@ Ref<PredictionContext> PredictionContext::mergeArrays(const Ref<ArrayPredictionC
Ref<ArrayPredictionContext> M = std::make_shared<ArrayPredictionContext>(mergedParents, mergedReturnStates);
// if we created same array as a or b, return that instead
// TO_DO: track whether this is possible above during merge sort for speed
// TODO: track whether this is possible above during merge sort for speed
if (*M == *a) {
if (mergeCache != nullptr) {
mergeCache->put(a, b, a);

View File

@ -99,7 +99,7 @@ std::unique_ptr<ATNConfigSet> ProfilingATNSimulator::computeReachSet(ATNConfigSe
_decisions[_currentDecision].LL_ATNTransitions++; // count computation even if error
if (reachConfigs != nullptr) {
} else { // no reach on current lookahead symbol. ERROR.
// TO_DO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule()
// TODO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule()
_decisions[_currentDecision].errors.push_back(ErrorInfo(_currentDecision, closure, _input, _startIndex, _llStopIndex, true));
}
} else {

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -45,7 +45,6 @@ namespace pattern {
const std::map<std::string, std::vector<ParseTree *>> &labels, ParseTree *mismatchedNode);
ParseTreeMatch(ParseTreeMatch const&) = default;
virtual ~ParseTreeMatch();
ParseTreeMatch& operator=(ParseTreeMatch const&) = default;
/// <summary>
/// Get the last node associated with a specific {@code label}.

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
@ -30,7 +30,6 @@ namespace pattern {
ParseTree *patternTree);
ParseTreePattern(ParseTreePattern const&) = default;
virtual ~ParseTreePattern();
ParseTreePattern& operator=(ParseTreePattern const&) = default;
/// <summary>
/// Match a specific parse tree against this tree pattern.