lua-users home
lua-l archive

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


Thank you for special answer.

This is helpful, I also now found the defines/enums NUM_RESERVED and TK_EOS, and like this I see how I could find such "<eof> error events" in the lua code... . This is fine for me.

btw I am just implementing Lua 5.4.3 with Luaconf setting LUA_32BITS into the ARM CortexM4 STM32G4 device line for some IoT applications (M4 includes hardware 32bit floating point), and this really works extremely nice. If I use optimization level 3 in ARMCC-Keil compiler, and if I use luaL_openLibs function to include all standard libs, then it compiles to about 110kByte ROM size... and if I use only basic libraries like base, coroutines, math, string, utf8, table, then it compiles down to only about 50kByte ROM size, this is FULL size of complete application, including ARMCC microlib (but WITHOUT any file system - I want to run just ONE Lua "file" context which will be found at some fix defined location in ROM - this sounds probably very simple to you or any "Lua multi-system guys", but for me this promises an extremely cute and useful solution so far, thank you very much for this.).

The stripping down of code to 50kByte ROM size if the more sophisticated libs are kept out is also a very nice proof of the very efficient "automatic linker code stripping" by ARM CC, and about the somehow very clear programming style of your Lua code, thank you (but for now, and as STM32G4 meanwhile really is available with 512kB ROM quite by standard down to QFN housings, I keep with the luaL_openLibs and the 110kB ROM).

(using optimisation level O1, which somehow is required for "reasonable debugging facilities", the code size will increase by about 20% to 60kB / 120-130kB, but this still is really fine so far...).

On Thu, Jun 10, 2021 at 3:25 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> is there somewhere some list of the error messages used by Lua?

No. Several error messages are composed of "submessages", so that there
is great variability in their formats. (In general, we think that,
when we use standardized error messages, there is a tendency to give
less information than is available, in order to fit the standard.)


> In luac.c there is a function named "incomplete" which contains the
> following code:
>
> #define EOFMARK "<eof>"
> #define marklen (sizeof(EOFMARK)/sizeof(char) - 1)
> ...
> if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) {
> [...]
> (anyway this luaX_tokens list of reserved workds is a bit longer than the
> reserved word list int he reference manual, chapter 3.1: It further
> contains the following 5 strings as reserved words: "<eof>", "<number>",
> "<integer>", "<name>", "<string>" ... but I do not really see in the
> reference manual where those are really used... . (Looking of "<eof>" in
> the reference manual gives no result...).

That is not a list of reserved words, it is a list of printable names
for tokens. The extra elements are used for error messages. For
instance, in the message

  <name> expected near '('

"<name>" came from that list.  Similarly, "<eof>" comes from that list
when needed:

  $ echo 'function end' | lua
  lua: stdin:1: <name> expected near 'end'

  $ echo 'function ()' | lua
  lua: stdin:1: <name> expected near '('

  $ echo function | lua
  lua: stdin:2: <name> expected near <eof>

-- Roberto