%%%==============================================================================
%% Copyright 2026-present by Alceu Frigeri
%%
%% This work may be distributed and/or modified under the conditions of
%%
%% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
%%   version 1.3c (or later), and/or
%% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
%%   version 3 (or later)
%%
%% This work has the LPPL maintenance status *maintained*.
%%
%% The Current Maintainer of this work is Alceu Frigeri
%%
%% This is version {1.0} {2026/11/27}
%%
%% The list of files that compose this work can be found in the README.md file at
%% https://ctan.org/pkg/codehighlight
%%
%%%==============================================================================
%%
%% Nota Bene:
%% Some languages 'got' an specific identifier
%%                  like ==> identifier = { pragma } { \# } { }
%%                    or ==> identifier = { texcs }  { \\ } { }
%%      this is a flexible way to declare keywords/pragmas instead
%%      of changing the catcode of some chars to letter
%%          main implication: some keyword/pragma's lists got split.
%%%==============================================================================

%%%%%%%
%%%  This save the current 'expl syntax' state
%%%%%%%
\hlExplFileTest
%%%%%%%
%%%
%%% Just an attempt at having my package's info in a regular way
%%%   \pkginfograb_set:nn {<pkg-name>} { props} sets package info
%%%
%%%   \pkginfograbProvidesExplPackage {<pkg-name>} { props} sets package info
%%%     and calls \ProvidesExplPackage
%%%
%%%%%%%
\RequirePackage{pkginfograb}
\pkginfograbProvidesExplFile {codehighlight-06}
  {
     name        = {codehighlight-06} ,
     prefix      = {codehl} ,
     date        = {2026/11/27} ,
     version     = {1.0} ,
     description = {codehighlight ~language ~definitions ~06}
  }
%%%%%%%
%%% End of cut-n-paste
%%%%%%%

\codehl_lang_def:nn { lua.5.5 }
  {
    %%%
    info / note  =
     {
       lua ~ 5.5 ~ base ~ Language. ~ Some ~ references~\\
        https://www.lua.org/~\\
        https://www.lua.org/manual/5.5/~\\
        https://www.lua.org/versions.html
     }  ,
    %%%
     
    comment ~ line           =      {1} { --              }                           { }  ,
    
    comment                  =      {2} { --[[            } { ]]            }         { }  ,
    comment                  =      {2} { --[=[           } { ]=]           }         { }  ,
    comment                  =      {2} { --[==[          } { ]==]          }         { }  ,
    comment                  =      {2} { --[===[         } { ]===]         }         { }  ,
    comment                  =      {2} { --[====[        } { ]====]        }         { }  ,
    comment                  =      {2} { --[=====[       } { ]=====]       }         { }  ,
    comment                  =      {2} { --[======[      } { ]======]      }         { }  ,
    comment                  =      {2} { --[=======[     } { ]=======]     }         { }  ,
    comment                  =      {2} { --[========[    } { ]========]    }         { }  ,
    comment                  =      {2} { --[=========[   } { ]=========]   }         { }  ,
    comment                  =      {2} { --[==========[  } { ]==========]  }         { }  ,

    string                   =      {1} { " }                                 { \\ }  { }  ,
    string                   =      {1} { ' }                                 { \\ }  { }  ,

    delimited ~ string       =      {2} { [[              } { ]]            } { \\ }  { }  ,
    delimited ~ string       =      {2} { [=[             } { ]=]           } { \\ }  { }  ,
    delimited ~ string       =      {2} { [==[            } { ]==]          } { \\ }  { }  ,
    delimited ~ string       =      {2} { [===[           } { ]===]         } { \\ }  { }  ,
    delimited ~ string       =      {2} { [====[          } { ]====]        } { \\ }  { }  ,
    delimited ~ string       =      {2} { [=====[         } { ]=====]       } { \\ }  { }  ,
    delimited ~ string       =      {2} { [======[        } { ]======]      } { \\ }  { }  ,
    delimited ~ string       =      {2} { [=======[       } { ]=======]     } { \\ }  { }  ,
    delimited ~ string       =      {2} { [========[      } { ]========]    } { \\ }  { }  ,
    delimited ~ string       =      {2} { [=========[     } { ]=========]   } { \\ }  { }  ,
    delimited ~ string       =      {2} { [==========[    } { ]==========]  } { \\ }  { }  ,

    alphanumeric             =      true  ,
    oletter                  =      { \_  }  ,
    digits                   =      { :\. }  ,
  }

\codehl_keyset_def:nn { lua.5.5 }
  {
    %%%
    info / note  =
     {
       lua ~ 5.5 ~ base ~ Language. ~ Some ~ references~\\
        https://www.lua.org/~\\
        https://www.lua.org/manual/5.5/~\\
        https://www.lua.org/versions.html
     }  ,
    %%%

     
    keywd                    =      {1}
      {
        and, break, do, else, elseif, end, false, for, function, 
        goto, if, in, local, nil, not, or, repeat, return, then, 
        true, until, while, global, 
      }  ,
    keywd                    =      {1}
      {
        attributes, autodie, autouse, base, bigint, bignum, bigrat, blib, bytes, 
        charnames, constant, diagnostics, encoding, feature, fields, filetest, 
        if, integer, less, lib, locale, mro, ok, open, ops, overload, overloading, 
        parent, re, sigtrap, sort, strict, subs, threads, threads::shared, utf8, 
        vars, version, vmsish, warnings, warnings::register,
        say, state, switch, unicode_strings, current_sub, unicode_eval, evalbytes, 
        fc, postderef_qq, bitwise, isa, signatures, module_true, try, defer, class
      }  ,
    keywd                    =      {2}
      {    %%% basic
        _G, _VERSION, assert, collectgarbage, dofile, error, getmetatable, 
        ipairs, load, loadfile, next, pairs, pcall, print, rawequal, 
        rawget, rawlen, rawset, require, select, setmetatable, tonumber, 
        tostring, type, warn, xpcall, 
      }  ,
    keywd                    =      {2}
      {    %%% coroutine
        coroutine.close, coroutine.create, coroutine.isyieldable, 
        coroutine.resume, coroutine.running, coroutine.status, 
        coroutine.wrap, coroutine.yield, 
      }  ,
    keywd                    =      {2}
      {    %%% debug
        debug.debug, debug.gethook, debug.getinfo, debug.getlocal, 
        debug.getmetatable, debug.getregistry, debug.getupvalue, 
        debug.getuservalue, debug.sethook, debug.setlocal, 
        debug.setmetatable, debug.setupvalue, debug.setuservalue, 
        debug.traceback, debug.upvalueid, debug.upvaluejoin, 
      }  ,
    keywd                    =      {2}
      {    %%% io
        io.close, io.flush, io.input, io.lines, io.open, io.output, 
        io.popen, io.read, io.stderr, io.stdin, io.stdout, io.tmpfile, 
        io.type, io.write, file:close, file:flush, file:lines, file:read, 
        file:seek, file:setvbuf, file:write,  
      }  ,
    keywd                    =      {2}
      {    %%% math
        math.abs, math.acos, math.asin, math.atan, math.ceil, math.cos, 
        math.deg, math.exp, math.floor, math.fmod, math.frexp, math.huge, 
        math.ldexp, math.log, math.max, math.maxinteger, math.min, 
        math.mininteger, math.modf, math.pi, math.rad, math.random, 
        math.randomseed, math.sin, math.sqrt, math.tan, math.tointeger, 
        math.type, math.ult, 
      }  ,
    keywd                    =      {2}
      {    %%% os
        os.clock, os.date, os.difftime, os.execute, os.exit, os.getenv, 
        os.remove, os.rename, os.setlocale, os.time, os.tmpname, 
      }  ,
    keywd                    =      {2}
      {    %%% package
        package.config, package.cpath, package.loaded, package.loadlib, 
        package.path, package.preload, package.searchers, package.searchpath, 
      }  ,
    keywd                    =      {2}
      {    %%% string
        string.byte, string.char, string.dump, string.find, string.format, 
        string.gmatch, string.gsub, string.len, string.lower, string.match, 
        string.pack, string.packsize, string.rep, string.reverse, 
        string.sub, string.unpack, string.upper, 
      }  ,
    keywd                    =      {2}
      {    %%% table
        table.concat, table.create, table.insert, table.move, table.pack, 
        table.remove, table.sort, table.unpack, 
      }  ,
    keywd                    =      {2}
      {    %%% utf8
        utf8.char, utf8.charpattern, utf8.codepoint, utf8.codes, 
        utf8.len, utf8.offset, 
      }  ,
    keywd                    =      {2}
      {    %%% metamethods
        __add, __band, __bnot, __bor, __bxor, __call, __close, __concat, 
        __div, __eq, __gc, __idiv, __index, __le, __len, __lt, __metatable, 
        __mod, __mode, __mul, __name, __newindex, __pairs, __pow, __shl, 
        __shr, __sub, __tostring, __unm, 
      }  ,
    keywd                    =      {2}
      {    %%% environmentvariables
        LUA_CPATH, LUA_CPATH_5_5, LUA_INIT, LUA_INIT_5_5, 
        LUA_PATH, LUA_PATH_5_5, 
      }  ,
    keywd                    =      {3}
      {    %%% C API
        lua_Alloc, lua_CFunction, lua_Debug, lua_Hook, lua_Integer, 
        lua_KContext, lua_KFunction, lua_Number, lua_Reader, lua_State, 
        lua_Unsigned, lua_WarnFunction, lua_Writer, lua_absindex, 
        lua_arith, lua_atpanic, lua_call, lua_callk, lua_checkstack, 
        lua_close, lua_closeslot, lua_closethread, lua_compare, lua_concat, 
        lua_copy, lua_createtable, lua_dump, lua_error, lua_gc, lua_getallocf, 
        lua_getextraspace, lua_getfield, lua_getglobal, lua_gethook, 
        lua_gethookcount, lua_gethookmask, lua_geti, lua_getinfo, 
        lua_getiuservalue, lua_getlocal, lua_getmetatable, lua_getstack, 
        lua_gettable, lua_gettop, lua_getupvalue, lua_insert, lua_isboolean, 
        lua_iscfunction, lua_isfunction, lua_isinteger, lua_islightuserdata, 
        lua_isnil, lua_isnone, lua_isnoneornil, lua_isnumber, lua_isstring, 
        lua_istable, lua_isthread, lua_isuserdata, lua_isyieldable, 
        lua_len, lua_load, lua_newstate, lua_newtable, lua_newthread, 
        lua_newuserdatauv, lua_next, lua_numbertocstring, lua_numbertointeger, 
        lua_pcall, lua_pcallk, lua_pop, lua_pushboolean, lua_pushcclosure, 
        lua_pushcfunction, lua_pushexternalstring, lua_pushfstring, 
        lua_pushglobaltable, lua_pushinteger, lua_pushlightuserdata, 
        lua_pushliteral, lua_pushlstring, lua_pushnil, lua_pushnumber, 
        lua_pushstring, lua_pushthread, lua_pushvalue, lua_pushvfstring, 
        lua_rawequal, lua_rawget, lua_rawgeti, lua_rawgetp, lua_rawlen, 
        lua_rawset, lua_rawseti, lua_rawsetp, lua_register, lua_remove, 
        lua_replace, lua_resume, lua_rotate, lua_setallocf, lua_setfield, 
        lua_setglobal, lua_sethook, lua_seti, lua_setiuservalue, lua_setlocal, 
        lua_setmetatable, lua_settable, lua_settop, lua_setupvalue, 
        lua_setwarnf, lua_status, lua_stringtonumber, lua_toboolean, 
        lua_tocfunction, lua_toclose, lua_tointeger, lua_tointegerx, 
        lua_tolstring, lua_tonumber, lua_tonumberx, lua_topointer, 
        lua_tostring, lua_tothread, lua_touserdata, lua_type, lua_typename, 
        lua_upvalueid, lua_upvalueindex, lua_upvaluejoin, lua_version, 
        lua_warning, lua_xmove, lua_yield, lua_yieldk, 
      }  ,
    keywd                    =      {3}
      {    %%% auxiliarylibrary
        luaL_Buffer, luaL_Reg, luaL_Stream, luaL_addchar, luaL_addgsub, 
        luaL_addlstring, luaL_addsize, luaL_addstring, luaL_addvalue, 
        luaL_alloc, luaL_argcheck, luaL_argerror, luaL_argexpected, 
        luaL_buffaddr, luaL_buffinit, luaL_buffinitsize, luaL_bufflen, 
        luaL_buffsub, luaL_callmeta, luaL_checkany, luaL_checkinteger, 
        luaL_checklstring, luaL_checknumber, luaL_checkoption, luaL_checkstack, 
        luaL_checkstring, luaL_checktype, luaL_checkudata, luaL_checkversion, 
        luaL_dofile, luaL_dostring, luaL_error, luaL_execresult, luaL_fileresult, 
        luaL_getmetafield, luaL_getmetatable, luaL_getsubtable, luaL_gsub, 
        luaL_len, luaL_loadbuffer, luaL_loadbufferx, luaL_loadfile, 
        luaL_loadfilex, luaL_loadstring, luaL_makeseed, luaL_newlib, 
        luaL_newlibtable, luaL_newmetatable, luaL_newstate, luaL_openlibs, 
        luaL_openselectedlibs, luaL_opt, luaL_optinteger, luaL_optlstring, 
        luaL_optnumber, luaL_optstring, luaL_prepbuffer, luaL_prepbuffsize, 
        luaL_pushfail, luaL_pushresult, luaL_pushresultsize, luaL_ref, 
        luaL_requiref, luaL_setfuncs, luaL_setmetatable, luaL_testudata, 
        luaL_tolstring, luaL_traceback, luaL_typeerror, luaL_typename, 
        luaL_unref, luaL_where, 
      }  ,
    keywd                    =      {3}
      {    %%% LUAL_BUFFERSIZE
        constants, LUA_ERRERR, LUA_ERRFILE, LUA_ERRMEM, LUA_ERRRUN, 
        LUA_ERRSYNTAX, LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCCOUNTB, 
        LUA_GCGEN, LUA_GCINC, LUA_GCISRUNNING, LUA_GCPARAM, LUA_GCPMAJORMINOR, 
        LUA_GCPMINORMAJOR, LUA_GCPMINORMUL, LUA_GCPPAUSE, LUA_GCPSTEPMUL, 
        LUA_GCPSTEPSIZE, LUA_GCRESTART, LUA_GCSTEP, LUA_GCSTOP, LUA_HOOKCALL, 
        LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_HOOKRET, LUA_HOOKTAILCALL, 
        LUA_LOADED_TABLE, LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, 
        LUA_MASKRET, LUA_MAXINTEGER, LUA_MININTEGER, LUA_MINSTACK, LUA_MULTRET, 
        LUA_N2SBUFFSZ, LUA_NOREF, LUA_OK, LUA_OPADD, LUA_OPBAND, LUA_OPBNOT, 
        LUA_OPBOR, LUA_OPBXOR, LUA_OPDIV, LUA_OPEQ, LUA_OPIDIV, LUA_OPLE, 
        LUA_OPLT, LUA_OPMOD, LUA_OPMUL, LUA_OPPOW, LUA_OPSHL, LUA_OPSHR, 
        LUA_OPSUB, LUA_OPUNM, LUA_PRELOAD_TABLE, LUA_REFNIL, LUA_REGISTRYINDEX, 
        LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD, LUA_TBOOLEAN, LUA_TFUNCTION, 
        LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNONE, LUA_TNUMBER, LUA_TSTRING, 
        LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, LUA_USE_APICHECK, LUA_YIELD, 
      }  ,
    keywd                    =      {3}
      {    %%% standardlibrary
        LUA_COLIBK, LUA_DBLIBK, LUA_GLIBK, LUA_IOLIBK, LUA_LOADLIBK, 
        LUA_MATHLIBK, LUA_OSLIBK, LUA_STRLIBK, LUA_TABLIBK, LUA_UTF8LIBK, 
        LUA_COLIBNAME, LUA_DBLIBNAME, LUA_IOLIBNAME, LUA_LOADLIBNAME,
        LUA_MATHLIBNAME, LUA_OSLIBNAME, LUA_STRLIBNAME, LUA_TABLIBNAME, 
        LUA_UTF8LIBNAME, 
      }  ,
      
  }

%%
%% Aliases
%%

\codehl_lang_alias:nn   { lua } { lua.5.5 }
\codehl_keyset_alias:nn { lua } { lua.5.5 }

%%%%%%%
%%%  This restore the 'expl syntax' state saved (hopefully) at the beginning
%%%%%%%
\hlExplFileOut


