From: Andreas Rossberg <rossberg@mpi-sws.org>
To: Yitzhak Mandelbaum <yitzhak@research.att.com>,
Mike Lin <nilekim@gmail.com>
Cc: Andrej Bauer <Andrej.Bauer@andrej.com>, caml-list@inria.fr
Subject: Re: [Caml-list] ocamllex and python-style indentation
Date: Wed, 1 Jul 2009 00:06:09 +0200 [thread overview]
Message-ID: <1750DDE9-4FC6-4657-9687-58240F520A70@mpi-sws.org> (raw)
In-Reply-To: <E47AC31E-BF02-4440-A0BD-EB4B2D90182A@research.att.com>
On Jun 30, 2009, at 20.58 h, Yitzhak Mandelbaum wrote:
> To restart this thread, do your solutions handle the following
> (legal) variation of the original example?
>
> if True:
> x = 3+4
> y = (2 +
> 4 + 5)
> z = 5
> else:
> x = 5
> if False:
> x = 8
> z = 2
>
> Notice that the assignment of y wraps onto the next line at an
> *earlier* column. This is legal b/c it is surrounded by parens.
> However, it seems that the preprocessing approaches will fail for
> this example. Do you have a workaround?
Handling that wouldn't be hard with the approach I described. You only
need to have parentheses start a dummy block at column 0, so that no
tokens will be inserted inside it .
However, I don't think it is actually a good idea to allow this. (And
I don't think Haskell does, but I may misremember.)
On Jun 30, 2009, at 22.19 h, Mike Lin wrote:
> More generally, you've got parentheses, comments, and string literals,
> and you need to know to ignore whitespace within any of those -- and
> to ignore e.g. an open parenthesis that occurs within a comment, or a
> close comment that occurs within a string literal. So inevitably
> you've got to lex and parse at some level to make this work for a
> practical language.
Comments and string literals are no problem, since the lex wrapper
will never see anything inside them as separate tokens anyway.
- Andreas
next prev parent reply other threads:[~2009-06-30 22:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-11 12:57 Andrej Bauer
2009-06-11 13:12 ` [Caml-list] " yoann padioleau
2009-06-11 13:21 ` Andreas Rossberg
2009-06-11 13:44 ` Martin Jambon
2009-06-12 8:20 ` Andrej Bauer
2009-06-12 12:56 ` Martin Jambon
2009-06-12 13:34 ` Martin Jambon
2009-06-12 15:43 ` Andreas Rossberg
2009-06-30 18:58 ` Yitzhak Mandelbaum
2009-06-30 20:19 ` Mike Lin
2009-06-30 22:06 ` Andreas Rossberg [this message]
2009-07-01 2:13 ` Mike Lin
2009-07-01 7:31 ` Andreas Rossberg
2009-07-01 14:02 ` Mike Lin
2009-07-01 14:17 ` Andreas Rossberg
2009-07-01 14:21 ` Andreas Rossberg
2009-07-01 14:37 ` Mike Lin
2009-07-01 15:03 ` Sylvain Le Gall
2009-07-01 15:16 ` [Caml-list] " Andreas Rossberg
2009-07-01 16:26 ` Sylvain Le Gall
2009-07-01 15:19 ` [Caml-list] " Martin Jambon
2009-07-01 15:43 ` Andreas Rossberg
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=1750DDE9-4FC6-4657-9687-58240F520A70@mpi-sws.org \
--to=rossberg@mpi-sws.org \
--cc=Andrej.Bauer@andrej.com \
--cc=caml-list@inria.fr \
--cc=nilekim@gmail.com \
--cc=yitzhak@research.att.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