[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.1: Question on how the Lua parser evaluates bodies
- From: Andrew Gierth <andrew@...>
- Date: Fri, 19 Jun 2020 18:05:33 +0100
>>>>> "Alexander" == Alexander Walz <email@example.com> writes:
Alexander> Hello Luiz Henrique,
Alexander> you are right with block() , I am sorry.
Alexander> I get this in Lua 5.1:
The REPL decides whether it has a complete statement to execute by doing
a load() on whatever it has, and seeing if there's a syntax error at the
very end of the input. So in your example, the first two calls to
block() are for the strings [[do]] (which fails) and [[do print("Lua")]]
(which also fails), and then the third call for [[do print("Lua") end]]
succeeds and the REPL then runs the resulting chunk.