%D \module
%D   [      file=s-syntax, % was: s-syn-01,
%D        version=0000.00.00,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Preliminary Syntax Stuff,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \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 This is needed for the \METAFUN\ manual: quite old code that I would do
%D differently nowadays.

\unprotect

\unexpanded\def\module_syntax_Indent          #1{\ifvmode\noindent\hbox to 2em{\hss#1}\else#1\fi}
\unexpanded\def\module_syntax_Sugar           #1{\removeunwantedspaces\kern.25em{#1}\kern.25em\ignorespaces}
\unexpanded\def\module_syntax_Something       #1{\Sugar{\mathematics{\langle\hbox{#1}\rangle}}}
\unexpanded\def\module_syntax_Lbrace            {\Sugar{\tttf\leftargument}}
\unexpanded\def\module_syntax_Rbrace            {\Sugar{\tttf\rightargument}}
\unexpanded\def\module_syntax_Lparent           {\Sugar{\tttf(}}
\unexpanded\def\module_syntax_Rparent           {\Sugar{\tttf)}}
\unexpanded\def\module_syntax_Lbracket          {\Sugar{\tttf[}}
\unexpanded\def\module_syntax_Rbracket          {\Sugar{\tttf]}}
\unexpanded\def\module_syntax_Or                {\Sugar{\mathematics{\vert}}}
\unexpanded\def\module_syntax_Optional        #1{\Sugar{\mathematics{[\hbox{#1}]}}}
\unexpanded\def\module_syntax_Means             {\Sugar{\mathematics{\rightarrow}}}
\unexpanded\def\module_syntax_Tex             #1{\Sugar{\type{#1}}}
\unexpanded\def\module_syntax_Literal         #1{\Sugar{\type{#1}}}
\unexpanded\def\module_syntax_Syntax          #1{\strut\kern-.25em{#1}\kern-.25em}
\unexpanded\def\module_syntax_Next              {\par\strut\kern4em} % {\crlf\hbox to 2em{}\nobreak}
\unexpanded\def\module_syntax_Whatever        #1{\Sugar{\mathematics{(\hbox{#1})}}}
\unexpanded\def\module_syntax_Quote           #1{\Sugar{\quote{#1}}}
\unexpanded\def\module_syntax_Or                {\Sugar{\module_syntax_Indent{\mathematics{\vert}}}}
\unexpanded\def\module_syntax_Means             {\Sugar{\module_syntax_Indent{\mathematics{\rightarrow}}}}
\unexpanded\def\module_syntax_FlaggedLiteral  #1{\color[darkred]{\module_syntax_Literal{#1}}}
\unexpanded\def\module_syntax_FlaggedSomething#1{\module_syntax_Something{\color[darkred]{#1}}}

\unexpanded\def\StartSyntax
  {\startlines
   % formatters
   \let\Indent          \module_syntax_Indent
   \let\Sugar           \module_syntax_Sugar
   \let\Something       \module_syntax_Something
   \let\Lbrace          \module_syntax_Lbrace
   \let\Rbrace          \module_syntax_Rbrace
   \let\Lparent         \module_syntax_Lparent
   \let\Rparent         \module_syntax_Rparent
   \let\Lbracket        \module_syntax_Lbracket
   \let\Rbracket        \module_syntax_Rbracket
   \let\Or              \module_syntax_Or
   \let\Optional        \module_syntax_Optional
   \let\Means           \module_syntax_Means
   \let\Tex             \module_syntax_Tex
   \let\Literal         \module_syntax_Literal
   \let\Syntax          \module_syntax_Syntax
   \let\Next            \module_syntax_Next
   \let\Whatever        \module_syntax_Whatever
   \let\Quote           \module_syntax_Quote
   \let\Or              \module_syntax_Or
   \let\Means           \module_syntax_Means
   \let\FlaggedLiteral  \module_syntax_FlaggedLiteral
   \let\FlaggedSomething\module_syntax_FlaggedSomething
   % shortcuts
   \let\FL              \module_syntax_FlaggedLiteral
   \let\FS              \module_syntax_FlaggedSomething
   \let\L               \module_syntax_Literal
   \let\S               \module_syntax_Something
   \let\M               \module_syntax_Means
   \let\N               \module_syntax_Next
   \let\O               \module_syntax_Or
   \let\Q               \module_syntax_Quote
   \let\LB              \module_syntax_Lbrace
   \let\RB              \module_syntax_Rbrace
   \let\LP              \module_syntax_Lparent
   \let\RP              \module_syntax_Rparent
   \let\LS              \module_syntax_Lbracket
   \let\RS              \module_syntax_Rbracket
   \let\{               \module_syntax_Lbrace
   \let\}               \module_syntax_Rbrace
   \let\(               \module_syntax_Lparent
   \let\)               \module_syntax_Rparent
   \let\[               \module_syntax_Lbracket
   \let\]               \module_syntax_Rbracket
   % precaution
   \catcode`\#\othercatcode}

\unexpanded\def\StopSyntax
  {\stoplines}

\unexpanded\def\SyntaxCommand#1%
  {\csname module_syntax_#1\endcsname}

\protect \endinput
