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

Change inner loops to use int not YY_CHAR, removing need for separate NUL table #370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 5 additions & 23 deletions src/dfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,30 +452,12 @@ void ntod (void)

/* Note that the test for ecgroup[0] == numecs below accomplishes
* both (1) and (2) above
*
* New way: we will only use NUL table for fulltbl, because the
* scanner will use an integer instead of YY_CHAR as noted above
*/
if (!fullspd && ecgroup[0] == numecs) {
/* NUL is alone in its equivalence class, which is the
* last one.
*/
int use_NUL_table = (numecs == csize);

if (fulltbl && !use_NUL_table) {
/* We still may want to use the table if numecs
* is a power of 2.
*/
if (numecs <= csize && is_power_of_2(numecs)) {
use_NUL_table = true;
}
}

if (use_NUL_table)
nultrans =
allocate_integer_array (current_max_dfas);

/* From now on, nultrans != nil indicates that we're
* saving null transitions for later, separate encoding.
*/
}
if (fulltbl && ecgroup[0] == numecs && is_power_of_2(numecs))
nultrans = allocate_integer_array (current_max_dfas);


if (fullspd) {
Expand Down
11 changes: 10 additions & 1 deletion src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,16 @@ void genftbl (void)

void gen_next_compressed_state (char *char_map)
{
indent_put2s ("YY_CHAR yy_c = %s;", char_map);
/* Formerly YY_CHAR, changed to int because table can now have up to
* 0x101 entries, since we no longer generate a separate NUL table
*
* Note: on x86-64 architecture with gcc -O2, we save an instruction
* in the main loop, since the character can now be zero-extended in
* the process of retrieving it from the input stream or the yy_ec[]
* or yy_meta[] arrays, whereas previously it was zero-extended by a
* register-to-register move just prior to the yy_chk[] table lookup
*/
indent_put2s ("int yy_c = %s;", char_map);

/* Save the backing-up info \before/ computing the next state
* because we always compute one more state than needed - we
Expand Down