Did you know this?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Did you know this?

Dirk Laurie-2
A label does not need any other punctuation. In particular,
::continue::end is legal without an intervening spaces.

Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Luiz Henrique de Figueiredo
> A label does not need any other punctuation. In particular,
> ::continue::end is legal without an intervening spaces.

Why are you surprised?

Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Dirk Laurie-2
2014-09-01 19:14 GMT+02:00 Luiz Henrique de Figueiredo <[hidden email]>:
>> A label does not need any other punctuation. In particular,
>> ::continue::end is legal without an intervening spaces.
>
> Why are you surprised?

I've been automicallly either putting a label on its own line or at worst
coding a space ever since the goto statement was introduced.
Yesterday I mistyped, so there was no space. When I noticed the
omission later, it made me wonder why there was no error.

Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Steven Degutis
To be honest, I'm a little confused about exactly how Lua's grammar
works. A big part of this is because I recently heard (on this mailing
list?) that Section 9 of the Manual ("The Complete Syntax of Lua") is
not strictly accurate but more of a general idea.

On Mon, Sep 1, 2014 at 3:17 PM, Dirk Laurie <[hidden email]> wrote:

> 2014-09-01 19:14 GMT+02:00 Luiz Henrique de Figueiredo <[hidden email]>:
>>> A label does not need any other punctuation. In particular,
>>> ::continue::end is legal without an intervening spaces.
>>
>> Why are you surprised?
>
> I've been automicallly either putting a label on its own line or at worst
> coding a space ever since the goto statement was introduced.
> Yesterday I mistyped, so there was no space. When I noticed the
> omission later, it made me wonder why there was no error.
>

Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Roberto Ierusalimschy
> To be honest, I'm a little confused about exactly how Lua's grammar
> works. A big part of this is because I recently heard (on this mailing
> list?) that Section 9 of the Manual ("The Complete Syntax of Lua") is
> not strictly accurate but more of a general idea.

It may have (unreported) errors, but it is intended to be accurate.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

KHMan
In reply to this post by Dirk Laurie-2
On 9/2/2014 4:17 AM, Dirk Laurie wrote:

> 2014-09-01 19:14 GMT+02:00 Luiz Henrique de Figueiredo:
>>> A label does not need any other punctuation. In particular,
>>> ::continue::end is legal without an intervening spaces.
>>
>> Why are you surprised?
>
> I've been automicallly either putting a label on its own line or at worst
> coding a space ever since the goto statement was introduced.
> Yesterday I mistyped, so there was no space. When I noticed the
> omission later, it made me wonder why there was no error.

There are lots of other non-standard ways of writing ::label::
that will pass the parser -- it's still unambiguous to the parser.
A look at llex and lparser would make the possibilities obvious,
for example (using Lua 5.2):

::
--comment
label
--comment
::

Etc. But most people would stick to normal usage. :-)

Editors with syntax highlighting should colour your bit of code
correctly, giving users unambiguous visual feedback. Editors based
on Scintilla (SciTE, Notepad++, Geany, etc etc) does this, or
should be doing this, at least SciTE does (but not the above
example, only a reasonable 'sane' subset).

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia


Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Tim Hill
In reply to this post by Steven Degutis

On Sep 2, 2014, at 10:03 AM, Steven Degutis <[hidden email]> wrote:

> To be honest, I'm a little confused about exactly how Lua's grammar
> works. A big part of this is because I recently heard (on this mailing
> list?) that Section 9 of the Manual ("The Complete Syntax of Lua") is
> not strictly accurate but more of a general idea.
>
> On Mon, Sep 1, 2014 at 3:17 PM, Dirk Laurie <[hidden email]> wrote:
>> 2014-09-01 19:14 GMT+02:00 Luiz Henrique de Figueiredo <[hidden email]>:
>>>> A label does not need any other punctuation. In particular,
>>>> ::continue::end is legal without an intervening spaces.
>>>
>>> Why are you surprised?
>>
>> I've been automicallly either putting a label on its own line or at worst
>> coding a space ever since the goto statement was introduced.
>> Yesterday I mistyped, so there was no space. When I noticed the
>> omission later, it made me wonder why there was no error.
>>
>


I think it’s more correct to say that, technically, it is *incomplete* since some of the non-terminals are not resolved in the grammar. I’ve studied it quite a bit and have not found any errors (though a few surprises lol).

—Tim


Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Pierre-Yves Gérardy
In reply to this post by Roberto Ierusalimschy
On Tue, Sep 2, 2014 at 8:13 PM, Roberto Ierusalimschy <[hidden email]> wrote:
> To be honest, I'm a little confused about exactly how Lua's grammar
> works. A big part of this is because I recently heard (on this mailing
> list?) that Section 9 of the Manual ("The Complete Syntax of Lua") is
> not strictly accurate but more of a general idea.

It may have (unreported) errors, but it is intended to be accurate.

The grammar ​doesn't restrict break statements to loop blocks.​

—Pierre-Yves


 
Reply | Threaded
Open this post in threaded view
|

Re: Did you know this?

Roberto Ierusalimschy
In reply to this post by Tim Hill
> I think it’s more correct to say that, technically, it is *incomplete* since some of the non-terminals are not resolved in the grammar.

Do you mean "Name", "Number", and "String"? These are terminals (but
we could make that more clear). Are there others?

-- Roberto