Token should build its own NFA

This commit is contained in:
josh committed 2021-06-06 14:09:28 -04:00
1 parent afea886ecb
commit 701903def2
3 files changed
+14 -7

No files matched your search

+11
View File
@@ -15,10 +15,21 @@ module Imbecile
# Token ID.
attr_reader :id
# @return [Regex::NFA]
# Regex NFA for matching the token.
attr_reader :nfa
def initialize(name, pattern, id)
@name = name
@pattern = pattern
@id = id
regex = Regex.new(pattern)
regex.nfa.end_state.accepts = self
@nfa = regex.nfa
end
def to_s
@name
end
end