From b5897263525bfe8e8acc0c49e3a51eedc90c2534 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Thu, 15 Aug 2024 21:16:17 -0300 Subject: [PATCH] Make action a struct, guard against popping too much --- src/actions.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions.cr b/src/actions.cr index 6baf72b..6fed0b7 100644 --- a/src/actions.cr +++ b/src/actions.cr @@ -8,7 +8,7 @@ require "./tartrazine" # perform a list of actions. These actions can emit tokens # or change the state machine. module Tartrazine - class Action + struct Action property actions : Array(Action) = [] of Action property type : String @@ -64,7 +64,7 @@ module Tartrazine when "push" to_push = @states_to_push.empty? ? [lexer.state_stack.last] : @states_to_push to_push.each do |state| - if state == "#pop" + if state == "#pop" && lexer.state_stack.size > 1 # Pop the state lexer.state_stack.pop else