diff --git a/assets/parser.d.erb b/assets/parser.d.erb index a376f1c..e78568d 100644 --- a/assets/parser.d.erb +++ b/assets/parser.d.erb @@ -6,8 +6,10 @@ class <%= classname %> { enum { -<% @grammar.tokens.each do |token| %> - TOKEN_<%= token.c_name %>, +<% @grammar.tokens.each_with_index do |token, index| %> +<% if token.name %> + TOKEN_<%= token.c_name %> = <%= index %>, +<% end %> <% end %> } diff --git a/lib/imbecile/regex/fa.rb b/lib/imbecile/regex/fa.rb index 6c433d1..9e829e6 100644 --- a/lib/imbecile/regex/fa.rb +++ b/lib/imbecile/regex/fa.rb @@ -62,6 +62,16 @@ module Imbecile state_table = [] states = enumerate states.each do |state, id| + accepts = + if state.accepts + if state.accepts.name + state.accepts.id + else + 0xFFFFFFFE # drop token + end + else + 0xFFFFFFFF # not an accepting state + end state_table << { transition_table_index: transition_table.size, n_transitions: state.transitions.size,