Merge pull request #2445 from WalterCouto/master

C++: fix bug in PredictionContext::mergeArrays
This commit is contained in:
Terence Parr 2018-12-21 12:01:08 -07:00 committed by GitHub
commit fa466c42a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -209,4 +209,5 @@ YYYY/MM/DD, github id, Full name, email
2018/11/12, vinoski, Steve Vinoski, vinoski@ieee.org
2018/11/14, nxtstep, Adriaan (Arjan) Duz, codewithadriaan[et]gmail[dot]com
2018/11/15, amykyta3, Alex Mykyta, amykyta3@users.noreply.github.com
2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com
2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com
2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com

View File

@ -272,7 +272,7 @@ ssize_t BufferedTokenStream::previousTokenOnChannel(size_t i, size_t channel) {
}
if (i == 0)
break;
return -1;
i--;
}
return i;

View File

@ -278,7 +278,7 @@ Ref<PredictionContext> PredictionContext::mergeArrays(const Ref<ArrayPredictionC
// same payload (stack tops are equal), must yield merged singleton
size_t payload = a->returnStates[i];
// $+$ = $
bool both$ = payload == EMPTY_RETURN_STATE && a_parent && b_parent;
bool both$ = payload == EMPTY_RETURN_STATE && !a_parent && !b_parent;
bool ax_ax = (a_parent && b_parent) && *a_parent == *b_parent; // ax+ax -> ax
if (both$ || ax_ax) {
mergedParents[k] = a_parent; // choose left