caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Lexing.lexeme_start_p broken?
@ 2004-09-17 22:07 Scott Duckworth
  2004-09-20  9:23 ` Jean-Christophe Filliatre
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Duckworth @ 2004-09-17 22:07 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-21  9:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-17 22:07 [Caml-list] Lexing.lexeme_start_p broken? Scott Duckworth
2004-09-20  9:23 ` Jean-Christophe Filliatre
2004-09-20 14:44   ` skaller
2004-09-21  8:26     ` Damien Doligez
2004-09-21  9:25       ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).