Mark regex NFA end state as accepting the token
This commit is contained in:
1 parent
7196a0605a
commit
c77c81bf25
2 files changed
+4
-1
No files matched your search
@@ -41,8 +41,9 @@ module Imbecile
|
||||
# Build NFA from each token expression.
|
||||
@tokens.each do |token_name, token_def|
|
||||
token_def[:regex] = Regex.new(token_def[:pattern])
|
||||
token_def[:regex].nfa.end_state.accepts = token_name
|
||||
end
|
||||
dfa = DFA.new(@tokens.map {|token_name, token_def| token_def[:regex].nfa})
|
||||
dfa = Regex::DFA.new(@tokens.map {|token_name, token_def| token_def[:regex].nfa})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,6 +5,8 @@ module Imbecile
|
||||
|
||||
class State
|
||||
|
||||
attr_accessor :accepts
|
||||
|
||||
def initialize
|
||||
@transitions = []
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user