diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2020-09-18 13:04:27 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2020-09-18 13:04:27 +0300 |
commit | 154592f9db7af78cfa31ad6d64134ca89eed13b0 (patch) | |
tree | edcf45357d13c23d59e75bde7d513e856a4c71cf /support/dfa.c | |
parent | cde8fd84a060bcae8a5960897ff2e2de576b2e08 (diff) | |
download | egawk-154592f9db7af78cfa31ad6d64134ca89eed13b0.tar.gz egawk-154592f9db7af78cfa31ad6d64134ca89eed13b0.tar.bz2 egawk-154592f9db7af78cfa31ad6d64134ca89eed13b0.zip |
Update support files from GNULIB.
Diffstat (limited to 'support/dfa.c')
-rw-r--r-- | support/dfa.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/support/dfa.c b/support/dfa.c index 8a012ad6..641f422a 100644 --- a/support/dfa.c +++ b/support/dfa.c @@ -2505,11 +2505,6 @@ reorder_tokens (struct dfa *d) : NULL); for (idx_t i = 0; i < d->tindex; i++) - for (idx_t j = 0; j < d->follows[i].nelem; j++) - if (map[d->follows[i].elems[j].index] < 0) - map[d->follows[i].elems[j].index] = nleaves++; - - for (idx_t i = 0; i < d->tindex; i++) { if (map[i] < 0) { @@ -2527,7 +2522,12 @@ reorder_tokens (struct dfa *d) multibyte_prop[map[i]] = d->multibyte_prop[i]; for (idx_t j = 0; j < d->follows[i].nelem; j++) - d->follows[i].elems[j].index = map[d->follows[i].elems[j].index]; + { + if (map[d->follows[i].elems[j].index] == -1) + map[d->follows[i].elems[j].index] = nleaves++; + + d->follows[i].elems[j].index = map[d->follows[i].elems[j].index]; + } qsort (d->follows[i].elems, d->follows[i].nelem, sizeof *d->follows[i].elems, compare); @@ -2700,6 +2700,17 @@ dfaanalyze (struct dfa *d, bool searchflag) case STAR: case PLUS: + /* Every element in the lastpos of the argument is in the backward + set of every element in the firstpos. */ + if (d->epsilon) + { + tmp.elems = lastpos - stk[-1].nlastpos; + tmp.nelem = stk[-1].nlastpos; + for (position *p = firstpos - stk[-1].nfirstpos; + p < firstpos; p++) + merge2 (&backward[p->index], &tmp, &merged); + } + /* Every element in the firstpos of the argument is in the follow of every element in the lastpos. */ { |