This commit is contained in:
Roberto Alsina 2024-08-03 07:44:28 -03:00
parent f80869db1f
commit b3dfa5e28f

View File

@ -61,7 +61,8 @@ module Tartrazine
# <rule> # <rule>
# <pop depth="1"/> # <pop depth="1"/>
# </rule> # </rule>
# They match, don't move pos, and alter the stack # They match, don't move pos, probably alter
# the stack, probably not generate tokens
class Always < Rule class Always < Rule
def match(text, pos, lexer) : Tuple(Bool, Int32, Array(Token)) def match(text, pos, lexer) : Tuple(Bool, Int32, Array(Token))
tokens = [] of Token tokens = [] of Token
@ -84,7 +85,7 @@ module Tartrazine
when "token" when "token"
raise Exception.new "Can't have a token without a match" if match.nil? raise Exception.new "Can't have a token without a match" if match.nil?
[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"]}" puts "Pushing state #{xml["state"]}"
lexer.state_stack << xml["state"] lexer.state_stack << xml["state"]