diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2003-04-25 12:27:31 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2003-04-25 12:27:31 +0000 |
commit | 7abcc8799e5b726f0469512d888fa2f8d11b95c0 (patch) | |
tree | a328bf1bf7de799d41dc72145ed6444561e8d6f1 /parsing/parser.mly | |
parent | 00e105ce490f8d7afd16b7c941fdf9d06ff347a6 (diff) |
Ajout des litteraux de type int32, nativeint, int64
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5510 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'parsing/parser.mly')
-rw-r--r-- | parsing/parser.mly | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/parsing/parser.mly b/parsing/parser.mly index eaac02c0b..5f809a6a8 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -87,6 +87,12 @@ let mkuminus name arg = match name, arg.pexp_desc with | "-", Pexp_constant(Const_int n) -> mkexp(Pexp_constant(Const_int(-n))) + | "-", Pexp_constant(Const_int32 n) -> + mkexp(Pexp_constant(Const_int32(Int32.neg n))) + | "-", Pexp_constant(Const_int64 n) -> + mkexp(Pexp_constant(Const_int64(Int64.neg n))) + | "-", Pexp_constant(Const_nativeint n) -> + mkexp(Pexp_constant(Const_nativeint(Nativeint.neg n))) | _, Pexp_constant(Const_float f) -> mkexp(Pexp_constant(Const_float(neg_float_string f))) | _ -> @@ -234,6 +240,8 @@ let mktype_kind vflag kind = %token INHERIT %token INITIALIZER %token <int> INT +%token <int32> INT32 +%token <int64> INT64 %token <string> LABEL %token LAZY %token LBRACE @@ -253,6 +261,7 @@ let mktype_kind vflag kind = %token MINUSGREATER %token MODULE %token MUTABLE +%token <nativeint> NATIVEINT %token NEW %token OBJECT %token OF @@ -1365,11 +1374,17 @@ constant: | CHAR { Const_char $1 } | STRING { Const_string $1 } | FLOAT { Const_float $1 } + | INT32 { Const_int32 $1 } + | INT64 { Const_int64 $1 } + | NATIVEINT { Const_nativeint $1 } ; signed_constant: constant { $1 } | MINUS INT { Const_int(- $2) } - | subtractive FLOAT { Const_float("-" ^ $2) } + | MINUS FLOAT { Const_float("-" ^ $2) } + | MINUS INT32 { Const_int32(Int32.neg $2) } + | MINUS INT64 { Const_int64(Int64.neg $2) } + | MINUS NATIVEINT { Const_nativeint(Nativeint.neg $2) } ; /* Identifiers and long identifiers */ |