-- No words to check
resultALL = false
if yesno(tArgs.explain, false) then
report.xpNoWords(tArgs, sourceWordTable, andWordTable, orWordTable)
end
else
bANDresult, tANDhits = checkANDwords(sourceWordTable, andWordTable)
bORresult, tORhits = checkORwords(sourceWordTable, orWordTable)
resultALL = (bANDresult) and (bORresult)
end  
sYeslist = ''
if resultALL then
-- concat the sYeslist (= all hit words; from 2 tables)
if bANDresult then
sYeslist = sYeslist .. table.concat(tANDhits, tArgs.sep)
end  
if #tORhits > 0 then
if #tANDhits > 0 then
sYeslist = sYeslist .. tArgs.sep
end
sYeslist = sYeslist .. table.concat(tORhits, tArgs.sep)
end
end  
if yesno(tArgs.explain, false) then
if tArgs.yes ~= nil then
if (tArgs.yes == *) and (tArgs.no == *) then
report.xpYesNoBothBlank
end
end
if warningIMaxWordsReached ~= nil then
report.xpMessage(warningIMaxWordsReached)
end
report.xpBuildReport(tArgs, sourceWordTable,
bANDresult, andWordTable, tANDhits,
bORresult, orWordTable, tORhits,
sYeslist, xpLitWordCount)
end
return yesnoReturnstring(tArgs, sYeslist)
end  
-- set wordt separator
local function setSep(sSep)
if sSep == nil then return defaultSep end
local msg = ''
-- todo what with
local newSep = defaultSep  
newSep = sSep
sSep = decodeUnicode(sSep)
if string.match(sSep, '[%s%w%d]') ~= nil then -- not ok
msg = 'Irregular characters in sep: ' .. sSep
newSep = defaultSep
end
newSep = string.sub(sSep, 1, 1)
if newSep == '' then --- ???
newSep = defaultSep
end  
return newSep
end  
local function concatAndLists(s1, s2, newSep)
local tLists = {} -- working table: both s1 and s2 to concat
table.insert(tLists, s1)
table.insert(tLists, s2)
return table.concat(tLists, newSep)
end  
local function parseArgs(origArgs)
local newArgs = {}
newArgs['sep'] = setSep(origArgs['sep']) -- do first, needed below
newArgs['source'] = decodeUnicode(origArgs['s'] or origArgs['source'] or '')
newArgs['andString'] = decodeUnicode(concatAndLists(
origArgs['w'] or origArgs['word'] or nil,
origArgs['andw'] or origArgs['andwords'] or nil,
newArgs.sSep)
newArgs['orString'] = decodeUnicode(origArgs['orw'] or origArgs['orwords'] or '')
-- boolean options: catch both parameters, also handle nil & nonsense input values:
newArgs['case'] = yesno(origArgs['case'] or origArgs['casesensitive'] or true, true) -- defaults to True
newArgs['booleans'] = yesno(origArgs['bool'] or origArgs['booleans'] or false, false) -- defaults to False
newArgs['literals'] = yesno(origArgs['literals'] or origArgs['lit'] or true, true) -- defaults to True
newArgs['yes'] = origArgs['yes'] or nil -- nil; default so return sYeslist; keep '' as legal input & return value
newArgs['no'] = origArgs['no'] or ''
newArgs['explain'] = false -- never. 22Mar2023 checkExplain(newArgs)  
newArgs.explain = false -- never. 22Mar2023 checkExplain(newArgs)  
return newArgs
end  
function p.main
local origArgs = getArgs
local sReturn = ''
local tArgs = {}  
tArgs = parseArgs(origArgs)
if yesno(tArgs.explain, false) then
initReport
report.xpListArguments(origArgs)
end  
sReturn = p._main(tArgs)  
if warningIMaxWordsReached ~=nil then
local preview = require('Module:If preview')
sReturn = sReturn .. preview._warning({warningIMaxWordsReached})
end  
if yesno(tArgs.explain, false) then
return sReturn .. report.xpPresent(tArgs.explain)
else
return sReturn
end
end  
return p