% \iffalse
%% File: l3final.dtx Copyright (C) 1990-2006 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the ``expl3 bundle'' (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%
%<*driver|package>
\RequirePackage{l3names}
%</driver|package>
%<*-ini>
%\fi
\GetIdInfo$Id: l3final.dtx 1670 2009-11-01 22:34:54Z will $
          {L3 Experimental final module}
%\iffalse
%</-ini>
%<*driver>
%\fi
\ProvidesFile{\filename.\filenameext}
  [\filedate\space v\fileversion\space\filedescription]
%\iffalse
\documentclass[full]{l3doc}
\begin{document}
\DocInput{\filename.\filenameext}
\end{document}
%</driver>
%\fi
%
%\section{Finalising \textsf{expl3}}
%
% This module is the end of \pkg{expl3}, and finishes off the 
% format. It also contains the loading code for the rest of \LaTeX3.
% 
%\begin{function}{\par} 
%  \begin{syntax}
%    "\par"
%  \end{syntax}
%  \cs{par} needs to be defined, as \TeX\ uses it in some runaway 
%  situtations.
%\end{function}
% 
%\begin{function}{\latex_format_dump:} 
%  \begin{syntax}
%    "\latex_format_dump:"
%  \end{syntax}
%  Dumps the format, settting category codes back to user space and
%  undefines itself (as it can only every be used once).
%\end{function}
%
%\subsection{Higher-level \LaTeX3}
%
% Here, the rest of \LaTeX3 is loaded in a `chain'.
%    \begin{macrocode}
\clist_map_inline:nn {
  xparse    ,
  xtemplate ,
} { \file_input_no_record:n { #1 .ltx } }
%    \end{macrocode}
%
%\subsection{Dumping the format}
%
%\begin{macro}{\par}
% \TeX\ has a nasty habit of inserting a command with the name \cs{par}
% so we had better make sure that that command at least has a definition.
%    \begin{macrocode}
%<*initex>
\cs_set_eq:NN \par \tex_par:D
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ExplSyntaxOff}
% We re-define \cs{ExplSyntaxOff} as the version that comes through 
% from \pkg{l3names} is defined using \TeX\ primitives, which we no
% longer have! Here, we can also make a fixed decision about the 
% category codes to fix.
%    \begin{macrocode}
%<*initex>
\cs_set_nopar:Npn \ExplSyntaxOff {
  \intexpr_if_odd:nT { \ExplSyntaxStatus } {
    \tl_set:Nn \ExplSyntaxStatus { 0 }
    \char_set_catcode:nn { 126 } { 13 }
    \char_set_catcode:nn { 32 } { 10 }
    \char_set_catcode:nn { 9 } { 10 }
    \char_set_catcode:nn { 95 } { 8 }
    \char_set_catcode:nn { 58 } { 12 }
    \tex_endlinechar:D = 13 \scan_stop:
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\latex_format_dump:}
% The last action to take is to dump the format. So that the document
% starts with user category codes, \cs{ExplSyntaxOff} is called along
% with tokenizing \cs{tex_dump:D} before actually calling it.
%    \begin{macrocode}
\cs_new_nopar:Npn \latex_format_dump: {
  \ExplSyntaxOff
  \cs_gundefine:N \latex_format_dump:  
  \tex_dump:D
}
\latex_format_dump:
%</initex>
%    \end{macrocode}
%\end{macro}
%
%\endinput
