Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Re: [Caml-announce] OCamldoc
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Marcin 'Qrczak' Kowalczyk <qrczak@k...>
Subject: Re: [Caml-list] Re: [Caml-announce] OCamldoc
Thu, 11 Oct 2001 21:32:11 +0200, Xavier Leroy <xavier.leroy@inria.fr> pisze:

> But: languages where indentation is significant (Haskell, Occam,
> Python) have bad reputation as being 1- harder to parse (for a
> program), and 2- intolerant w.r.t. cut-and-paste or machine-generated
> code.  2- is perhaps less of a problem for documentation comments
> (they are rarely machine-generated :-), but 1- worries me.  I've been
> hacking Lex and Yacc for years, still I do not have the slightest idea
> on how to take indentation into account in a Lex/Yacc parser...

I've recently implemented a toy language with significant layout.
Conclusions:

It's easy to parse with a lexer written by hand and a parser generated
by Happy (Yacc for Haskell). What is needed (and what Happy provides):
a state threaded through both lexer and parser. The lexer converts
layout to virtual brackets of some sort and virtual semicolons.

It's easy to write a lexer by hand in a functional language. I don't
know about handling layout with Lex. Parsing is not affected by layout.

Significant layout is practical for languages with enough static
checking (either by static typing or by a redundant grammar). It's
impractical for languages where almost any sequence of tokens is
valid at compile time.

In particular it works for Haskell (both reasons) and Python
(grammar with enough amount of redundancy). It didn't work well
for my language :-)

I'm sure it would work for core OCaml, but there might be problems
with ocamldoc if errors in layout of special comments are generally
not catched and just change the meaning.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr