lua-users home
lua-l archive

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


On Mon, Jul 29, 2019 at 5:33 PM Carl Glassberg <carlglassberg@gmail.com> wrote:
Hello:

This is an example of a syntactically valid legal _expression_ in Lua,
taken from the PEGTL github grammar for Lua, by Dr. Colin Hirsch and
Daniel Frey (I hope they don't mind me repeating it here):
   ( a * b ).c()[ d ].e:f()

 Other than being a function (method?) call to f, what is the meaning
of the parse of it, step by step, from left to right?

Thanks for your assistance!

Carl

The names a, b, and d refer to variables.

Multiply the value in the variable a with the value in the variable b. Call this T1.

Treating T1 as an object, extract the entry named "c". Call this T2.

Invoke T2 as a function with no parameters. Call the result T3.

Treating T3 as an object, extract the entry with a key equal to the value found in the variable d. Call this T4.

Treating T4 as an object, extract the entry named "e". Call this T5.

Treating T5 as an object, extract the entry named "f". Call this T6.

Invoke T6 as a function, passing T5 as the only parameter. (By convention, this parameter should be named "self".)

/s/ Adam