aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-07-01 09:35:48 -0700
committerGraydon Hoare <[email protected]>2010-07-01 09:35:48 -0700
commitcb04275afa8c72a10ca5893de27dc0228d29ea8c (patch)
tree311b929af7610673fa3a3ed7d1efbc4d2a08c5af
parentFix lexer's definition of numeric literals. (diff)
downloadrust-cb04275afa8c72a10ca5893de27dc0228d29ea8c.tar.xz
rust-cb04275afa8c72a10ca5893de27dc0228d29ea8c.zip
Add machine-dependent 'float' type.
-rw-r--r--doc/rust.texi22
-rw-r--r--src/boot/fe/lexer.mll1
-rw-r--r--src/boot/fe/token.ml2
3 files changed, 21 insertions, 4 deletions
diff --git a/doc/rust.texi b/doc/rust.texi
index f9d6e3e0..47ee7cfb 100644
--- a/doc/rust.texi
+++ b/doc/rust.texi
@@ -647,9 +647,10 @@ The keywords are:
@tab @code{type}
@tab @code{true}
@tab @code{false}
-@item @code{any}
-@tab @code{int}
+@tab @code{any}
+@item @code{int}
@tab @code{uint}
+@tab @code{float}
@tab @code{char}
@tab @code{bool}
@item @code{u8}
@@ -1750,6 +1751,7 @@ Rust; they cannot be used as user-defined identifiers in any context.
* Ref.Type.Any:: An open sum of every possible type.
* Ref.Type.Mach:: Machine-level types.
* Ref.Type.Int:: The machine-dependent integer types.
+* Ref.Type.Float:: The machine-dependent floating-point types.
* Ref.Type.Prim:: Primitive types.
* Ref.Type.Big:: The arbitrary-precision integer type.
* Ref.Type.Text:: Strings and characters.
@@ -1842,9 +1844,21 @@ The Rust type @code{int}@footnote{A Rust @code{int} is analogous to a C99
target-machine-dependent size. Its size, in bits, is equal to the size of the
rust type @code{uint} on the same target machine.
+@node Ref.Type.Float
+@subsection Ref.Type.Float
+
+The Rust type @code{float} is a machine-specific type equal to one of the
+supported Rust floating-point machine types (@code{f32} or @code{f64}). It is
+the largest floating-point type that is directly supported by hardware on the
+target machine, or if the target machine has no floating-point hardware
+support, the largest floating-point type supported by the software
+floating-point library used to support the other floating-point machine types.
+
+Note that due to the preference for hardware-supported floating point, the
+type @code{float} may not be equal to the largest @emph{supported}
+floating-point type.
-@page
@node Ref.Type.Prim
@subsection Ref.Type.Prim
@@ -1863,7 +1877,7 @@ The boolean type @code{bool} with values @code{true} and @code{false}.
@item
The machine types.
@item
-The machine-dependent integer types.
+The machine-dependent integer and floating-point types.
@end itemize
diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll
index 4e4e845c..6430821d 100644
--- a/src/boot/fe/lexer.mll
+++ b/src/boot/fe/lexer.mll
@@ -79,6 +79,7 @@
("int", INT);
("uint", UINT);
+ ("float", FLOAT);
("char", CHAR);
("str", STR);
diff --git a/src/boot/fe/token.ml b/src/boot/fe/token.ml
index 636e1ac2..446e5262 100644
--- a/src/boot/fe/token.ml
+++ b/src/boot/fe/token.ml
@@ -118,6 +118,7 @@ type token =
| BOOL
| INT
| UINT
+ | FLOAT
| CHAR
| STR
| MACH of Common.ty_mach
@@ -267,6 +268,7 @@ let rec string_of_tok t =
| BOOL -> "bool"
| INT -> "int"
| UINT -> "uint"
+ | FLOAT -> "float"
| CHAR -> "char"
| STR -> "str"
| MACH m -> Common.string_of_ty_mach m