1@Section
2  @Tag { lexical }
3  @Title { Lexical structure (words, spaces, symbols) and macros }
4@Begin
5@PP
6The input to Lout consists of a sequence of @I {textual units},
7textual.unit @Index {Textual unit }
8which may be
9either {@I{white spaces}},
10@I identifiers,
11@I delimiters,
12or
13@I {literal words}.  Each
14is a sequence of @I characters chosen from:
15letter @Index { Letter character }
16other @Index { Other character }
17quote @Index { Quote character }
18escape @Index { Escape character }
19comment.char @Index { Comment character }
20underscore.char @Index { Underscore character }
21@ID @Tab
22    vmargin { 0.5vx }
23    @Fmta { @Col A ! @Col B }
24{
25@Rowa A { letter      } B { @Code "@ab-zAB-Z_" }
26@Rowa A { white space } B { @I { space  formfeed  tab  newline } }
27@Rowa A { quote       } B { @Code "\"" }
28@Rowa A { escape      } B { @Code "\\" }
29@Rowa A { comment     } B { @Code "#" }
30@Rowa A { other       } B { @Code "!$%&'()*+,-./0123456789:;<=>?[]^`{|}~" }
31}
32Notice that @Code "@" and @Code "_" are classed as letters.  Basser
33Lout accepts the accented letters of the ISO-LATIN-1 character set
34(depending on how it is installed), and these are also classed as
35letters.  The ten digits are classed as `other' characters, and in
36fact the `other' class contains all 8-bit characters (except octal 0)
37not assigned to previous classes.
38@PP
39A @I {white space} is a sequence of one or more white space characters.
40white.space @Index { White space }
41formfeed @Index { Formfeed }
42space.f @Index { Space }
43 Lout treats the formfeed character exactly like the space character;
44it is useful for getting page breaks when printing Lout source code.
45@PP
46A @I delimiter is a sequence of one or more `other' characters which
47delimiter @Index { Delimiter }
48is the name of a symbol.  For example, @Code "{" and @Code "//" are
49delimiters.  When defining a delimiter, the name must be enclosed
50in quotes:
51@ID @Code {
52"def  \"^\"  { {}  ^&  {} }"
53}
54but quotes are not used when the delimiter is invoked.  A delimiter may
55have delimiters and any other characters adjacent, whereas identifiers
56may not be adjacent to letters or other identifiers.  The complete list
57of predefined delimiters is
58@ID @OneRow @Code {
59{
60      "/"
61  @JL "//"
62  @JL "^/"
63  @JL "^//"
64} |2.2cx {
65      "|"
66  @JL "||"
67  @JL "^|"
68  @JL "^||"
69} |2.2cx {
70      "&"
71  @JL "^&"
72} |2.2cx {
73      "&&"
74  @JL "{"
75  @JL "}"
76}
77}
78A longer delimiter like @Code "<=" will be recognised in
79preference to a shorter one like {@Code "<"}.
80@PP
81An @I identifier is a sequence of one or more letters which is the name of a
82identifier @Index { Identifier }
83symbol.  It is conventional but not essential to begin identifiers with
84{@Code "@"};  Basser Lout will print a warning message if it finds an
85unquoted literal word (see below) beginning with {@Code "@"}, since such
86words are usually misspelt identifiers.  The ten digits are not letters
87and may not appear in identifiers; and although the underscore character
88is a letter and may be used in identifiers, it is not conventional to
89do so.  The complete list of predefined identifiers is
90@CD @OneRow @Code {
91{     "@BackEnd"
92  @JL "@Background"
93  @JL "@Begin"
94  @JL "@BeginHeaderComponent"
95  @JL "@Break"
96  @JL "@Case"
97  @JL "@ClearHeaderComponent"
98  @JL "@Common"
99  @JL "@Char"
100  @JL "@CurrFace"
101  @JL "@CurrFamily"
102  @JL "@CurrLang"
103  @JL "@CurrYUnit"
104  @JL "@CurrZUnit"
105  @JL "@Database"
106  @JL "@Enclose"
107  @JL "@End"
108  @JL "@EndHeaderComponent"
109  @JL "@Filter"
110  @JL "@FilterErr"
111  @JL "@FilterIn"
112  @JL "@FilterOut"
113  @JL "@Font"
114  @JL "@FontDef"
115  @JL "@ForceGalley"
116  @JL "@Galley"
117  @JL "@GetContext"
118  @JL "@Graphic"
119  @JL "@HAdjust"
120  @JL "@HContract"
121  @JL "@HCover"
122  @JL "@HExpand"
123  @JL "@High"
124  @JL "@HLimited"
125  @JL "@HMirror"
126  @JL "@HScale"
127  @JL "@HShift"
128} |4.4cx {
129      "@HSpan"
130  @JL "@Include"
131  @JL "@IncludeGraphic"
132  @JL "@IncludeGraphicRepeated"
133  @JL "@Insert"
134  @JL "@KernShrink"
135  @JL "@Key"
136  @JL "@Language"
137  @JL "@LClos"
138  @JL "@LEnv"
139  @JL "@LInput"
140  @JL "@LUse"
141  @JL "@LinkSource"
142  @JL "@LinkDest"
143  @JL "@Meld"
144  @JL "@Merge"
145  @JL "@Minus"
146  @JL "@Moment"
147  @JL "@Next"
148  @JL "@NotRevealed"
149  @JL "@Null"
150  @JL "@OneCol"
151  @JL "@OneOf"
152  @JL "@OneRow"
153  @JL "@Open"
154  @JL "@Optimize"
155  @JL "@Outline"
156  @JL "@PAdjust"
157  @JL "@PageLabel"
158  @JL "@PlainGraphic"
159  @JL "@Plus"
160  @JL "@PrependGraphic"
161  @JL "@RawVerbatim"
162  @JL "@Rotate"
163  @JL "@Rump"
164  @JL "@Scale"
165  @JL "@SetColor"
166} |4.4cx {
167      "@SetColour"
168  @JL "@SetContext"
169  @JL "@SetHeaderComponent"
170  @JL "@Space"
171  @JL "@StartHSpan"
172  @JL "@StartHVSpan"
173  @JL "@StartVSpan"
174  @JL "@SysDatabase"
175  @JL "@SysInclude"
176  @JL "@SysIncludeGraphic"
177  @JL "@SysIncludeGraphicRepeated"
178  @JL "@SysPrependGraphic"
179  @JL "@Tag"
180  @JL "@Tagged"
181  @JL "@Target"
182  @JL "@Texture"
183  @JL "@SetTexture"
184  @JL "@Underline"
185  @JL "@SetUnderlineColor"
186  @JL "@SetUnderlineColour"
187  @JL "@Use"
188  @JL "@URLLink"
189  @JL "@VAdjust"
190  @JL "@VContract"
191  @JL "@VCover"
192  @JL "@Verbatim"
193  @JL "@VExpand"
194  @JL "@VLimited"
195  @JL "@VMirror"
196  @JL "@VScale"
197  @JL "@VShift"
198  @JL "@VSpan"
199  @JL "@Wide"
200  @JL "@Yield"
201  @JL "@YUnit"
202  @JL "@ZUnit"
203}
204}
205plus the names of the parameters of @@Moment.  The symbols @@LClos, @@LEnv,
206lclos @Index { @@LClos symbol }
207lenv @Index { @@LEnv symbol }
208linput @Index { @@LInput symbol }
209lvis @Index { @@LVis symbol }
210luse @Index { @@LUse symbol }
211@@LInput, @@LVis and @@LUse appear in cross reference databases generated
212by Lout and are not for use elsewhere.
213@PP
214A sequence of characters which is neither a white space, an identifier, nor a
215delimiter, is by default a @I {literal word}, which means that it will
216word @Index { Word }
217literal.word @Index { Literal word }
218quoted.word @Index { Quoted word }
219pass through Lout unchanged.  An arbitrary sequence of characters
220enclosed in double quotes, for example @Code "\"{  }\"", is also a
221literal word.  Space characters may be included, but not tabs or
222newlines.  There are special character sequences, used only between
223quotes, for obtaining otherwise inaccessible characters:
224@ID @Tab
225   vmargin { 0.5vx }
226   @Fmta { @Col A ! @Col B }
227{
228@Rowa A { @Code "\\\""   } B { produces @Code "\"" }
229@Rowa A { @Code "\\\\"   } B { "\\" }
230@Rowa A { @Code "\\ddd"  } B { the character whose ASCII code is }
231@Rowa A {                } B { the up to three digit octal number {@Code ddd} }
232}
233So, for example, @Code "\"\\\"@PP\\\"\"" produces {@Code "\"@PP\""}.
234@PP
235When the comment character
236comment @Index { Comment }
237@Code "#" is encountered, everything from
238that point to the end of the line is ignored.  This is useful for
239including reminders to oneself, like this:
240@ID @OneRow @Code {
241"# Lout user manual"
242"# J. Kingston, June 1989"
243}
244for temporarily deleting parts of the document, and so on.
245@PP
246@I Macros
247macro @Index { Macro }
248provide a means of defining symbols which stand for a
249sequence of textual units rather than an object.  For example, the macro
250definition
251@ID @Code {
252"macro  @PP  {  //1.3vx  2.0f @Wide  &0i }"
253}
254makes Lout replace the symbol @Code "@PP" by the given textual units
255before assembling its input into objects.  A similar macro to this
256one is used to separate the paragraphs of the present document.  The
257enclosing braces and any spaces adjacent to them are dropped, which can
258be a problem:  @Code "@PP2i" has result {@Code "//1.3vx 2.0f @Wide &0i2i"}
259which is erroneous.
260@PP
261The meaning of symbols used within the body of a macro is determined by
262where the macro is defined, not by where it is used.  Due to implementation
263problems, @@Open symbols will not work within macros.  Named and body
264parameters will work if the symbol that they are parameters of is also
265present.  There is no way to get a left or right brace into the body of
266a macro without the matching brace.
267@PP
268Macros may be nested within other definitions and exported, but they may
269not be parameters.  They may not have parameters or nested definitions
270of their own, and consequently a preceding @Code export clause (Section
271{@NumberOf visibility}) would be pointless; however, an @Code import
272clause is permitted.
273@End @Section
274