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])]
|
[Token.new(type: xml["type"], value: match[0])]
|
||||||
# TODO handle #push #push:n #pop and multiple states
|
# TODO handle #push #push:n #pop and multiple states
|
||||||
when "push"
|
when "push"
|
||||||
puts "Pushing state #{xml["state"]}"
|
# Push without a state means push the current state
|
||||||
lexer.state_stack << xml["state"]
|
state = xml["state"]? || lexer.state_stack.last
|
||||||
|
puts "Pushing state #{state}"
|
||||||
|
lexer.state_stack << state
|
||||||
[] of Token
|
[] of Token
|
||||||
when "pop"
|
when "pop"
|
||||||
depth = xml["depth"].to_i
|
depth = xml["depth"].to_i
|
||||||
puts "Popping #{depth} states"
|
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}"
|
puts "Can't pop #{depth} states, only have #{lexer.state_stack.size}"
|
||||||
else
|
else
|
||||||
lexer.state_stack.pop(depth)
|
lexer.state_stack.pop(depth)
|
||||||
|
Loading…
Reference in New Issue
Block a user