caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oliver@first.in-berlin.de
To: Norman Hardy <norm@cap-lore.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Typesystem and Parsers
Date: Sat, 23 Oct 2010 04:25:42 +0200	[thread overview]
Message-ID: <20101023022542.GA17861@siouxsie> (raw)
In-Reply-To: <02EDD7B5-BB14-4A51-878F-D3020C7B5FE7@cap-lore.com>

On Fri, Oct 22, 2010 at 04:43:46PM -0700, Norman Hardy wrote:
> 
> On 2010 Oct 22, at 7:59 , Oliver Bandel wrote:
> 
> > Also with arranging a parser (e.g. with ocamlyacc) both ways can be walked along, either by just accepting everything and build up the tree, and later detect erros in syntax or type... (for example all scanned entities given back as strings or string lists)...
> 
> Let me describe an advantage that I see for Scheme over OCaml which pushes in the opposite direction to your proposal.
> Analyzing a Scheme  program such as (let ( ... (r ...) ...) ...) where the ellipses may be pages of code, I can put the cursor just to the right of the r and type splat B twice on at least the Mac and learn the scope of r.
> There are few more frequent steps for me as I study Scheme code.
> Any of several editors that are not Scheme savvy can do this and even the Mac's Terminal program (a glass TTY for the shell) knows this trick.
> I miss this in OCaml.
> Perhaps this is because the gross parsing of Scheme is carried out at the lexical level—parentheses first!
> 
> As I reason about the scope of an OCaml variable, the whole cache of program logic in my head is flushed!
> And them I am not sure of the result.
> A systematic algorithm to determine scope is complex and error prone.
> 
> I want simple syntactic rules to determine scope, rules that fairly general editors can help with.

Hmhh, ok that's a convenience thing you like in Scheme.

But I really meant not how to work with Ocaml vs. other languages
(which tools are there and IDEs).

I meant the tradeoff between either using the type system (and how the parser is written)
to make the code robust but  that it will break the compilation on the one side
  vs.
on the other side making the parser (and used types) less rigid and rather
going a weakly typed way (or using for example reinvocation of the parser with
"error" catching in ocamlyacc for example, to just ignore errors) 
so that the tokens can be picked up, and the decision if the e.g. a found string
should have been an int.


So it's rather about parsing techniques.

Maybe I'm too much off-topic here.

Sorry if I am.

But somehow I think when using OCaml things behave different than doing it in
C, and if I want to take the advantages of OCaml and the type system (to use
the type system as constraints to program structure, pushing invariants into
the program via type system), how can I nevertheless do a complete parse - as
far as possible - and after creating a parse tree, analyze the tree (instead of
being forced to stop at the first error).

Should there be error-tokens inserted into the parse tree?
Or will this become a big mess and I better just stop at the first error
of my input language?

For example in a book I found mentioned, that type checking is a very late stage
in parsing. But I doubt this was written with OCaml in mind, even though
it was stated as general.


Ciao,
   Oliver



      reply	other threads:[~2010-10-23  2:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 14:59 Oliver Bandel
2010-10-22 17:41 ` [Caml-list] " Oliver Bandel
2010-10-22 23:43 ` Norman Hardy
2010-10-23  2:25   ` oliver [this message]

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=20101023022542.GA17861@siouxsie \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@yquem.inria.fr \
    --cc=norm@cap-lore.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;
as well as URLs for NNTP newsgroup(s).