From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA01957; Sat, 18 Sep 2004 00:07:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA01409 for ; Sat, 18 Sep 2004 00:07:09 +0200 (MET DST) Received: from imf17aec.mail.bellsouth.net (imf17aec.mail.bellsouth.net [205.152.59.65]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8HM78qr002120 for ; Sat, 18 Sep 2004 00:07:08 +0200 Received: from [127.0.0.1] ([68.209.92.250]) by imf17aec.mail.bellsouth.net (InterMail vM.5.01.06.11 201-253-122-130-111-20040605) with ESMTP id <20040917220707.QMGI19186.imf17aec.mail.bellsouth.net@[127.0.0.1]> for ; Fri, 17 Sep 2004 18:07:07 -0400 Message-ID: <414B602F.2020400@clemson.edu> Date: Fri, 17 Sep 2004 18:07:43 -0400 From: Scott Duckworth User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Lexing.lexeme_start_p broken? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 414B600C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; printf:01 printf:01 char:01 lnum:01 stdin:01 chef:99 transitions:01 chef:99 ocamlc:01 int:01 eof:02 eof:02 bytes:02 module:03 lexbuf:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I can't seem to get the function Lexing.lexeme_start_p to return a position with correct information in it. Here is my code (test.mll): { open Lexing } rule scan = parse eof { raise End_of_file } | _ as x { let pos = lexeme_start_p lexbuf in Printf.printf "ASCII %d at line %d col %d\n" (int_of_char x) pos.pos_lnum pos.pos_bol; scan lexbuf } { try scan (from_channel stdin) with End_of_file -> () } I do the following, but I always get incorrect output: [duckwos@chef]$ ocamllex test.mll 3 states, 257 transitions, table size 1046 bytes [duckwos@chef]$ ocamlc -o test test.ml [duckwos@chef]$ ./test << EOF > position > does not > change > EOF ASCII 112 at line 1 col 0 ASCII 111 at line 1 col 0 ASCII 115 at line 1 col 0 ASCII 105 at line 1 col 0 ASCII 116 at line 1 col 0 ASCII 105 at line 1 col 0 ASCII 111 at line 1 col 0 ASCII 110 at line 1 col 0 ASCII 10 at line 1 col 0 ASCII 100 at line 1 col 0 ASCII 111 at line 1 col 0 ASCII 101 at line 1 col 0 ASCII 115 at line 1 col 0 ASCII 32 at line 1 col 0 ASCII 110 at line 1 col 0 ASCII 111 at line 1 col 0 ASCII 116 at line 1 col 0 ASCII 10 at line 1 col 0 ASCII 99 at line 1 col 0 ASCII 104 at line 1 col 0 ASCII 97 at line 1 col 0 ASCII 110 at line 1 col 0 ASCII 103 at line 1 col 0 ASCII 101 at line 1 col 0 ASCII 10 at line 1 col 0 [duckwos@chef]$ Any ideas why this is happening? I get the same results even if I am reading from an actual file opened with Lexing.from_file (open_in "filename"). One more thing. How does the pos_fname field in the position type get it's value if there is no way for the Lexing module to know the file name? Am I missing something here? Thanks in advance! -- Scott Duckworth ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners