%D \module
%D   [       file=metatex,
%D        version=2008.10.10,
%D          title=\METATEX,
%D       subtitle=\METATEX\ Format Generation,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=Hans Hagen / \CONTEXT\ Development Team]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D We can experiment here with runtime loading, i.e. no longer
%D use a format. However, we still need a stub then but it could
%D as well be luatools (mtxrun) itself then.

%D This format is just a minimal layer on top of the \LUATEX\
%D engine and will not provide high level functionality. It can
%D be used as basis for dedicated (specialized) macro packages.
%D
%D A format is generated with the command;
%D
%D \starttyping
%D luatools --make --compile metatex
%D \stoptyping
%D
%D Remark: this is far from complete. We will gradually add
%D more. Also, it's not yet clean what exactly will be part
%D of it. This is a prelude to a configureable macro package.

\catcode`\{=1 \catcode`\}=2 \catcode`\#=6

\edef\metatexformat {\jobname}
\edef\metatexversion{2007.04.03 13:01}

\let\fmtname   \metatexformat
\let\fmtversion\metatexversion

\ifx\normalinput\undefined \let\normalinput\input \fi

\def\loadcorefile#1{\normalinput#1.tex \relax}
\def\loadmarkfile#1{\normalinput#1.mkiv\relax}

\loadmarkfile{syst-ini}

\ifnum\luatexversion<60 % also change message
    \writestatus{!!!!}{Your luatex binary is too old, you need at least version 0.60!}
    \expandafter\end
\fi

\newtoks\metatexversiontoks \metatexversiontoks\expandafter{\metatexversion} % at the lua end

\loadmarkfile{syst-pln}      % plain tex initializations of internal registers (no further code)
\loadmarkfile{syst-mes}

\loadmarkfile{luat-cod}      %
\loadmarkfile{luat-bas}      %
\loadmarkfile{luat-lib}      %

% needs stripping:

\loadmarkfile{catc-ini}      % catcode table management
\loadmarkfile{catc-act}      % active character definition mechanisms
\loadmarkfile{catc-def}      % some generic catcode tables
\loadmarkfile{catc-ctx}      % a couple of context specific tables but expected by later modules
\loadmarkfile{catc-sym}      % some definitions related to \letter<tokens>

% helpers, maybe less

\loadmarkfile{syst-aux}      % a whole lot of auxiliary macros
%loadmarkfile{syst-lua}      % some helpers using lua instead
%loadmarkfile{syst-con}      % some rather basic conversions
%loadmarkfile{syst-fnt}
%loadmarkfile{syst-str}
%loadmarkfile{syst-rtp}

% not needed

% \loadmarkfile{supp-fil}
% \loadmarkfile{supp-dir}

% characters

\loadmarkfile{char-utf}
\loadmarkfile{char-ini}
\loadmarkfile{char-enc}      % \registerctxluafile{char-enc}{1.001}

% attributes

\loadmarkfile{attr-ini}

% nodes

\loadmarkfile{node-ini}
%loadmarkfile{node-fin}
%loadmarkfile{node-par}

% attributes, not needed:

%loadmarkfile{attr-ini}

% regimes

% \loadmarkfile{regi-ini}
% \loadcorefile{regi-syn}

% languages

% fonts

% \loadcorefile{enco-ini.mkiv}
% \loadcorefile{hand-ini.mkiv}

\registerctxluafile{font-ini}{1.001}

\registerctxluafile{node-fnt}{1.001}

\registerctxluafile{font-enc}{1.001}
\registerctxluafile{font-map}{1.001}
\registerctxluafile{font-syn}{1.001}
\registerctxluafile{font-tfm}{1.001}
\registerctxluafile{font-afm}{1.001}
\registerctxluafile{font-cid}{1.001}
\registerctxluafile{font-ott}{1.001}
\registerctxluafile{font-otf}{1.001}
\registerctxluafile{font-otb}{1.001}
\registerctxluafile{font-otn}{1.001}
\registerctxluafile{font-ota}{1.001}
\registerctxluafile{font-otp}{1.001}
\registerctxluafile{font-otc}{1.001}
%registerctxluafile{font-vf} {1.001}
\registerctxluafile{font-def}{1.001}
%registerctxluafile{font-ctx}{1.001}
\registerctxluafile{font-xtx}{1.001}
%registerctxluafile{font-fbk}{1.001}
%registerctxluafile{font-ext}{1.001}
\registerctxluafile{font-pat}{1.001}
%registerctxluafile{font-chk}{1.001}

%registerctxluafile{math-ini}{1.001}
%registerctxluafile{math-dim}{1.001}
%registerctxluafile{math-ent}{1.001}
%registerctxluafile{math-ext}{1.001}
%registerctxluafile{math-vfu}{1.001}
%registerctxluafile{math-map}{1.001}
%registerctxluafile{math-noa}{1.001}

\registerctxluafile{task-ini}{1.001}

%registerctxluafile{l-xml}{1.001} % needed for font database

% why not ...

\pdfoutput\plusone

% too

\appendtoks
    \ctxlua{statistics.savefmtstatus("\jobname","\metatexversion","metatex.tex")}% can become automatic
\to \everydump

% done

\errorstopmode \dump \endinput
