X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/da901cf29aae60b244bd9fcee72a5a2f59d359f2..5f32b8fda0421d16fc3455d1ce9aef746afbd818:/doc/parsing.tex diff --git a/doc/parsing.tex b/doc/parsing.tex index c04ab56..51cc5bb 100644 --- a/doc/parsing.tex +++ b/doc/parsing.tex @@ -89,33 +89,48 @@ consumed any input items. \begin{describe*} {\quad\=\quad\=\kill \dhead{cls} - {error-with-location (condition-with-location error) \\ \> - \&key :location} - \dhead{cls} - {warning-with-location (condition-with-location warning) \\ \> - \&key :location} - \dhead{cls} - {enclosing-error-with-location - (enclosing-error-with-location error) \\ \> - \&key :condition :location} - \dhead{cls} - {enclosing-warning-with-location - (enclosing-condition-with-location warning) \\ \> - \&key :condition :location} + {error-with-location (condition-with-location error) \\ \> + \&key :location} \dhead{cls} - {simple-condition-with-location - (condition-with-location simple-condition) \\ \> - \&key :format-control :format-arguments :location} + {warning-with-location (condition-with-location warning) \\ \> + \&key :location} \dhead{cls} - {simple-error-with-location - (error-with-location simple-error) \\ \> - \&key :format-control :format-arguments :location} - \dhead{cls} - {simple-warning-with-location - (warning-with-location simple-warning) \\ \> - \&key :format-control :format-arguments :location}} + {information-with-location (condition-with-location information) \\ \> + \&key :location} + \dhead{cls} + {enclosing-error-with-location + (enclosing-error-with-location error) \\ \> + \&key :condition :location} + \dhead{cls} + {enclosing-warning-with-location + (enclosing-condition-with-location warning) \\ \> + \&key :condition :location} + \dhead{cls} + {enclosing-information-with-location + (enclosing-condition-with-location information) \\ \> + \&key :condition :location} + \dhead{cls} + {simple-condition-with-location + (condition-with-location simple-condition) \\ \> + \&key :format-control :format-arguments :location} + \dhead{cls} + {simple-error-with-location + (error-with-location simple-error) \\ \> + \&key :format-control :format-arguments :location} + \dhead{cls} + {simple-warning-with-location + (warning-with-location simple-warning) \\ \> + \&key :format-control :format-arguments :location} + \dhead{cls} + {simple-information-with-location + (information-with-location simple-information) \\ \> + \&key :format-control :format-arguments :location}} \end{describe*} +\begin{describe}{gf} + {enclosing-condition-with-location-type @ @> @} +\end{describe} + \begin{describe}{fun} {make-condition-with-location @ @ @ \&rest @ @@ -130,11 +145,47 @@ consumed any input items. \dhead{fun}{warn-with-location @ @ \&rest @}} \end{describe*} +\begin{describe*} + {\dhead{cls}{parser-error (error) \\ \ind + \&key :expected :found \-} + \dhead{gf}{parser-error-expected @ @> @} + \dhead{gf}{parser-error-found @ @> @}} +\end{describe*} + +\begin{describe}{fun} + {report-parser-error @ @ @ @} +\end{describe} + +\begin{describe*} + {\quad\=\kill + \dhead{cls}{base-lexer-error (error-with-location) \&key :location} + \dhead{cls}{simple-lexer-error + (base-lexer-error simple-error-with-location) \\\> + \&key :format-control :format-arguments :location} + \dhead{cls}{base-syntax-error (error-with-location) \&key :location} + \dhead{cls}{simple-syntax-error + (base-syntax-error simple-error-with-location) \\\> + \&key :format-control :format-arguments :location}} +\end{describe*} + \begin{describe}{mac} {with-default-error-location (@) @^* @
^* @> @^*} \end{describe} +\begin{describe}{gf}{classify-condition @ @> @} + \begin{describe*} + {\dhead{meth}{classify-condition (@ error) @> @} + \dhead{meth}{classify-condition (@ warning) @> @} + \dhead{meth}{classify-condition (@ information) + @> @} + \dhead{meth}{classify-condition (@ base-lexer-error) + @> @} + \dhead{meth}{classify-condition (@ base-syntax-error) + @> @}} + \end{describe*} +\end{describe} + \begin{describe}{mac} {count-and-report-errors () @^* @^* @> @ @ @} @@ -190,7 +241,7 @@ depends on the type of scanner. Given a captured place, the scanner can be rewound to the position held in it. Depending on how the scanner works, holding onto a captured place might -consume a lot of memory or case poor performance. For example, if the +consume a lot of memory or cause poor performance. For example, if the scanner is reading from an input stream, having a captured place means that data from that point on must be buffered in case the program needs to rewind the scanner and read that data again. Therefore it's possible to @@ -219,10 +270,10 @@ the scanner and read that data again. Therefore it's possible to \begin{describe}{mac} {with-scanner-place (@ @) @^* @^* @> @^*} - Capture the @'s current position as a place, evaluate the - @s as an implicit progn with the variable @ bound to the captured - place. When control leaves the @s, the place is released. The return - values are the values of the final @. + Capture the @'s current position as a place, evaluate the @s + as an implicit progn with the variable @ bound to the captured + place. When control leaves the @s, the place is released. The + return values are the values of the final @. \end{describe} \subsection{Scanner file-location protocol} \label{sec:parsing.scanner.floc} @@ -276,7 +327,7 @@ Character scanners are scanners which read sequences of characters. \begin{describe}{gf}{scanner-unread @ @} Rewind the @ by one step. The @ must be the previous current character, and becomes the current character again. It is an error - if: the @ has reached end-of-file; the @ is never been + if: the @ has reached end-of-file; the @ has never been stepped; or @ was not the previous current character. \end{describe} @@ -370,15 +421,15 @@ file-location protocols. \begin{describe}{gf} {charbuf-scanner-map @ @ \&optional @ - \nlret @ @ @} + \nlret @ @ @} Read characters from the @'s buffers. This is intended to be an efficient and versatile interface for reading characters from a scanner in bulk. The function @ is invoked repeatedly, as if by \begin{prog} - (multiple-value-bind (@ @) \\ \ind\ind - (funcall @ @ @ @) \- \\ + (multiple-value-bind (@ @) \\ \ind\ind + (funcall @ @ @ @) \-\\ \textrm\ldots) \end{prog} The argument @ is a simple string; @ and @ are two @@ -386,7 +437,7 @@ file-location protocols. @ (inclusive) and @ (exclusive) should be processed. If @'s return value @ is nil then @ is ignored: the function has consumed the entire buffer and wishes to read more. If - @ is non-nil, then it must be a fixnum such that $@ \le + @ is non-nil, then @ must be a fixnum such that $@ \le @ \le @$: the function has consumed the buffer as far as @ (exclusive) and has completed successfully. @@ -394,8 +445,8 @@ file-location protocols. fails: the @ function is called with no arguments, and is expected to return two values. If omitted, @ defaults to \begin{prog} - (lambda () \\ \ind - (values nil nil))% + (lambda () \\ \ind + (values nil nil)) \end{prog} The @|charbuf-scanner-map| function returns three values. The first value @@ -454,18 +505,18 @@ file-location protocols. \begin{describe}{mac} {defparse @ (@[[ :context (@ @) @]] - @^*) \\ \ind - @[[ @^* @! @ @]] \\ - @^* \- - \nlret @} + @^*) \\ \ind + @[[ @^* @! @ @]] \\ + @^* + \-\nlret @} \end{describe} \begin{describe}{mac} {with-parser-context - (@ @{ @ @ @}^*) \\ \ind - @^* \\ - @^* \- - \nlret @^*} + (@ @{ @ @ @}^*) \\ \ind + @^* \\ + @^* + \-\nlret @^*} \end{describe} \begin{describe}{lmac} @@ -490,26 +541,26 @@ file-location protocols. \begin{describe}{mac} {if-parse (@[[ \=:result @ @! - :expected @ @! \+ \\ - :consumedp @ @]]) \- \\ \ind\ind - @ \- \\ - @ \\ - @[@@] \- - \nlret @^*} + :expected @ @! \+\\ + :consumedp @ @]]) \-\\ \ind\ind + @ \-\\ + @ \\ + @[@@] + \-\nlret @^*} \end{describe} \begin{describe}{mac} - {when-parse (@[@@]) @ \\ \ind - @^* \- - \nlret @^*} + {when-parse (@[@@]) @ \\ \ind + @^* + \-\nlret @^*} \end{describe} \begin{describe}{mac} {cond-parse (@[[ \=:result @ @! - :expected @ @! \+ \\ - :consumedp @ @]]) \- \\ \ind - @{ (@ @^*) @}^* \- - \nlret @^*} + :expected @ @! \+\\ + :consumedp @ @]]) \-\\ \ind + @{ (@ @^*) @}^* + \-\nlret @^*} \end{describe} \begin{describe}{parse}{:eof} @@ -537,8 +588,9 @@ file-location protocols. \end{describe} \begin{describe}{parseform} - {seq (@{ @ @! (@[@@] @) @}^*) \\ \ind - @^*} + {seq (@{ @ @! + (@[@@] @) @}^*) \\ \ind + @^*} \end{describe} \begin{describe}{parseform}{and @^*} @@ -551,22 +603,22 @@ file-location protocols. \end{describe} \begin{describe}{parseform} - {many (\=@ @ @ \+ \\ - @[[ \=:new @ @! :final @ @! \+ \\ - :min @ @! :max @ @! \\ - :commitp @ @]]) \-\- \\ \ind + {many (\=@ @ @ \+\\ + @[[ \=:new @ @! :final @ @! \+\\ + :min @ @! :max @ @! \\ + :commitp @ @]]) \-\-\\ \ind @ @[@@]} \end{describe} \begin{describe}{parseform} {list (@[[ :min @ @! :max @ @! - :commitp @ @]])\\ \ind + :commitp @ @]]) \\ \ind @ @[@@]} \end{describe} \begin{describe}{parseform} {skip-many (@[[ :min @ @! :max @ @! - :commitp @ @]])\\ \ind + :commitp @ @]]) \\ \ind @ @[@@]} \end{describe} @@ -692,7 +744,7 @@ file-location protocols. \end{describe} \begin{describe}{parseform} - {expr \=(@[[ :nestedp @ @]]) \+ \\ + {expr \=(@[[ :nestedp @ @]]) \+\\ @ @ @ @} \end{describe} @@ -718,12 +770,13 @@ file-location protocols. \begin{describe*} {\quad\=\kill - \dhead{cls}{simple-binary-operator (simple-operator) \\ \> - \&key :name :function :lprec :rprec :associativity} + \dhead{cls}{simple-binary-operator (simple-operator) \\ \> + \&key :name :function + :lprec :rprec :associativity} \dhead{cls}{simple-postfix-operator (simple-unary-operator) \\ \> \&key :name :function :lprec :rprec} \dhead{cls}{simple-prefix-operator - (prefix-operator simple-unary-operator) \\ \> + (prefix-operator simple-unary-operator) \\ \> \&key :name :function :rprec}} \end{describe*} @@ -762,18 +815,34 @@ file-location protocols. \begin{describe}{fun}{define-indicator @ @} \end{describe} -\begin{describe}{fun}{syntax-error @ @ \&key :continuep} +\begin{describe*} + {\dhead{cls}{lexer-error (parser-error base-lexer-error) \\ \ind + \&key :expected :found :location \-} + \dhead{cls}{syntax-error (parser-error base-syntax-error) \\ \ind + \&key :expected :found :location \-}} +\end{describe*} + +\begin{describe}{fun} + {syntax-error @ @ \&key :continuep :location} \end{describe} \begin{describe}{fun} - {lexer-error @ @ @} + {lexer-error @ @ \&key :location} \end{describe} \begin{describe}{parseform} {skip-until (@[[ :keep-end @ @]]) @^*} \end{describe} -\begin{describe}{parseform}{error () @ @} +\begin{describe}{parseform} + {error (@[[ :ignore-unconsumed @ @! + :force-process @ @]]) \\ \ind\ind + @ @ \-\\ + @^* \\ + @^*} +\end{describe} + +\begin{describe}{parseform}{must @ @[@@]} \end{describe} \begin{describe}{fun}