Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Alessandro Baretta <alex@baretta.com>
To: Richard Lyman <rich@lithinos.com>, Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Setting the EOL character....
Date: Fri, 13 Sep 2002 11:10:00 +0200	[thread overview]
Message-ID: <3D81AB68.5010606@baretta.com> (raw)
In-Reply-To: <000401c25ace$6896c7b0$0a00a8c0@stone>



Richard Lyman wrote:
> Ok...
> 
> That doesn't look too bad - and I think I almost understand it. : )
> 
> ... so then - there's no OCaml concept of a global EOL variable, or method
> that deals with reading in from a stream until the EOL??
> 
> I was hoping more for something along the lines of -
> 
> (start pseudocode)
> 
> myStream = Unix.accepted_socket_stream
> while(true){
>     a_line = myStream.read_until("\000")
>     deal_with_line(a_line)
> }
> 
> (end pseudocode)
> 
> Thanks for your thoughts!
> 
> -Rich

How about the following:

let process_line out_channel line = .... in
let read_until_null in_channel out_channel =
    Scanf.fscanf in_channel "[^\000]\000"
      (process_line out_channel) in
let process_request in_channel out_channel =
    try while true do
       read_until_null in_channel out_channel
    done with End_of_file -> ()
let sockaddr = <server_socket_specification> in
Unix.establish_server process_request sockaddr


Nonetheless, let me suggest that you look into ocamllex and 
ocamlyacc--lexer and parser generators respectively. They 
are probably your best choice for lexing and parsing the 
input stream, no matter how weird its structure.

Alex

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


  reply	other threads:[~2002-09-13  9:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-13  2:24 Arturo Borquez
2002-09-13  2:36 ` Richard Lyman
2002-09-13  9:10   ` Alessandro Baretta [this message]
2002-09-13 15:33   ` Bruno.Verlyck
2002-09-13 15:52     ` Matt Boyd
  -- strict thread matches above, loose matches on Subject: below --
2002-09-13  0:07 Richard Lyman

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=3D81AB68.5010606@baretta.com \
    --to=alex@baretta.com \
    --cc=caml-list@inria.fr \
    --cc=rich@lithinos.com \
    /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