From 0dbc519f11e78208839dc23dc8e673e202cfaa59 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 25 Aug 2022 12:28:10 +0200 Subject: [PATCH] Add support for string literals --- hare.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hare.lua b/hare.lua index c3d884a..2e52fa4 100644 --- a/hare.lua +++ b/hare.lua @@ -50,7 +50,10 @@ local escape_sequence = named_escape + '\\u' * hex_digit * hex_digit * hex_digit * hex_digit local rune = escape_sequence + l.nonnewline_esc-S("\\'") local string_char = escape_sequence + l.nonnewline_esc-S('\\"') -local string = token(l.STRING, "'" * rune * "'" + '"' * string_char^0 * '"') +local sq_str = "'" * rune * "'" +local dq_str = '"' * string_char^0 * '"' +local bt_str = l.delimited_range('`', false, true) +local string = token(l.STRING, sq_str + dq_str + bt_str) -- TODO: highlight size correctly both as keyword and type local type = token(l.TYPE, word_match{ -- 2.34.6