diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index fff2b5268..55b14b38a 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -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 @@ -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} diff --git a/chapters/syntax.tex b/chapters/syntax.tex index df0c90e62..1e5d41c25 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -26,14 +26,15 @@ \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: @@ -41,7 +42,8 @@ \section{Lexical conventions}\doublelabel{lexical-conventions} \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. @@ -364,6 +366,8 @@ \subsection{Expressions}\doublelabel{expressions1} | "{" array-arguments "}" | end +UNSIGNED-NUMBER : UNSIGNED-INTEGER | UNSIGNED-REAL + type-specifier : ["."] name name : IDENT { "." IDENT }