summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-syntax.mkiv
blob: 658343ac560aaa26680c9abe618397bb85edc4c0 (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
   \enforced\let\Indent          \module_syntax_Indent
   \enforced\let\Sugar           \module_syntax_Sugar
   \enforced\let\Something       \module_syntax_Something
   \enforced\let\Lbrace          \module_syntax_Lbrace
   \enforced\let\Rbrace          \module_syntax_Rbrace
   \enforced\let\Lparent         \module_syntax_Lparent
   \enforced\let\Rparent         \module_syntax_Rparent
   \enforced\let\Lbracket        \module_syntax_Lbracket
   \enforced\let\Rbracket        \module_syntax_Rbracket
   \enforced\let\Or              \module_syntax_Or
   \enforced\let\Optional        \module_syntax_Optional
   \enforced\let\Means           \module_syntax_Means
   \enforced\let\Tex             \module_syntax_Tex
   \enforced\let\Literal         \module_syntax_Literal
   \enforced\let\Syntax          \module_syntax_Syntax
   \enforced\let\Next            \module_syntax_Next
   \enforced\let\Whatever        \module_syntax_Whatever
   \enforced\let\Quote           \module_syntax_Quote
   \enforced\let\Or              \module_syntax_Or
   \enforced\let\Means           \module_syntax_Means
   \enforced\let\FlaggedLiteral  \module_syntax_FlaggedLiteral
   \enforced\let\FlaggedSomething\module_syntax_FlaggedSomething
   % shortcuts
   \enforced\let\FL              \module_syntax_FlaggedLiteral
   \enforced\let\FS              \module_syntax_FlaggedSomething
   \enforced\let\L               \module_syntax_Literal
   \enforced\let\S               \module_syntax_Something
   \enforced\let\M               \module_syntax_Means
   \enforced\let\N               \module_syntax_Next
   \enforced\let\O               \module_syntax_Or
   \enforced\let\Q               \module_syntax_Quote
   \enforced\let\LB              \module_syntax_Lbrace
   \enforced\let\RB              \module_syntax_Rbrace
   \enforced\let\LP              \module_syntax_Lparent
   \enforced\let\RP              \module_syntax_Rparent
   \enforced\let\LS              \module_syntax_Lbracket
   \enforced\let\RS              \module_syntax_Rbracket
   \enforced\let\{               \module_syntax_Lbrace
   \enforced\let\}               \module_syntax_Rbrace
   \enforced\let\(               \module_syntax_Lparent
   \enforced\let\)               \module_syntax_Rparent
   \enforced\let\[               \module_syntax_Lbracket
   \enforced\let\]               \module_syntax_Rbracket
   % precaution
   \catcode`\#\othercatcode}

\unexpanded\def\StopSyntax
  {\stoplines}

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

\protect \endinput