From: Scott Duckworth <duckwos@clemson.edu>
To: caml-list@inria.fr
Subject: [Caml-list] Lexing.lexeme_start_p broken?
Date: Fri, 17 Sep 2004 18:07:43 -0400 [thread overview]
Message-ID: <414B602F.2020400@clemson.edu> (raw)
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
next reply other threads:[~2004-09-17 22:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-17 22:07 Scott Duckworth [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=414B602F.2020400@clemson.edu \
--to=duckwos@clemson.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox