lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
> Sent: Thursday, November 27, 2003 4:34 AM
> Subject: Re: On the subject of Lua's grammar... --[[ ]]
> 
> > That syntax does look pretty wacky, [...]
> 
> Suggestions for improvements are wellcome. The syntax needs to allow
the
> inclusion of any literal string; it would be nice if the old `[[ ]]'
> could fit as a special case of the new format.

Woo I didn't think I'd be saying this, but what about the way it works
in Perl?

e.g. <<END;

I can put anything I want here until my own delimiter is met...

END

This could extend to comments and strings, e.g.

-- Single line comment

s = "Single line string"

m = [[Multiline 
string can inhabit
several lines....
]]

--[[Multiline comment can
be spaced over several
lines.]]

m2 = [*[END]*] Multiline strings
can be split over several lines
and [[ optionally contain and characters I like ]]
as long as its not the delimiter I specified.
END

--[*[END]*] Multiline strings
can be split over several lines
and [[ optionally contain and characters I like ]]
as long as its not the delimiter I specified.
END

The following would be the same as --[[ ]]

--[*[]]]*] Multiline strings
can be split over several lines
and [[ optionally contain and characters I like 
as long as its not the delimiter I specified.
]]

[*[...]*] is quite clear, almost like a section heading.

In Python you can enclose anything in """ (except """) so long comments
are strings which are discarded. I quite like this as it slims the
language down slightly. It might be nice to discard --[[ and --[*[ and
just discard [[ and [*[ string which are not assigned to a variable. I
assume this causes problems for the parser (e.g. because a function has
option brackets around a single argument)?

I suppose Robertos suggestion is simpler --[***[ ... ]***] but I thought
I'd suggest this.

--[*[Nick]*]

Regards,
Nick