caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Sébastien Dailly" <sebastien-ocaml@chimrod.com>
To: caml-list@inria.fr
Subject: [Caml-list] Strange result with Lexing
Date: Thu, 02 Apr 2015 17:22:41 +0200	[thread overview]
Message-ID: <ebb918ce3a944148219a68a2db15aade@chimrod.com> (raw)

[-- 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)) }

             reply	other threads:[~2015-04-02 15:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 15:22 Sébastien Dailly [this message]
2015-04-02 15:42 ` Török Edwin
2015-04-02 15:46 ` hugo
2015-04-03  7:25   ` Sébastien Dailly

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=ebb918ce3a944148219a68a2db15aade@chimrod.com \
    --to=sebastien-ocaml@chimrod.com \
    --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;
as well as URLs for NNTP newsgroup(s).