mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-09-20 07:21:22 +00:00
Make action a struct, guard against popping too much
This commit is contained in:
parent
a3a7b5bd9a
commit
b589726352
@ -8,7 +8,7 @@ require "./tartrazine"
|
|||||||
# perform a list of actions. These actions can emit tokens
|
# perform a list of actions. These actions can emit tokens
|
||||||
# or change the state machine.
|
# or change the state machine.
|
||||||
module Tartrazine
|
module Tartrazine
|
||||||
class Action
|
struct Action
|
||||||
property actions : Array(Action) = [] of Action
|
property actions : Array(Action) = [] of Action
|
||||||
property type : String
|
property type : String
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ module Tartrazine
|
|||||||
when "push"
|
when "push"
|
||||||
to_push = @states_to_push.empty? ? [lexer.state_stack.last] : @states_to_push
|
to_push = @states_to_push.empty? ? [lexer.state_stack.last] : @states_to_push
|
||||||
to_push.each do |state|
|
to_push.each do |state|
|
||||||
if state == "#pop"
|
if state == "#pop" && lexer.state_stack.size > 1
|
||||||
# Pop the state
|
# Pop the state
|
||||||
lexer.state_stack.pop
|
lexer.state_stack.pop
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user