Generator builds a Lexer, not a Lexer::DFA
This commit is contained in:
parent
51a31317a6
commit
f295acb593
@ -115,7 +115,7 @@ class <%= classname %>
|
|||||||
uint accepts;
|
uint accepts;
|
||||||
}
|
}
|
||||||
|
|
||||||
<% transition_table, state_table = lexer_dfa.build_tables %>
|
<% transition_table, state_table = lexer.dfa.build_tables %>
|
||||||
private static const Transition transitions[] = [
|
private static const Transition transitions[] = [
|
||||||
<% transition_table.each do |transition_table_entry| %>
|
<% transition_table.each do |transition_table_entry| %>
|
||||||
Transition(<%= transition_table_entry[:first] %>u, <%= transition_table_entry[:last] %>u, <%= transition_table_entry[:destination] %>u),
|
Transition(<%= transition_table_entry[:first] %>u, <%= transition_table_entry[:last] %>u, <%= transition_table_entry[:destination] %>u),
|
||||||
|
@ -25,7 +25,7 @@ module Imbecile
|
|||||||
unless rule_names["Start"]
|
unless rule_names["Start"]
|
||||||
raise Error.new("Start rule not found")
|
raise Error.new("Start rule not found")
|
||||||
end
|
end
|
||||||
lexer_dfa = Lexer::DFA.new(@grammar.tokens)
|
lexer = Lexer.new(@grammar)
|
||||||
classname = @grammar.classname || File.basename(output_file).sub(%r{[^a-zA-Z0-9].*}, "").capitalize
|
classname = @grammar.classname || File.basename(output_file).sub(%r{[^a-zA-Z0-9].*}, "").capitalize
|
||||||
erb = ERB.new(File.read(File.join(File.dirname(File.expand_path(__FILE__)), "../../assets/parser.d.erb")), nil, "<>")
|
erb = ERB.new(File.read(File.join(File.dirname(File.expand_path(__FILE__)), "../../assets/parser.d.erb")), nil, "<>")
|
||||||
result = erb.result(binding.clone)
|
result = erb.result(binding.clone)
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
module Imbecile
|
module Imbecile
|
||||||
class Lexer
|
class Lexer
|
||||||
|
|
||||||
|
# @return [DFA]
|
||||||
|
# Lexer DFA.
|
||||||
|
attr_accessor :dfa
|
||||||
|
|
||||||
|
def initialize(grammar)
|
||||||
|
@dfa = DFA.new(grammar.tokens)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user