From 6efa2ebd0e44b758740120374d63874beda7ba6a Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 17 Feb 2016 13:11:58 +0100 Subject: simplified "lexer.test..." macros using the $$ return command * this is slightly more efficient than using repeated conditionals * the last :EN does not require a conditional, as its return value can simply be forwarded. * even without $$, this could have been done easier using a once-only loop and breaking out of the loop if :EN fails using :;. The last :EN result is still stored in QReg "_". * :EN could also be used to match header lines if lexer.tes would leave the first line (header line) in some Q-Reg, like the local .[header]. However, repeated :ENs would be necessary as globbing currently does not support {...,...} expansions. Since sooner or later, the header line must be evaluated for some lexer.set macro, this is probably more efficient than the current solution using SciTECO patterns and [lexer.checkheader] could be removed as well. --- lib/scite2co.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/scite2co.lua') diff --git a/lib/scite2co.lua b/lib/scite2co.lua index b39c184..e03a59f 100755 --- a/lib/scite2co.lua +++ b/lib/scite2co.lua @@ -93,18 +93,18 @@ local file_patterns = expand(props["file.patterns."..language]) io.write([=[ @[lexer.test.]=]..language:lower()..[=[]{ ]=]) -if shbang then io.write([=[ _#!M]=]..shbang..[=[M[lexer.checkheader]U.r +if shbang then io.write([=[ _#!M]=]..shbang..[=[M[lexer.checkheader]"S -1 ' ]=]) end -local first_pattern = not shbang +local patterns = {} for pattern in file_patterns:gmatch("[^;]+") do - io.write([=[ ]=]) - if not first_pattern then io.write([=[Q.r"F ]=]) end - io.write([=[:EN]=]..pattern..[=[Q*U.r]=]) - if not first_pattern then io.write([=[ ']=]) end + table.insert(patterns, pattern) +end +for i, pattern in ipairs(patterns) do + io.write([=[ :EN]=]..pattern..[=[Q*]=]) + if i ~= #patterns then io.write([=["S -1 ']=]) end io.write("\n") - first_pattern = false end -io.write([=[Q.r} +io.write([=[} ]=]) -- cgit v1.2.3