[nem-en] indentation syntax ideas
Michal Moskal
michal.moskal at gmail.com
Sun Oct 30 22:56:04 CET 2005
On 10/30/05, Kamil Skalski <kamil.skalski at gmail.com> wrote:
> 2005/10/28, Michal Moskal <michal.moskal at gmail.com>:
> >
> > 2. similarly for
> > [SomeAttribute]
> > class Something ...
> > it adds ; after ].
>
> So it works now for every kind of [] ? Maybe the more "safe" way to
> do this is to allow
> code like
>
> [Foo];
> class A { }
>
> in standard parser?
I guess this would be better idea. I just don't know how feasible it is.
I didn't change anything in []-handling, just added \-handling.
> > Now the syntax is activated by the -i switch. Maybe it would be good
> > to provide something like #pragma indent or #indent to activate it
> > on file-by-file basis (that is no mixture of syntaxes within a file,
> > just when the traditional lexer sees #indent, it aborts and creates a
> > new indentaion lexer for this file).
>
> The worst thing about -i is that it can introduce strange bugs into
> normal {}-programs...
Remember that once you're inside {...} the indentation syntax is off.
This means any possible bug is at the class definition (or even namespace
definition) level in most cases (i.e. when the top-level code feature
is not used). It is hard to mess something with the parser alone there.
> So I'm not so sure if mixing styles is a good
> thing.
This certainly OK to include traditional lambda expressions inside
indentation code, like in:
def foo ()
def l = some_list ()
l.Map (fun (x) { x + 2 })
Of course once we will support x => x + 2 kind of stuff this usage will
go away. But it still may be good idea to support mixing syntaxes, at
least for some third party syntax extensions.
> Having ability to specify exactly files with indentation
> support would be quite nice and #pragma seems to be the cleanest
> design for me. I guess it is even worth the unelegant lexer-change
> implementation, though we could force users to specify the mode at the
> very beginning of file. So PreParser could have something like "parse
> preludium" and then maybe change the lexer.
I guess it would have to skip comments first. Otherwise I'm OK with
the idea this has to be the first thing in a file.
> The proposal of Philippe looks like an universal solution, which would
> give us what we need in an easy way. I still don't really like the
> design in which ordering of command line parameters change the
> semantics... As for now, I would vote against, but if others like it?
I also don't like this semantics. I guess when one wants to have
a mix of files with new and old syntax, the best solution is to use #pragma
indent.
As for the second suggestion (the next email), I'm happy with ignoring
Semicolon (true) at the top-level, if it's possible.
--
Michal Moskal,
http://nemerle.org/~malekith/
More information about the devel-en
mailing list