summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/modules/mkiv/s-syntax.mkiv
blob: d9492af3e54eba0780199a7b7925566f4a377060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
%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