Warn if token type is a table when not needed

This commit is contained in:
Guldoman 2022-06-15 21:31:16 +02:00
parent 2e37e85a48
commit d169619f69
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 5 additions and 1 deletions

View File

@ -272,7 +272,11 @@ function tokenizer.tokenize(incoming_syntax, text, state)
if find_results[1] then
local type_is_table = type(p.type) == "table"
local n_types = type_is_table and #p.type or 1
if #find_results - 1 > n_types then
if #find_results == 2 and type_is_table then
report_bad_pattern(core.warn, current_syntax, n,
"Token type is a table, but a string was expected.")
p.type = p.type[1]
elseif #find_results - 1 > n_types then
report_bad_pattern(core.error, current_syntax, n,
"Not enough token types: got %d needed %d.", n_types, #find_results - 1)
elseif #find_results - 1 < n_types then