Merge pull request #1679 from Thomasb81/Issue_1666

Issue 1666
This commit is contained in:
Terence Parr 2017-02-22 13:14:37 -08:00 committed by GitHub
commit ce09abb480
3 changed files with 8 additions and 5 deletions

View File

@ -135,4 +135,6 @@ YYYY/MM/DD, github id, Full name, email
2017/01/18, mshockwave, Bekket McClane, yihshyng223@gmail.com 2017/01/18, mshockwave, Bekket McClane, yihshyng223@gmail.com
2017/02/10, lionelplessis, Lionel Plessis, lionelplessis@users.noreply.github.com 2017/02/10, lionelplessis, Lionel Plessis, lionelplessis@users.noreply.github.com
2017/02/14, lecode-official, David Neumann, david.neumann@lecode.de 2017/02/14, lecode-official, David Neumann, david.neumann@lecode.de
2017/02/14, xied75, Dong Xie, xied75@gmail.com 2017/02/14, xied75, Dong Xie, xied75@gmail.com
2017/02/20, Thomasb81, Thomas Burg, thomasb81@gmail.com

View File

@ -251,7 +251,7 @@ std::string TokenStreamRewriter::getText(const Interval &interval) {
} }
std::string TokenStreamRewriter::getText(const std::string &programName, const Interval &interval) { std::string TokenStreamRewriter::getText(const std::string &programName, const Interval &interval) {
std::vector<TokenStreamRewriter::RewriteOperation*> rewrites = _programs[programName]; std::vector<TokenStreamRewriter::RewriteOperation*> &rewrites = _programs[programName];
size_t start = interval.a; size_t start = interval.a;
size_t stop = interval.b; size_t stop = interval.b;
@ -305,7 +305,8 @@ std::string TokenStreamRewriter::getText(const std::string &programName, const I
} }
std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRewriter::reduceToSingleOperationPerIndex( std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRewriter::reduceToSingleOperationPerIndex(
std::vector<TokenStreamRewriter::RewriteOperation*> rewrites) { std::vector<TokenStreamRewriter::RewriteOperation*> &rewrites) {
// WALK REPLACES // WALK REPLACES
for (size_t i = 0; i < rewrites.size(); ++i) { for (size_t i = 0; i < rewrites.size(); ++i) {
@ -402,7 +403,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
} }
m[op->index] = op; m[op->index] = op;
} }
return m; return m;
} }

View File

@ -267,7 +267,7 @@ namespace antlr4 {
/// ///
/// Return a map from token index to operation. /// Return a map from token index to operation.
/// </summary> /// </summary>
virtual std::unordered_map<size_t, RewriteOperation*> reduceToSingleOperationPerIndex(std::vector<RewriteOperation*> rewrites); virtual std::unordered_map<size_t, RewriteOperation*> reduceToSingleOperationPerIndex(std::vector<RewriteOperation*> &rewrites);
virtual std::string catOpText(std::string *a, std::string *b); virtual std::string catOpText(std::string *a, std::string *b);