3 %%% Description of the parsing machinery
5 %%% (c) 2015 Straylight/Edgeware
8 %%%----- Licensing notice ---------------------------------------------------
10 %%% This file is part of the Sensible Object Design, an object system for C.
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 \chapter{Parsing
} \label{ch:parsing
}
28 %%%--------------------------------------------------------------------------
29 \section{The parser protocol
} \label{sec:parsing.proto
}
31 For the purpose of Sod's parsing library,
\emph{parsing
} is the process of
32 reading a sequence of input items, in order, and computing an output value.
34 A
\emph{parser
} is an expression which consumes zero or more input items and
35 returns three values: a
\emph{result
}, a
\emph{success flag
}, and a
36 \emph{consumed flag
}. The two flags are (generalized) booleans. If the
37 success flag is non-nil, then the parser is said to have
\emph{succeeded
},
38 and the result is the parser's output. If the success flag is nil then the
39 parser is said to have
\emph{failed
}, and the result is a list of
40 \emph{indicators
}. Finally, the consumed flag is non-nil if the parser
41 consumed any input items.
43 \begin{describe
}{fun
}{combine-parser-failures @<failures> @> @<list>
}
46 \begin{describe
}{fun
}{parse-empty \&optional @<value> @> @<function>
}
50 {parse-fail @<indicator> \&optional @<consumedp> @> @<function>
}
53 %%%--------------------------------------------------------------------------
54 \section{File locations
} \label{sec:parsing.floc
}
56 \begin{describe
}{cls
}{file-location
}
59 \begin{describe
}{fun
}{file-location-p @<object> @> @<generalized-boolean>
}
63 {make-file-location @<filename> \&optional @<line> @<column>
68 {\dhead{fun
}{file-location-filename @<floc> @> @<string-or-nil>
}
69 \dhead{fun
}{file-location-line @<floc> @> @<fixnum-or-nil>
}
70 \dhead{fun
}{file-location-column @<floc> @> @<fixnum-or-nil>
}}
73 \begin{describe
}{gf
}{file-location @<object> @> @<floc>
}
74 \begin{describe
}{meth
}{file-location (@<floc> file-location) @> @<floc>
}
76 \begin{describe
}{meth
}{file-location (@<stream> stream) @> @<floc>
}
78 \begin{describe
}{meth
}{file-location (@<any> t) @> @<floc>
}
82 \begin{describe
}{cls
}{condition-with-location (condition) \&key :location
}
85 \begin{describe
}{meth
}
86 {file-location (@<condition> condition-with-location) @> @<floc>
}
92 {error-with-location (condition-with-location error) \\ \>
95 {warning-with-location (condition-with-location warning) \\ \>
98 {information-with-location (condition-with-location information) \\ \>
101 {enclosing-error-with-location
102 (enclosing-error-with-location error) \\ \>
103 \&key :condition :location
}
105 {enclosing-warning-with-location
106 (enclosing-condition-with-location warning) \\ \>
107 \&key :condition :location
}
109 {enclosing-information-with-location
110 (enclosing-condition-with-location information) \\ \>
111 \&key :condition :location
}
113 {simple-condition-with-location
114 (condition-with-location simple-condition) \\ \>
115 \&key :format-control :format-arguments :location
}
117 {simple-error-with-location
118 (error-with-location simple-error) \\ \>
119 \&key :format-control :format-arguments :location
}
121 {simple-warning-with-location
122 (warning-with-location simple-warning) \\ \>
123 \&key :format-control :format-arguments :location
}
125 {simple-information-with-location
126 (information-with-location simple-information) \\ \>
127 \&key :format-control :format-arguments :location
}}
131 {enclosing-condition-with-location-type @<condition> @> @<symbol>
}
134 \begin{describe
}{fun
}
135 {make-condition-with-location @<default-type> @<floc>
136 @<datum> \&rest @<arguments>
137 \nlret @<condition-with-location>
}
141 {\dhead{fun
}{error-with-location @<floc> @<datum> \&rest @<arguments>
}
142 \dhead{fun
}{cerror-with-location @<floc> @<continue-string>
143 @<datum> \&rest @<arguments>
}
144 \dhead{fun
}{cerror*-with-location @<floc> @<datum> \&rest @<arguments>
}
145 \dhead{fun
}{warn-with-location @<floc> @<datum> \&rest @<arguments>
}}
149 {\dhead{cls
}{parser-error (error) \\
\ind
150 \&key :expected :found \-
}
151 \dhead{gf
}{parser-error-expected @<condition> @> @<list>
}
152 \dhead{gf
}{parser-error-found @<condition> @> @<value>
}}
155 \begin{describe
}{fun
}
156 {report-parser-error @<error> @<stream> @<show-expected> @<show-found>
}
161 \dhead{cls
}{base-lexer-error (error-with-location) \&key :location
}
162 \dhead{cls
}{simple-lexer-error
163 (base-lexer-error simple-error-with-location) \\\>
164 \&key :format-control :format-arguments :location
}
165 \dhead{cls
}{base-syntax-error (error-with-location) \&key :location
}
166 \dhead{cls
}{simple-syntax-error
167 (base-syntax-error simple-error-with-location) \\\>
168 \&key :format-control :format-arguments :location
}}
171 \begin{describe
}{mac
}
172 {with-default-error-location (@<floc>) @<declaration>^* @<form>^*
176 \begin{describe
}{gf
}{classify-condition @<condition> @> @<string>
}
178 {\dhead{meth
}{classify-condition (@<condition> error) @> @<string>
}
179 \dhead{meth
}{classify-condition (@<condition> warning) @> @<string>
}
180 \dhead{meth
}{classify-condition (@<condition> information)
182 \dhead{meth
}{classify-condition (@<condition> base-lexer-error)
184 \dhead{meth
}{classify-condition (@<condition> base-syntax-error)
189 \begin{describe
}{mac
}
190 {count-and-
report-errors () @<declaration>^* @<form>^*
191 @> @<value> @<n-errors> @<n-warnings>
}
194 %%%--------------------------------------------------------------------------
195 \section{Scanners
} \label{sec:parsing.scanner
}
197 A
\emph{scanner
} is an object which keeps track of a parser's progress as it
198 works through its input. There's no common base class for scanners: a
199 scanner is simply any object which implements the scanner protocol described
202 A scanner maintains a sequence of items to read. It can step forwards
203 through the items, one at a time, until it reaches the end (if, indeed, the
204 sequence is finite, which it needn't be). Until that point, there is a
205 current item, though there's no protocol for accessing it at this level
206 because the nature of the items is left unspecified.
208 Some scanners support an additional
\emph{place-capture
} protocol which
209 allows rewinding the scanner to an earlier point in the input so that it can
212 \subsection{Basic scanner protocol
} \label{sec:parsing.scanner.basic
}
214 The basic protocol supports stepping the scanner forward through its input
215 sequence, and detecting the end of the sequence.
217 \begin{describe
}{gf
}{scanner-step @<scanner>
}
218 Advance the @<scanner> to the next item, which becomes current.
220 It is an error to step the scanner if the scanner is at end-of-file.
223 \begin{describe
}{gf
}{scanner-at-eof-p @<scanner> @> @<generalized-boolean>
}
224 Return non-nil if the scanner is at end-of-file, i.e., there are no more
227 If nil is returned, there is a current item, and it is safe to step the
228 scanner again; otherwise, it is an error to query the current item or to
232 \subsection{Place-capture scanner protocol
} \label{sec:parsing.scanner.place
}
234 The place-capture protocol allows rewinding to an earlier point in the
235 sequence. Not all scanners support the place-capture protocol.
237 To rewind a scanner to a particular point, that point must be
\emph{captured
}
238 as a
\emph{place
} when it's current -- so you must know in advance that this
239 is an interesting place that's worth capturing. The type of place returned
240 depends on the type of scanner. Given a captured place, the scanner can be
241 rewound to the position held in it.
243 Depending on how the scanner works, holding onto a captured place might
244 consume a lot of memory or cause poor performance. For example, if the
245 scanner is reading from an input stream, having a captured place means that
246 data from that point on must be buffered in case the program needs to rewind
247 the scanner and read that data again. Therefore it's possible to
248 \emph{release
} a place when it turns out not to be needed any more.
250 \begin{describe
}{gf
}{scanner-capture-place @<scanner> @> @<place>
}
251 Capture the @<scanner>'s current position as a place, and return the place.
254 \begin{describe
}{gf
}{scanner-restore-place @<scanner> @<place>
}
255 Rewind the @<scanner> to the state it was in when @<place> was captured.
256 In particular, the item that was current when the @<place> was captured
257 becomes current again.
259 It is an error to restore a @<place> that has been released, or if the
260 @<place> wasn't captured from the @<scanner>.
263 \begin{describe
}{gf
}{scanner-release-place @<scanner> @<place>
}
264 Release the @<place>, to avoid having to maintaining the ability to restore
265 it after it's not needed any more..
267 It is an error if the @<place> wasn't captured from the @<scanner>.
270 \begin{describe
}{mac
}
271 {with-scanner-place (@<place> @<scanner>) @<declarations>^* @<form>^*
273 Capture the @<scanner>'s current position as a place, evaluate the @<form>s
274 as an implicit progn with the variable @<place> bound to the captured
275 place. When control leaves the @<form>s, the place is released. The
276 return values are the values of the final @<form>.
279 \subsection{Scanner file-location protocol
} \label{sec:parsing.scanner.floc
}
281 Some scanners participate in the file-location protocol
282 (
\xref{sec:parsing.floc
}). They implement a method on @|file-location| which
283 collects the necessary information using scanner-specific functions described
286 \begin{describe
}{fun
}{scanner-file-location @<scanner> @> @<file-location>
}
287 Return a @|file-location| object describing the current position of the
290 This calls the @|scanner-filename|, @|scanner-line| and @|scanner-column|
291 generic functions on the scanner, and uses these to fill in an appropriate
294 Since there are default methods on these generic functions, it is not an
295 error to call @|scanner-file-location| on any kind of value, but it might
296 not be very useful. This function exists to do the work of appropriately
297 specialized methods on @|file-location|.
301 {\dhead{gf
}{scanner-filename @<scanner> @> @<string>
}
302 \dhead{gf
}{scanner-line @<scanner> @> @<integer>
}
303 \dhead{gf
}{scanner-column @<scanner> @> @<integer>
}}
304 Return the filename, line and column components of the @<scanner>'s current
305 position, for use in assembling a @<file-location>: see the
306 @|scanner-file-location| function.
308 There are default methods on all three generic functions which simply
312 \subsection{Character scanners
} \label{sec:parsing.scanner.char
}
314 Character scanners are scanners which read sequences of characters.
316 \begin{describe
}{cls
}{character-scanner () \&key
}
317 Base class for character scanners. This provides some very basic
320 Not all character scanners are subclasses of @|character-scanner|.
323 \begin{describe
}{gf
}{scanner-current-char @<scanner> @> @<character>
}
324 Returns the current character.
327 \begin{describe
}{gf
}{scanner-unread @<scanner> @<character>
}
328 Rewind the @<scanner> by one step. The @<chararacter> must be the previous
329 current character, and becomes the current character again. It is an error
330 if: the @<scanner> has reached end-of-file; the @<scanner> has never been
331 stepped; or @<character> was not the previous current character.
335 {scanner-interval @<scanner> @<place-a> \&optional @<place-b>
337 Return the characters in the @<scanner>'s input from @<place-a> up to (but
338 not including) @<place-b>.
340 The characters are returned as a string. If @<place-b> is omitted, return
341 the characters up to (but not including) the current position. It is an
342 error if @<place-b> precedes @<place-a> or they are from different
345 This function is a character-scanner-specific extension to the
346 place-capture protocol; not all character scanners implement the
347 place-capture protocol, and some that do may not implement this function.
350 \subsubsection{Stream access to character scanners
}
351 Sometimes it can be useful to apply the standard Lisp character input
352 operations to the sequence of characters held by a character scanner.
354 \begin{describe
}{gf
}{make-scanner-stream @<scanner> @> @<stream>
}
355 Returns a fresh input @|stream| object which fetches input characters from
356 the character scanner object @<scanner>. Reading characters from the
357 stream steps the scanner. The stream will reach end-of-file when the
358 scanner reports end-of-file. If the scanner implements the file-location
359 protocol then reading from the stream will change the file location in an
362 This is mostly useful for applying standard Lisp stream functions, most
363 particularly the @|read| function, in the middle of a parsing operation.
366 \begin{describe
}{cls
}{character-scanner-stream (stream) \&key :scanner
}
367 A Common Lisp input @|stream| object which works using the character
368 scanner protocol. Any @<scanner> which implements the base scanner and
369 character scanner protocols is suitable. See @|make-scanner-stream|.
372 \subsection{String scanners
} \label{sec:parsing.scanner.string
}
374 A
\emph{string scanner
} is a simple kind of character scanner which reads
375 input from a string object. String scanners implement the character scanner
376 and place-capture protocols.
378 \begin{describe
}{cls
}{string-scanner
}
379 The class of string scanners. The @|string-scanner| class is not a
380 subclass of @|character-scanner|.
383 \begin{describe
}{fun
}{string-scanner-p @<value> @> @<generalized-boolean>
}
384 Return non-nil if @<value> is a @|string-scanner| object; otherwise return
388 \begin{describe
}{fun
}
389 {make-string-scanner @<string> \&key :start :end @> @<string-scanner>
}
390 Construct and return a fresh @|string-scanner| object. The new scanner
391 will read characters from @<string>, starting at index @<start> (which
392 defaults to zero), and continuing until it reaches index @<end> (defaults
393 to the end of the @<string>).
396 \subsection{Character buffer scanners
} \label{sec:parsing.scanner.charbuf
}
398 A
\emph{character buffer scanner
}, or
\emph{charbuf scanner
} for short, is an
399 efficient scanner for reading characters from an input stream. Charbuf
400 scanners implements the basic scanner, character buffer, place-capture, and
401 file-location protocols.
403 \begin{describe
}{cls
}
404 {charbuf-scanner (character-scanner)
405 \&key :stream :filename :line :column
}
406 The class of charbuf scanners. The scanner will read characters from
407 @<stream>. Charbuf scanners implement the file-location protocol: the
408 initial location is set from the given @<filename>, @<line> and @<column>;
409 the scanner will update the location as it reads its input.
412 \begin{describe
}{cls
}{charbuf-scanner-place
}
413 The class of place objects captured by a charbuf scanner.
416 \begin{describe
}{fun
}
417 {charbuf-scanner-place-p @<value> @> @<generalized-boolean>
}
418 Type predicate for charbuf scanner places: returns non-nil if @<value> is a
419 place captured by a charbuf scanner, and nil otherwise.
423 {charbuf-scanner-map @<scanner> @<func> \&optional @<fail>
424 \nlret @<result> @<success-flag> @<consumed-flag>
}
425 Read characters from the @<scanner>'s buffers.
427 This is intended to be an efficient and versatile interface for reading
428 characters from a scanner in bulk. The function @<func> is invoked
431 (multiple-value-bind (@<donep> @<used>) \\
\ind\ind
432 (funcall @<func> @<buf> @<start> @<end>) \-\\
435 The argument @<buf> is a simple string; @<start> and @<end> are two
436 nonnegative fixnums, indicating that the subsequence of @<buf> between
437 @<start> (inclusive) and @<end> (exclusive) should be processed. If
438 @<func>'s return value @<donep> is nil then @<used> is ignored: the
439 function has consumed the entire buffer and wishes to read more. If
440 @<donep> is non-nil, then @<used> must be a fixnum such that $@<start>
\le
441 @<used>
\le @<end>$: the function has consumed the buffer as far as @<used>
442 (exclusive) and has completed successfully.
444 If end-of-file is encountered before @<func> completes successfully then it
445 fails: the @<fail> function is called with no arguments, and is expected to
446 return two values. If omitted, @<fail> defaults to
452 The @|charbuf-scanner-map| function returns three values. The first value
453 is the non-nil @<donep> value returned by @<func> if @|charbuf-scanner-map|
454 succeeded, or the first value returned by @<fail>; the second value is @|t|
455 on success, or the second value returned by @<fail>; the third value is
456 non-nil if @<func> consumed any input, i.e., it returned with @<donep> nil
457 at least once, or with $@<used> > @<start>$.
460 \subsection{Token scanners
} \label{sec:parsing.scanner.token
}
462 \begin{describe
}{cls
}
463 {token-scanner () \&key :filename (:line
1) (:column
0)
}
466 \begin{describe
}{gf
}{token-type @<scanner> @> @<type>
}
469 \begin{describe
}{gf
}{token-value @<scanner> @> @<value>
}
472 \begin{describe
}{gf
}{scanner-token @<scanner> @> @<type> @<value>
}
475 \begin{describe
}{ty
}{token-scanner-place
}
478 \begin{describe
}{fun
}
479 {token-scanner-place-p @<value> @> @<generalized-boolean>
}
482 \subsection{List scanners
}
484 \begin{describe
}{ty
}{list-scanner
}
487 \begin{describe
}{fun
}{list-scanner-p @<value> @> @<generalized-boolean>
}
490 \begin{describe
}{fun
}{make-list-scanner @<list> @> @<list-scanner>
}
493 %%%--------------------------------------------------------------------------
494 \section{Parsing syntax
}
496 \begin{describe
}{gf
}{expand-parser-spec @<context> @<spec> @> @<form>
}
500 {expand-parser-form @<context> @<head> @<tail> @> @<form>
}
503 \begin{describe
}{gf
}{wrap-parser @<context> @<form> @> @<wrapped-form>
}
506 \begin{describe
}{mac
}
507 {defparse @<name> (@
[[ :context (@<var> @<context-class>) @
]]
508 @<destructuring-lambda-list-item>^*) \\
\ind
509 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
514 \begin{describe
}{mac
}
516 (@<context-class> @
{ @<init-keyword> @<value> @
}^*) \\
\ind
522 \begin{describe
}{lmac
}
523 {parse @<parser> @> @<result> @<success-flag> @<consumed-flag>
}
526 \begin{describe
}{mac
}
527 {parser @<lambda-list>
528 @
[[ @<declaration>^* @! @<doc-string> @
]]
533 \begin{describe
}{gf
}{parser-at-eof-p @<context> @> @<form>
}
536 \begin{describe
}{gf
}{parser-step @<context> @> @<form>
}
539 \begin{describe
}{sym
}{it
}
542 \begin{describe
}{mac
}
543 {if-parse (@
[[ \=:result @<result-var> @!
544 :expected @<expected-var> @! \+\\
545 :consumedp @<consumed-var> @
]]) \-\\
\ind\ind
552 \begin{describe
}{mac
}
553 {when-parse (@
[@<result-var>@
]) @<parser> \\
\ind
558 \begin{describe
}{mac
}
559 {cond-parse (@
[[ \=:result @<result-var> @!
560 :expected @<expected-var> @! \+\\
561 :consumedp @<consumed-var> @
]]) \-\\
\ind
562 @
{ (@<parser> @<form>^*) @
}^*
566 \begin{describe
}{parse
}{:eof
}
569 \begin{describe
}{parseform
}{lisp @<form>^*
}
572 \begin{describe
}{parseform
}{label @<parser>
}
575 \begin{describe
}{parse
}{t
}
578 \begin{describe
}{parseform
}{t @<value>
}
581 \begin{describe
}{parse
}{nil
}
584 \begin{describe
}{parseform
}{nil @<indicator>
}
587 \begin{describe
}{parseform
}{when @<cond> @<parser>
}
590 \begin{describe
}{parseform
}
591 {seq (@
{ @<atomic-parser-spec> @!
592 (@
[@<var>@
] @<parser>) @
}^*) \\
\ind
596 \begin{describe
}{parseform
}{and @<parser>^*
}
599 \begin{describe
}{parseform
}{or @<parser>^*
}
602 \begin{describe
}{parseform
}{? @<parser> @
[@<default>@
]}
605 \begin{describe
}{parseform
}
606 {many (\=@<accumulator-var> @<init-form> @<update-form> \+\\
607 @
[[ \=:new @<new-var> @! :final @<final-form> @! \+\\
608 :min @<minimum> @! :max @<maximum> @! \\
609 :commitp @<commitp> @
]]) \-\-\\
\ind
610 @<item-parser> @
[@<sep-parser>@
]}
613 \begin{describe
}{parseform
}
614 {list (@
[[ :min @<minimum> @! :max @<maximum> @!
615 :commitp @<commitp> @
]]) \\
\ind
616 @<item-parser> @
[@<sep-parser>@
]}
619 \begin{describe
}{parseform
}
620 {skip-many (@
[[ :min @<minimum> @! :max @<maximum> @!
621 :commitp @<commitp> @
]]) \\
\ind
622 @<item-parser> @
[@<sep-parser>@
]}
625 \begin{describe
}{fun
}{call-pluggable-parser @<symbol> \&rest @<args>
}
628 \begin{describe
}{parseform
}{plug @<symbol> @<arg>^*
}
631 \begin{describe
}{fun
}
632 {pluggable-parser-add @<symbol> @<tag> @<parser-function>
}
635 \begin{describe
}{mac
}
636 {define-pluggable-parser @<symbol> @<tag> @<lambda-list>
637 @
[[ @<declaration>^* @! @<doc-string> @
]]
641 \begin{describe
}{gf
}{parser-capture-place @<context> @> @<form>
}
644 \begin{describe
}{gf
}{parser-restore-place @<context> @<place> @> @<form>
}
647 \begin{describe
}{gf
}{parser-release-place @<context> @<place> @> @<form>
}
651 {parser-places-must-be-released-p @<context> @> @<generalized-boolean>>
}
654 \begin{describe
}{mac
}
655 {with-parser-place (@<place-var> @<context>)
656 @
[[ @<declaration>^* @! @<doc-string> @
]]
660 \begin{describe
}{parseform
}{peek @<parser>
}
663 \begin{describe
}{parseform
}{commit
}
666 \begin{describe
}{cls
}{character-parser-context () \&key
}
669 \begin{describe
}{gf
}{parser-current-char @<context> @> @<form>
}
672 \begin{describe
}{parseform
}
673 {if-char (@
[@<result-var>@
]) @<condition> @<consequent> @<alternative>
}
676 \begin{describe
}{parseform
}{char @<character>
}
679 \begin{describe
}[char
]{parse
}{@<character>
}
682 \begin{describe
}[string
]{parse
}{@<string>
}
685 \begin{describe
}{parse
}{:any
}
688 \begin{describe
}{parseform
}{satisfies @<predicate>
}
691 \begin{describe
}{parseform
}{not @<character>
}
694 \begin{describe
}{parseform
}{filter @<predicate>
}
697 \begin{describe
}{parse
}{:whitespace
}
700 \begin{describe
}{cls
}{token-parser-context () \&key
}
703 \begin{describe
}{gf
}{parser-token-type @<context> @> @<form>
}
706 \begin{describe
}{gf
}{parser-token-value @<context> @> @<form>
}
709 \begin{describe
}{parseform
}{token @<type> @
[@<value>@
] @
[:peekp @<peek>@
]}
712 \begin{describe
}[atom
]{parse
}{@<atom>
}
715 \begin{describe
}[string
]{parse
}{@<string>
}
718 \begin{describe
}{cls
}{scanner-context () \&key :scanner
}
721 \begin{describe
}{gf
}{parse-scanner @<context> @> @<symbol>
}
724 \begin{describe
}{cls
}
725 {character-scanner-context (scanner-context character-parser-context)
729 \begin{describe
}{cls
}
730 {token-scanner-context (scanner-context token-parser-context)
734 \begin{describe
}{gf
}{push-operator @<operator> @<state>
}
737 \begin{describe
}{gf
}{push-value @<value> @<state>
}
740 \begin{describe
}{gf
}{apply-operator @<operator> @<state>
}
743 \begin{describe
}{gf
}{operator-push-action @<left> @<right>
}
746 \begin{describe
}{parseform
}
747 {expr \=(@
[[ :nestedp @<nestedp-var> @
]]) \+\\
748 @<operand-parser> @<binop-parser>
749 @<preop-parser> @<postop-parser>
}
752 \begin{describe
}{gf
}{operator-left-precedence @<operator> @> @<prec>
}
755 \begin{describe
}{gf
}{operator-right-precedence @<operator> @> @<prec>
}
758 \begin{describe
}{gf
}{operator-associativity @<operator> @> @<assoc>
}
761 \begin{describe
}{cls
}{prefix-operator () \&key
}
764 \begin{describe
}{cls
}{simple-operator () \&key :name :function
}
767 \begin{describe
}{cls
}
768 {simple-unary-operator (simple-operator) \&key :name :function
}
773 \dhead{cls
}{simple-binary-operator (simple-operator) \\ \>
774 \&key :name :function
775 :lprec :rprec :associativity
}
776 \dhead{cls
}{simple-postfix-operator (simple-unary-operator) \\ \>
777 \&key :name :function :lprec :rprec
}
778 \dhead{cls
}{simple-prefix-operator
779 (prefix-operator simple-unary-operator) \\ \>
780 \&key :name :function :rprec
}}
784 {\dhead{mac
}{preop @<name> (@<operand-var> @<lprec>)
785 @<declaration>^* @<form>^*
786 @> @<prefix-operator>
}
787 \dhead{mac
}{postop @<name>
788 (@<operand-var> @<lprec> @
[[ :rprec @<rprec> @
]])
789 @<declaration>^* @<form>^*
790 \nlret @<postfix-operator>
}
791 \dhead{mac
}{binop @<name> (@<operand-var> @<lprec> @<rprec> @<assoc>)
792 @<declaration>^*@<form>^*
793 @> @<binary-operator>
}}
797 {\dhead{cls
}{parenthesis () \&key :tag
}
798 \dhead{cls
}{open-parenthesis (parenthesis prefix-operator) \&key :tag
}
799 \dhead{cls
}{close-parenthesis (parenthesis) \&key :tag
}}
803 {\dhead{fun
}{lparen @<tag> @> @<open-paren>
}
804 \dhead{fun
}{rparen @<tag> @> @<close-paren>
}}
807 %%%-------------------------------------------------------------------------
808 \section{Lexical analyser
}
810 \begin{describe
}{cls
}
811 {sod-token-scanner (token-scanner)
812 \&key :filename (:line
1) (:column
0) :char-scanner
}
815 \begin{describe
}{fun
}{define-indicator @<indicator> @<description>
}
819 {\dhead{cls
}{lexer-error (parser-error base-lexer-error) \\
\ind
820 \&key :expected :found :location \-
}
821 \dhead{cls
}{syntax-error (parser-error base-syntax-error) \\
\ind
822 \&key :expected :found :location \-
}}
825 \begin{describe
}{fun
}
826 {syntax-error @<scanner> @<expected> \&key :continuep :location
}
829 \begin{describe
}{fun
}
830 {lexer-error @<char-scanner> @<expected> \&key :location
}
833 \begin{describe
}{parseform
}
834 {skip-until (@
[[ :keep-end @<keep-end-flag> @
]]) @<token-type>^*
}
837 \begin{describe
}{parseform
}
838 {error (@
[[ :ignore-unconsumed @<flag> @!
839 :force-process @<flag> @
]]) \\
\ind\ind
840 @<sub-parser> @<recover-parser> \-\\
845 \begin{describe
}{parseform
}{must @<sub-parser> @
[@<default>@
]}
848 \begin{describe
}{fun
}
849 {scan-comment @<char-scanner>
850 @> @<result> @<success-flag> @<consumed-flag>
}
853 %%%----- That's all, folks --------------------------------------------------
857 %%% TeX-master: "sod.tex"