[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table key starting with backslash
- From: "Alexandre (gaumerie)" <gaumerie@...>
- Date: Sun, 1 Nov 2015 13:28:23 +0100
>From the manual:
3.1 – Lexical Conventions
Lua is a free-form language. It ignores spaces (including new lines) and comments between lexical elements (tokens), except as delimiters between names and keywords.
Names (also called identifiers) in Lua can be any string of letters, digits, and underscores, not beginning with a digit. Identifiers are used to name variables, table fields, and labels.
Alexandre
--- Original Message ---
From: "Christopher Kappe" <nox_diesque@web.de>
Sent: 1 November 2015 10:44
To: lua-l@lists.lua.org
Subject: Re: table key starting with backslash
Still wondering if anyone can say sth. regarding this topic.
If the escape character "\" isn't allowed as first character in a string
key, it should be stated somewhere. Also, I would be interested in an
explanation why it is like that.
Am 09.10.2015 um 11:36 schrieb Christopher Kappe:
> Hello,
>
> I think I stumbled upon an error in the Lua parser or at least in the
> manual.
> I want to write a table mapping from special characters given in their
> LaTeX representation to the utf8 character. Like this (using the well
> known syntactic sugar for string keys):
>
> local latexToUtf8 = {
> \\\"a = "ä", -- without escaping: \"a
> \\\"o = "ö"
> -- etc.
> }
>
> This does not compile! However, this works:
>
> local latexToUtf8 = {
> ["\\\"a"] = "ä",
> ["\\\"o"] = "ö"
> }
>
> This contradicts the following sentence from
> http://www.lua.org/manual/5.3/manual.html
> A field of the form name = exp is equivalent to ["name"] = exp.
>
> Because all accents combined with all possible letters makes a large
> number, this table is going to be quite long, so I would really be happy
> if I could save the [""]
>
> Regards
> Christopher
>