mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
Process all 425 tests without crashing
This commit is contained in:
parent
db66777a8b
commit
e625d6604a
@ -87,13 +87,15 @@ module Tartrazine
|
||||
[Token.new(type: xml["type"], value: match[0])]
|
||||
# TODO handle #push #push:n #pop and multiple states
|
||||
when "push"
|
||||
puts "Pushing state #{xml["state"]}"
|
||||
lexer.state_stack << xml["state"]
|
||||
# Push without a state means push the current state
|
||||
state = xml["state"]? || lexer.state_stack.last
|
||||
puts "Pushing state #{state}"
|
||||
lexer.state_stack << state
|
||||
[] of Token
|
||||
when "pop"
|
||||
depth = xml["depth"].to_i
|
||||
puts "Popping #{depth} states"
|
||||
if lexer.state_stack.size < depth
|
||||
if lexer.state_stack.size <= depth
|
||||
puts "Can't pop #{depth} states, only have #{lexer.state_stack.size}"
|
||||
else
|
||||
lexer.state_stack.pop(depth)
|
||||
|
Loading…
Reference in New Issue
Block a user