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