Skip to content

Commit

Permalink
Improve so that .13 is a floating point number, (#2491)
Browse files Browse the repository at this point in the history
Closes #2122
* Improve so that .13 is a floating point number, and some minor corrections.
* Introduce UNSIGNED-REAL and UNSIGNED-NUMBER to be able say that 13 is not a floating point, but can still be used everywhere where numbers are expected (13. is a floating point number).
* Add more examples
* Simplify descriptive text as proposed with good link to grammar
  • Loading branch information
HansOlsson committed Mar 10, 2020
1 parent 29b6c89 commit 0030199
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
17 changes: 10 additions & 7 deletions chapters/lexicalstructure.tex
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ \section{Literal Constants}\doublelabel{literal-constants}
\subsection{Floating Point Numbers}\doublelabel{floating-point-numbers}

A floating point number is expressed as a decimal number in the form of
a sequence of decimal digits optionally followed by a decimal point,
optionally followed by an exponent. At least one digit must be present.
The exponent is indicated by an E or e, followed by an optional sign (+
or -) and one or more decimal digits. The minimal recommended range is
a sequence of decimal digits followed by a decimal point, followed by decimal digits,
followed by an exponent indicated by E or e followed by a sign
and one or more decimal digits. The various parts can be omitted, see \lstinline!UNSIGNED_REAL! in~\autoref{lexical-conventions} for
details and also the examples below. The minimal recommended range is
that of IEEE double precision floating point numbers, for which the
largest representable positive number is 1.7976931348623157E+308 and the
smallest positive number is 2.2250738585072014E-308. For example, the
Expand All @@ -152,15 +152,18 @@ \subsection{Floating Point Numbers}\doublelabel{floating-point-numbers}
For example, all of the following literals denote the same number:

\begin{lstlisting}[language=modelica]
13., 13E0, 1.3e1, 0.13E2
13., 13E0, 1.3e1, 0.13E2, .13E2
\end{lstlisting}
The last variant shows that that the leading zero is optional (in that case decimal digits must be present).
Note that \lstinline!13! is not in this list, since it is not a floating point number,
but can be converted to a floating point number.

\subsection{Integer Literals}\doublelabel{integer-literals}

Literals of type \lstinline!Integer! are sequences of decimal digits, e.g. as in the
integer numbers \lstinline!33, 0, 100, 30030044!. {[}\emph{Negative numbers are
integer numbers \lstinline!33!, \lstinline!0!, \lstinline!100!, \lstinline!30030044!. {[}\emph{Negative numbers are
formed by unary minus followed by an integer literal}{]}. The minimal
recommended number range is from -2147483648 to +2147483647 for a
recommended number range is from -2147483648 to +2147483647 corresponding to a
two's-complement 32-bit integer implementation.

\subsection{Boolean Literals}\doublelabel{boolean-literals}
Expand Down
14 changes: 9 additions & 5 deletions chapters/syntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ \section{Lexical conventions}\doublelabel{lexical-conventions}
"\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v"
DIGIT = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
UNSIGNED-INTEGER = DIGIT { DIGIT }
UNSIGNED-NUMBER = UNSIGNED-INTEGER [ "." [ UNSIGNED-INTEGER ] ]
[ ( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER ]
UNSIGNED-REAL = UNSIGNED-INTEGER "." [ UNSIGNED-INTEGER ]
| UNSIGNED_INTEGER [ "." [ UNSIGNED_INTEGER ] ] ( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER
| "." UNSIGNED-INTEGER [ ( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER ]
\end{lstlisting}
\textrm{S-CHAR} is any member of the Unicode character set
(\url{http://www.unicode.org}; see \autoref{mapping-package-class-structures-to-a-hierarchical-file-system} for storing as UTF-8 on files) except double-quote """, and backslash "\textbackslash{}"

For identifiers the redundant escapes (\lstinline!'\?' and '\"'!) are the same as the corresponding non-escaped
variants (\lstinline!'?' and '"'!). {[}\emph{The single quotes are part of an
For identifiers the redundant escapes (\lstinline!'\?'! and \lstinline!'\"'!) are the same as the corresponding non-escaped
variants (\lstinline!'?'! and \lstinline!'"'!). {[}\emph{The single quotes are part of an
identifier. E.g. 'x' and x are different IDENTs}{]}.

Note:

\begin{itemize}
\item
Whitespace and comments can be used between separate lexical units
and/or symbols, and also separates them. Whitespace and comments
and/or symbols, and also separates them. Each lexical unit will consume the maximum number of characters from the input stream.
Whitespace and comments
cannot be used inside other lexical units, except for STRING and
Q-IDENT where they are treated as part of the STRING or Q-IDENT
lexical unit.
Expand Down Expand Up @@ -364,6 +366,8 @@ \subsection{Expressions}\doublelabel{expressions1}
| "{" array-arguments "}"
| end

UNSIGNED-NUMBER : UNSIGNED-INTEGER | UNSIGNED-REAL

type-specifier : ["."] name

name : IDENT { "." IDENT }
Expand Down

0 comments on commit 0030199

Please sign in to comment.