From eaa7fc2ca250747e2a83858929d35320b6b054bc Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 11 May 2026 23:07:50 +0200 Subject: [PATCH] Document operator and delimiters --- doc/appendix.tex | 10 ++--- doc/language.tex | 103 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/doc/appendix.tex b/doc/appendix.tex index 0777d55..f68eaa2 100644 --- a/doc/appendix.tex +++ b/doc/appendix.tex @@ -14,14 +14,14 @@ = `0' | `1'. - = `\\x' . + = `\\x' \{\}. = `\\' \\ - (`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `?\@' | `0'). + (`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `0'). = \enspace? a printable ASCII character\space?. - = | | . + = | | . = \{ | \}. @@ -38,10 +38,10 @@ = `.\@' \{\} \alt{} \} `e' [`+' | `-'] \{\}. - = `\textquotedbl' \{\} `\textquotedbl'. - = `\textquotesingle' `\textquotesingle'. + = `\textquotedbl' \{\} `\textquotedbl'. + = | | \alt{} | \alt{} `true' | `false' | `nil'. diff --git a/doc/language.tex b/doc/language.tex index f79e663..cce2fcb 100644 --- a/doc/language.tex +++ b/doc/language.tex @@ -77,8 +77,111 @@ Examples: \section{Strings and characters} +Single \textit{characters} are enclosed in single quotation marks +(\textquotesingle).\@ \textit{Strings} are sequences of characters enclosed in +double quotation marks (\textquotedbl). The number of characters in a string is +called the \textit{the length} of the string. + +\begin{grammar} + = `\\' \\ + (`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `0'). + + = `\\x' \{\}. + + = | | . + + = `\textquotesingle' `\textquotesingle'. + + = `\textquotedbl' \{\} `\textquotedbl'. +\end{grammar} + +Alternatively, a single character may be represented by a +\textit{escape sequence} (see~\ref{table:escape}), a character combination +beginning with a backslash (\textbackslash). + +\begin{table}[ht] +\centering +\begin{tabular}{r l} + \textbf{Sequence} & \textbf{Meaning} \\ + \toprule + \verb|\n| & Newline \\ + \midrule + \verb|\a| & Bell \\ + \midrule + \verb|\b| & Backspace \\ + \midrule + \verb|\t| & Horizontal tab \\ + \midrule + \verb|\f| & Form feed \\ + \midrule + \verb|\r| & Carriage return \\ + \midrule + \verb|\v| & Vertical tab \\ + \midrule + \verb|\\| & Backslash \\ + \midrule + \verb|\'| & Single quote \\ + \midrule + \verb|\"| & Double quote \\ + \midrule + \verb|\0| & Null character \\ + \midrule + \verb|\xh…| & Arbitrary hexadecimal value, where \verb|n| is a hexadecimal digit \\ + \bottomrule +\end{tabular} +\caption{Escape sequences}\label{table:escape} +\end{table} + +Examples: + +\begin{itemize} + \item \verb|"String"| + \item \verb|'c'| + \item \verb|'\''| + \item \verb|"\"multi\nline\nquoted\nstring\""| +\end{itemize} + \section{Operators and delimiters} +\textit{Operators} and \textit{delimiters} are the special characters, character +pairs, or reserved words listed below. These reserved words consist exclusively +of letters and cannot be used in the role of identifiers. + +\begin{itemize} + \item{}:= + \item $@\quad\hat{}\quad\sim$ + \item $.\quad,\quad;\quad:\quad|$ + \item $<\quad>\quad>=\quad<=\quad<>\quad=$ + \item $+\quad-\quad*\quad/$ + \item $or\quad{}xor\quad\&$ + \item (\ and\ ) + \item \lbrack{} and \rbrack{} + \item \{ and \} + \item Pointer + \item module + \item import + \item type + \item const + \item var + \item begin + \item end + \item proc + \item record + \item while + \item do + \item case + \item of + \item if + \item then + \item elsif + \item else + \item cast + \item return + \item true + \item false + \item nil +\end{itemize} + \section{Comments} \textit{Comments} may be inserted between any two tokens in a program. They