Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb4638a

Browse files
committed
Change the grammar productions to use the new productionlist environment;
this supports a hyperlinked version of the grammar that can make tracking down details and definitions a little easier.
1 parent b2d1006 commit cb4638a

5 files changed

Lines changed: 410 additions & 261 deletions

File tree

Doc/ref/ref2.tex

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,18 @@ \section{Identifiers and keywords\label{identifiers}}
237237
\index{identifier}
238238
\index{name}
239239

240-
\begin{verbatim}
241-
identifier: (letter|"_") (letter|digit|"_")*
242-
letter: lowercase | uppercase
243-
lowercase: "a"..."z"
244-
uppercase: "A"..."Z"
245-
digit: "0"..."9"
246-
\end{verbatim}
240+
\begin{productionlist}
241+
\production{identifier}
242+
{(\token{letter}|"_") (\token{letter} | \token{digit} | "_")*}
243+
\production{letter}
244+
{\token{lowercase} | \token{uppercase}}
245+
\production{lowercase}
246+
{"a"..."z"}
247+
\production{uppercase}
248+
{"A"..."Z"}
249+
\production{digit}
250+
{"0"..."9"}
251+
\end{productionlist}
247252

248253
Identifiers are unlimited in length. Case is significant.
249254

@@ -303,17 +308,27 @@ \subsection{String literals\label{strings}}
303308
String literals are described by the following lexical definitions:
304309
\index{string literal}
305310

306-
\begin{verbatim}
307-
stringliteral: shortstring | longstring
308-
shortstring: "'" shortstringitem* "'" | '"' shortstringitem* '"'
309-
longstring: "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
310-
shortstringitem: shortstringchar | escapeseq
311-
longstringitem: longstringchar | escapeseq
312-
shortstringchar: <any ASCII character except "\" or newline or the quote>
313-
longstringchar: <any ASCII character except "\">
314-
escapeseq: "\" <any ASCII character>
315-
\end{verbatim}
316311
\index{ASCII@\ASCII{}}
312+
\begin{productionlist}
313+
\production{stringliteral}
314+
{\token{shortstring} | \token{longstring}}
315+
\production{shortstring}
316+
{"'" \token{shortstringitem}* "'"
317+
| '"' \token{shortstringitem}* '"'}
318+
\production{longstring}
319+
{"'''" \token{longstringitem}* "'''"
320+
| '"""' \token{longstringitem}* '"""'}
321+
\production{shortstringitem}
322+
{\token{shortstringchar} | \token{escapeseq}}
323+
\production{longstringitem}
324+
{\token{longstringchar} | \token{escapeseq}}
325+
\production{shortstringchar}
326+
{<any ASCII character except "\e" or newline or the quote>}
327+
\production{longstringchar}
328+
{<any ASCII character except "\e">}
329+
\production{escapeseq}
330+
{"\e" <any ASCII character>}
331+
\end{productionlist}
317332

318333
\index{triple-quoted string}
319334
\index{Unicode Consortium}
@@ -452,16 +467,24 @@ \subsection{Integer and long integer literals\label{integers}}
452467
Integer and long integer literals are described by the following
453468
lexical definitions:
454469

455-
\begin{verbatim}
456-
longinteger: integer ("l"|"L")
457-
integer: decimalinteger | octinteger | hexinteger
458-
decimalinteger: nonzerodigit digit* | "0"
459-
octinteger: "0" octdigit+
460-
hexinteger: "0" ("x"|"X") hexdigit+
461-
nonzerodigit: "1"..."9"
462-
octdigit: "0"..."7"
463-
hexdigit: digit|"a"..."f"|"A"..."F"
464-
\end{verbatim}
470+
\begin{productionlist}
471+
\production{longinteger}
472+
{\token{integer} ("l" | "L")}
473+
\production{integer}
474+
{\token{decimalinteger} | \token{octinteger} | \token{hexinteger}}
475+
\production{decimalinteger}
476+
{\token{nonzerodigit} \token{digit}* | "0"}
477+
\production{octinteger}
478+
{"0" \token{octdigit}+}
479+
\production{hexinteger}
480+
{"0" ("x" | "X") \token{hexdigit}+}
481+
\production{nonzerodigit}
482+
{"1"..."9"}
483+
\production{octdigit}
484+
{"0"..."7"}
485+
\production{hexdigit}
486+
{\token{digit} | "a"..."f" | "A"..."F"}
487+
\end{productionlist}
465488

466489
Although both lower case `l' and upper case `L' are allowed as suffix
467490
for long integers, it is strongly recommended to always use `L', since
@@ -487,14 +510,21 @@ \subsection{Floating point literals\label{floating}}
487510
Floating point literals are described by the following lexical
488511
definitions:
489512

490-
\begin{verbatim}
491-
floatnumber: pointfloat | exponentfloat
492-
pointfloat: [intpart] fraction | intpart "."
493-
exponentfloat: (nonzerodigit digit* | pointfloat) exponent
494-
intpart: nonzerodigit digit* | "0"
495-
fraction: "." digit+
496-
exponent: ("e"|"E") ["+"|"-"] digit+
497-
\end{verbatim}
513+
\begin{productionlist}
514+
\production{floatnumber}
515+
{\token{pointfloat} | \token{exponentfloat}}
516+
\production{pointfloat}
517+
{[\token{intpart}] \token{fraction} | \token{intpart} "."}
518+
\production{exponentfloat}
519+
{(\token{nonzerodigit} \token{digit}* | \token{pointfloat})
520+
\token{exponent}}
521+
\production{intpart}
522+
{\token{nonzerodigit} \token{digit}* | "0"}
523+
\production{fraction}
524+
{"." \token{digit}+}
525+
\production{exponent}
526+
{("e" | "E") ["+" | "-"] \token{digit}+}
527+
\end{productionlist}
498528

499529
Note that the integer part of a floating point number cannot look like
500530
an octal integer, though the exponent may look like an octal literal
@@ -517,9 +547,9 @@ \subsection{Imaginary literals\label{imaginary}}
517547

518548
Imaginary literals are described by the following lexical definitions:
519549

520-
\begin{verbatim}
521-
imagnumber: (floatnumber | intpart) ("j"|"J")
522-
\end{verbatim}
550+
\begin{productionlist}
551+
\production{imagnumber}{(\token{floatnumber} | \token{intpart}) ("j" | "J")}
552+
\end{productionlist}
523553

524554
An imaginary literal yields a complex number with a real part of
525555
0.0. Complex numbers are represented as a pair of floating point

0 commit comments

Comments
 (0)