caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Strange result with Lexing
@ 2015-04-02 15:22 Sébastien Dailly
  2015-04-02 15:42 ` Török Edwin
  2015-04-02 15:46 ` hugo
  0 siblings, 2 replies; 4+ messages in thread
From: Sébastien Dailly @ 2015-04-02 15:22 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

Hello,

I've found a strange result when calling Lexing.lexeme_start and 
Lexing.lexeme_end on DOS format file (with \r\n instead of \n).

The value returned by the two functions is wrong when the file is in DOS 
format (the result does not change when I convert the file in UNIX 
format, but this is what I expect).

I there something I misunderstood in the documentation ?

(I've compiled ocaml with opam on cygwin).

Regards,

-- 
Sébastien Dailly

[-- Attachment #2: lexer.mll --]
[-- Type: text/plain, Size: 509 bytes --]

{
  open Lexing
  open Parser

  exception SyntaxError of string * lexbuf
  
  let debug lexbuf =
    let open Lexing in
      Printf.printf "lexeme_start %d\nlexeme_end %d\n" 
        (Lexing.lexeme_start lexbuf)
        (Lexing.lexeme_end lexbuf)
}


let white = [' ' '\t']
let newline = "\n\r" | '\n' | '\r'


rule read = parse
  | white+   { read lexbuf }

  | "obj"   { debug lexbuf; OBJ }

  | newline {  read lexbuf }
  | eof     { EOF }
  | _       { raise (SyntaxError ("Unexpected char", lexbuf)) }

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

end of thread, other threads:[~2015-04-03  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02 15:22 [Caml-list] Strange result with Lexing Sébastien Dailly
2015-04-02 15:42 ` Török Edwin
2015-04-02 15:46 ` hugo
2015-04-03  7:25   ` Sébastien Dailly

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).