Use classes instead of structs to allow properties of the same type

This commit is contained in:
2024-08-22 21:52:59 -03:00
parent 0f3b7fc3c5
commit bd3df10d2c
6 changed files with 57 additions and 41 deletions

View File

@@ -4,14 +4,14 @@ module Tartrazine
class Json < Formatter
property name = "json"
def format(text : String, lexer : Lexer) : String
def format(text : String, lexer : BaseLexer) : String
outp = String::Builder.new("")
format(text, lexer, outp)
outp.to_s
end
def format(text : String, lexer : Lexer, io : IO) : Nil
tokenizer = Tokenizer.new(lexer, text)
def format(text : String, lexer : BaseLexer, io : IO) : Nil
tokenizer = lexer.tokenizer(text)
io << Tartrazine::Lexer.collapse_tokens(tokenizer.to_a).to_json
end
end