mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-12 22:42:23 +00:00
Nicer tokenize flow
This commit is contained in:
parent
da963e8a31
commit
03b81c2e54
@ -67,13 +67,13 @@ module Tartrazine
|
||||
Log.trace { "Stack is #{@state_stack} State is #{state.name}, pos is #{pos}, text is #{text[pos..pos + 10]}" }
|
||||
state.rules.each do |rule|
|
||||
matched, new_pos, new_tokens = rule.match(text, pos, self)
|
||||
if matched
|
||||
Log.trace { "MATCHED: #{rule.xml}" }
|
||||
pos = new_pos
|
||||
tokens += new_tokens
|
||||
break # We go back to processing with current state
|
||||
end
|
||||
Log.trace { "NOT MATCHED: #{rule.xml}" }
|
||||
next unless matched
|
||||
Log.trace { "MATCHED: #{rule.xml}" }
|
||||
|
||||
pos = new_pos
|
||||
tokens += new_tokens
|
||||
break # We go back to processing with current state
|
||||
end
|
||||
# If no rule matches, emit an error token
|
||||
unless matched
|
||||
|
Loading…
Reference in New Issue
Block a user