Rename lexer state "accepts" to "token"

This commit is contained in:
Josh Holtrop 2022-09-25 14:57:46 -04:00
parent 4d716f6c10
commit 48704295bb
2 changed files with 6 additions and 6 deletions

View File

@ -118,7 +118,7 @@ class <%= @classname %>
{ {
uint transition_table_index; uint transition_table_index;
uint n_transitions; uint n_transitions;
uint accepts; uint token;
uint code_id; uint code_id;
} }
@ -133,7 +133,7 @@ class <%= @classname %>
<% state_table.each do |state_table_entry| %> <% state_table.each do |state_table_entry| %>
State(<%= state_table_entry[:transition_table_index] %>u, State(<%= state_table_entry[:transition_table_index] %>u,
<%= state_table_entry[:n_transitions] %>u, <%= state_table_entry[:n_transitions] %>u,
<%= state_table_entry[:accepts] %>u, <%= state_table_entry[:token] %>u,
<%= state_table_entry[:code_id] %>u), <%= state_table_entry[:code_id] %>u),
<% end %> <% end %>
]; ];
@ -236,9 +236,9 @@ class <%= @classname %>
attempt_match_info.delta_col++; attempt_match_info.delta_col++;
} }
current_state = dest; current_state = dest;
if (states[current_state].accepts != _TOKEN_NONE) if (states[current_state].token != _TOKEN_NONE)
{ {
attempt_match_info.token = states[current_state].accepts; attempt_match_info.token = states[current_state].token;
attempt_match_info.code_id = states[current_state].code_id; attempt_match_info.code_id = states[current_state].code_id;
longest_match_info = attempt_match_info; longest_match_info = attempt_match_info;
} }

View File

@ -14,7 +14,7 @@ class Propane
state_table = [] state_table = []
states = @dfa.enumerate states = @dfa.enumerate
states.each do |state, id| states.each do |state, id|
accepts = token =
if state.accepts.nil? if state.accepts.nil?
TOKEN_NONE TOKEN_NONE
elsif state.accepts.drop? elsif state.accepts.drop?
@ -31,7 +31,7 @@ class Propane
state_table << { state_table << {
transition_table_index: transition_table.size, transition_table_index: transition_table.size,
n_transitions: state.transitions.size, n_transitions: state.transitions.size,
accepts: accepts, token: token,
code_id: code_id, code_id: code_id,
} }
state.transitions.each do |transition| state.transitions.each do |transition|