X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/fcb6c0fb72f7e2211322cfc303ee403bdf3ddd7d..3e166443f7ed632f0a8b3d0e680c2afcc265d56f:/doc/parsing.tex diff --git a/doc/parsing.tex b/doc/parsing.tex index e39a9e9..20ade82 100644 --- a/doc/parsing.tex +++ b/doc/parsing.tex @@ -7,7 +7,7 @@ %%%----- Licensing notice --------------------------------------------------- %%% -%%% This file is part of the Sensble Object Design, an object system for C. +%%% This file is part of the Sensible Object Design, an object system for C. %%% %%% SOD is free software; you can redistribute it and/or modify %%% it under the terms of the GNU General Public License as published by @@ -43,6 +43,13 @@ consumed any input items. \begin{describe}{fun}{combine-parser-failures @ @> @} \end{describe} +\begin{describe}{fun}{parse-empty \&optional @ @> @} +\end{describe} + +\begin{describe}{fun} + {parse-fail @ \&optional @ @> @} +\end{describe} + %%%-------------------------------------------------------------------------- \section{File locations} \label{sec:parsing.floc} @@ -82,31 +89,31 @@ 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} + {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} + \dhead{cls} + {simple-condition-with-location + (condition-with-location simple-condition) \\ \> + \&key :format-control :format-arguments :location} \dhead{cls} - {simple-condition-with-location - (condition-with-location simple-condition) \\ \> - \&key :format-control :format-arguments :location} + {simple-error-with-location + (error-with-location simple-error) \\ \> + \&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}} + {simple-warning-with-location + (warning-with-location simple-warning) \\ \> + \&key :format-control :format-arguments :location}} \end{describe*} \begin{describe}{fun} @@ -124,11 +131,12 @@ consumed any input items. \end{describe*} \begin{describe}{mac} - {with-default-error-location (@) @^* @> @^*} + {with-default-error-location (@) @^* @
^* + @> @^*} \end{describe} \begin{describe}{mac} - {count-and-report-errors () @^* + {count-and-report-errors () @^* @^* @> @ @ @} \end{describe} @@ -209,11 +217,12 @@ the scanner and read that data again. Therefore it's possible to \end{describe} \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 @. + {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 @. \end{describe} \subsection{Scanner file-location protocol} \label{sec:parsing.scanner.floc} @@ -368,8 +377,8 @@ file-location protocols. 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 @@ -385,8 +394,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 @@ -445,22 +454,31 @@ 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} {parse @ @> @ @ @} \end{describe} +\begin{describe}{mac} + {parser @ + @[[ @^* @! @ @]] + @ + @> @} +\end{describe} + \begin{describe}{gf}{parser-at-eof-p @ @> @} \end{describe} @@ -472,26 +490,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} @@ -519,8 +537,9 @@ file-location protocols. \end{describe} \begin{describe}{parseform} - {seq (@{ @ @! (@[@@] @) @}^*) \\ \ind - @^*} + {seq (@{ @ @! + (@[@@] @) @}^*) \\ \ind + @^*} \end{describe} \begin{describe}{parseform}{and @^*} @@ -533,22 +552,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} @@ -563,7 +582,9 @@ file-location protocols. \end{describe} \begin{describe}{mac} - {define-pluggable-parser @ @ @ @^*} + {define-pluggable-parser @ @ @ + @[[ @^* @! @ @]] + @^*} \end{describe} \begin{describe}{gf}{parser-capture-place @ @> @} @@ -580,12 +601,17 @@ file-location protocols. \end{describe} \begin{describe}{mac} - {with-parser-place (@ @) @^*} + {with-parser-place (@ @) + @[[ @^* @! @ @]] + @^*} \end{describe} \begin{describe}{parseform}{peek @} \end{describe} +\begin{describe}{parseform}{commit} +\end{describe} + \begin{describe}{cls}{character-parser-context () \&key} \end{describe} @@ -654,11 +680,111 @@ file-location protocols. \&key :scanner} \end{describe} -%% FIXME parser-expr +\begin{describe}{gf}{push-operator @ @} +\end{describe} + +\begin{describe}{gf}{push-value @ @} +\end{describe} + +\begin{describe}{gf}{apply-operator @ @} +\end{describe} + +\begin{describe}{gf}{operator-push-action @ @} +\end{describe} + +\begin{describe}{parseform} + {expr \=(@[[ :nestedp @ @]]) \+\\ + @ @ + @ @} +\end{describe} + +\begin{describe}{gf}{operator-left-precedence @ @> @} +\end{describe} + +\begin{describe}{gf}{operator-right-precedence @ @> @} +\end{describe} + +\begin{describe}{gf}{operator-associativity @ @> @} +\end{describe} + +\begin{describe}{cls}{prefix-operator () \&key} +\end{describe} + +\begin{describe}{cls}{simple-operator () \&key :name :function} +\end{describe} + +\begin{describe}{cls} + {simple-unary-operator (simple-operator) \&key :name :function} +\end{describe} + +\begin{describe*} + {\quad\=\kill + \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) \\ \> + \&key :name :function :rprec}} +\end{describe*} + +\begin{describe*} + {\dhead{mac}{preop @ (@ @) + @^* @^* + @> @} + \dhead{mac}{postop @ + (@ @ @[[ :rprec @ @]]) + @^* @^* + \nlret @} + \dhead{mac}{binop @ (@ @ @ @) + @^*@^* + @> @}} +\end{describe*} + +\begin{describe*} + {\dhead{cls}{parenthesis () \&key :tag} + \dhead{cls}{open-parenthesis (parenthesis prefix-operator) \&key :tag} + \dhead{cls}{close-parenthesis (parenthesis) \&key :tag}} +\end{describe*} + +\begin{describe*} + {\dhead{fun}{lparen @ @> @} + \dhead{fun}{rparen @ @> @}} +\end{describe*} %%%------------------------------------------------------------------------- \section{Lexical analyser} +\begin{describe}{cls} + {sod-token-scanner (token-scanner) + \&key :filename (:line 1) (:column 0) :char-scanner} +\end{describe} + +\begin{describe}{fun}{define-indicator @ @} +\end{describe} + +\begin{describe}{fun}{syntax-error @ @ \&key :continuep} +\end{describe} + +\begin{describe}{fun} + {lexer-error @ @ @} +\end{describe} + +\begin{describe}{parseform} + {skip-until (@[[ :keep-end @ @]]) @^*} +\end{describe} + +\begin{describe}{parseform} + {error (@[[ :ignore-unconsumed @ @]]) \\ \ind + @ @} +\end{describe} + +\begin{describe}{fun} + {scan-comment @ + @> @ @ @} +\end{describe} + %%%----- That's all, folks -------------------------------------------------- %%% Local variables: