Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 3.10 and ints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: camlp4 3.10 and ints
I'm getting some odd errors with camlp4 (3.10) and integers.

Firstly, INT returns a string, rather than an int, and similarly
$int:...$ expects a string instead of an int.  I can live with this,
but it seems a bit strange, and unless I'm mistaken is different from
what camlp4 <= 3.09 did.

Secondly, I get the error 'Failure: "Integer literal exceeds the range
of representable integers of type int"' if I try to pass a string
containing any int32 or int64 literal, eg. $int:"0x3ffL"$, even ones
which obviously do not exceed the range of representable integers.

To demonstrate this second one, save the following to files:

-------------------------------------------------- pa_test.ml ---
open Camlp4.PreCast
open Syntax

let expand_test _loc () =
  <:str_item< value test = $int:"0x3ffL"$ >>

EXTEND Gram
  GLOBAL: str_item;

  str_item: LEVEL "top" [
  [ "TEST" -> expand_test _loc () ]
  ];
END;;
--------------------------------------------------

-------------------------------------------------- test.ml ---
TEST
--------------------------------------------------

And then compile with:

  $ ocamlc -pp "camlp4o pa_extend.cmo q_MLast.cmo" -I +camlp4 -c pa_test.ml 
  $ ocamlc -pp "camlp4o ./pa_test.cmo" test.ml
  File "test.ml", line 1, characters 0-4:
  Failure: "Integer literal exceeds the range of representable integers of type int"
  Preprocessor error

Are these bugs or am I missing something?

Rich.

-- 
Richard Jones
Red Hat