Add Lexer class
This commit is contained in:
parent
2f1cb47bea
commit
91d6ee25ea
@ -69,6 +69,8 @@ class <%= classname %>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Lexer
|
||||||
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
<% @grammar.tokens.each_with_index do |token, index| %>
|
<% @grammar.tokens.each_with_index do |token, index| %>
|
||||||
@ -95,7 +97,7 @@ class <%= classname %>
|
|||||||
uint destination;
|
uint destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct LexerState
|
private struct State
|
||||||
{
|
{
|
||||||
uint transition_table_index;
|
uint transition_table_index;
|
||||||
uint n_transitions;
|
uint n_transitions;
|
||||||
@ -109,9 +111,9 @@ class <%= classname %>
|
|||||||
<% end %>
|
<% end %>
|
||||||
];
|
];
|
||||||
|
|
||||||
private static const LexerState lexer_states[] = [
|
private static const State states[] = [
|
||||||
<% state_table.each do |state_table_entry| %>
|
<% state_table.each do |state_table_entry| %>
|
||||||
LexerState(<%= state_table_entry[:transition_table_index] %>u, <%= state_table_entry[:n_transitions] %>u, <%= state_table_entry[:accepts] %>u),
|
State(<%= state_table_entry[:transition_table_index] %>u, <%= state_table_entry[:n_transitions] %>u, <%= state_table_entry[:accepts] %>u),
|
||||||
<% end %>
|
<% end %>
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -133,3 +135,4 @@ class <%= classname %>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user