Loading ...
Sorry, an error occurred while loading the content.

camlp4 - get current input filename

Expand Messages
  • Richard Jones
    Is there a way to get the current input filename while preprocessing a file with camlp4? Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and
    Message 1 of 2 , Jan 30, 2006
    • 0 Attachment
      Is there a way to get the current input filename while preprocessing a
      file with camlp4?

      Rich.

      --
      Richard Jones, CTO Merjis Ltd.
      Merjis - web marketing and technology - http://merjis.com
      Team Notepad - intranets and extranets for business - http://team-notepad.com
    • Martin Jambon
      ... That s !Pcaml.input_file Also, if you want to print a location in standard style, you have to do this: open Printf open Lexing (* works only if done
      Message 2 of 2 , Jan 30, 2006
      • 0 Attachment
        On Mon, 30 Jan 2006, Richard Jones wrote:

        > Is there a way to get the current input filename while preprocessing a
        > file with camlp4?

        That's !Pcaml.input_file

        Also, if you want to print a location in standard style, you have to do
        this:

        open Printf
        open Lexing

        (* works only if done immediately, since file name can change if a
        #line or #use directive is met *)

        let start, stop = _loc in
        let char1 = start.pos_cnum - start.pos_bol in
        let char2 = char1 + stop.pos_cnum - start.pos_cnum - 1 in
        sprintf "File %S, line %i, characters %i-%i:\n"
        !Pcaml.input_file (*start.pos_fname*) start.pos_lnum
        char1 char2

        The pos_fname field does not seem to be set (in 3.09.1) but it seems to
        have been fixed in the development version
        (http://caml.inria.fr/mantis/view.php?id=3886).


        Martin

        --
        Martin Jambon, PhD
        http://martin.jambon.free.fr

        Visit http://wikiomics.org, the Bioinformatics Howto Wiki
      Your message has been successfully submitted and would be delivered to recipients shortly.