From a9c2432822c68cfc0897c162b17af6b69d0e22b7 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 27 Nov 2008 15:06:29 -0500 Subject: Patterns --- doc/manual.tex | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/manual.tex b/doc/manual.tex index e83dc392..01f5a5f3 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -35,6 +35,8 @@ We give the Ur language definition in \LaTeX $\;$ math mode, since that is prett We often write syntax like $e^*$ to indicate zero or more copies of $e$, $e^+$ to indicate one or more copies, and $e,^*$ and $e,^+$ to indicate multiple copies separated by commas. Another separator may be used in place of a comma. The $e$ term may be surrounded by parentheses to indicate grouping; those parentheses should not be included in the actual ASCII. +We write $\ell$ for literals of the primitive types, for the most part following C conventions. There are $\mt{int}$, $\mt{float}$, and $\mt{string}$ literals. + \subsection{Core Syntax} \emph{Kinds} classify types and other compile-time-only entities. Each kind in the grammar is listed with a description of the sort of data it classifies. @@ -105,4 +107,18 @@ $$\begin{array}{rrcll} &&& X \; \mt{of} \; \tau & \textrm{unary constructor} \\ \end{array}$$ +\emph{Patterns} are used to describe structural conditions on expressions, such that expressions may be tested against patterns, generating assignments to pattern variables if successful. +$$\begin{array}{rrcll} + \textrm{Patterns} & p &::=& \_ & \textrm{wildcard} \\ + &&& x & \textrm{variable} \\ + &&& \ell & \textrm{constant} \\ + &&& \hat{X} & \textrm{nullary constructor} \\ + &&& \hat{X} \; p & \textrm{unary constructor} \\ + &&& \{(x = p,)^*\} & \textrm{rigid record pattern} \\ + &&& \{(x = p,)^+, \ldots\} & \textrm{flexible record pattern} \\ + \\ + \textrm{Qualified capitalized variable} & \hat{X} &::=& X & \textrm{not from a module} \\ + &&& M.X & \textrm{projection from a module} \\ +\end{array}$$ + \end{document} \ No newline at end of file -- cgit v1.2.3