Document operator and delimiters
This commit is contained in:
+5
-5
@@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
<binary-digit> = `0' | `1'.
|
<binary-digit> = `0' | `1'.
|
||||||
|
|
||||||
<hex-character> = `\\x' <hex-digit> <hex-digit>.
|
<hex-character> = `\\x' <hex-digit> \{<hex-digit>\}.
|
||||||
|
|
||||||
<escaped-character> = `\\' \\
|
<escaped-character> = `\\' \\
|
||||||
(`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `?\@' | `0').
|
(`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `0').
|
||||||
|
|
||||||
<printable-character> = \enspace? a printable ASCII character\space?.
|
<printable-character> = \enspace? a printable ASCII character\space?.
|
||||||
|
|
||||||
<character> = <printable-character> | <escaped-character> | <hex-digit>.
|
<character> = <printable-character> | <escaped-character> | <hex-character>.
|
||||||
|
|
||||||
<identifier> = <letter> \{<letter> | <decimal-digit>\}.
|
<identifier> = <letter> \{<letter> | <decimal-digit>\}.
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@
|
|||||||
<real-literal> = <integer-literal> `.\@' <decimal-digit> \{<decimal-digit>\}
|
<real-literal> = <integer-literal> `.\@' <decimal-digit> \{<decimal-digit>\}
|
||||||
\alt{} <integer-literal>\} `e' [`+' | `-'] <decimal-digit> \{<decimal-digit>\}.
|
\alt{} <integer-literal>\} `e' [`+' | `-'] <decimal-digit> \{<decimal-digit>\}.
|
||||||
|
|
||||||
<string-literal> = `\textquotedbl' \{<character>\} `\textquotedbl'.
|
|
||||||
|
|
||||||
<character-literal> = `\textquotesingle' <character> `\textquotesingle'.
|
<character-literal> = `\textquotesingle' <character> `\textquotesingle'.
|
||||||
|
|
||||||
|
<string-literal> = `\textquotedbl' \{<character>\} `\textquotedbl'.
|
||||||
|
|
||||||
<literal> = <integer-literal> | <word-literal> | <real-literal>
|
<literal> = <integer-literal> | <word-literal> | <real-literal>
|
||||||
\alt{} <string-literal> | <character-literal>
|
\alt{} <string-literal> | <character-literal>
|
||||||
\alt{} `true' | `false' | `nil'.
|
\alt{} `true' | `false' | `nil'.
|
||||||
|
|||||||
@@ -77,8 +77,111 @@ Examples:
|
|||||||
|
|
||||||
\section{Strings and characters}
|
\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}
|
||||||
|
<escaped-character> = `\\' \\
|
||||||
|
(`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `0').
|
||||||
|
|
||||||
|
<hex-character> = `\\x' <hex-digit> \{<hex-digit>\}.
|
||||||
|
|
||||||
|
<character> = <printable-character> | <escaped-character> | <hex-character>.
|
||||||
|
|
||||||
|
<character-literal> = `\textquotesingle' <character> `\textquotesingle'.
|
||||||
|
|
||||||
|
<string-literal> = `\textquotedbl' \{<character>\} `\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}
|
\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}
|
\section{Comments}
|
||||||
|
|
||||||
\textit{Comments} may be inserted between any two tokens in a program. They
|
\textit{Comments} may be inserted between any two tokens in a program. They
|
||||||
|
|||||||
Reference in New Issue
Block a user