lua-users home
lua-l archive

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

On Tue, May 28, 2013 at 9:38 PM, Gavin Kistner <> wrote:
> On May 28, 2013, at 6:12 PM, Luiz Henrique de Figueiredo <> wrote:
>> The syntax in section 9 of the manual is based on the tokens described
>> in section 3.1. The tokens in section 9 are either reserved words shown
>> in bold or literal strings shown quoted. The exception as you have noted
>> are Name, String, and Number. The words not in bold are non-terminals.
> Thanks for the response (and the language :).
> I never realized that the formatting of bold was intended to convey literal strings, so that's helpful. (But not EBNF, nor described in the manual. Why rely on formatting to convey something already covered by EBNF, and that you use for some of them?)
>> There is indeed no formal grammar for the tokens; the textual description
>> seems much more useful than regexes.
> I agree that a textual description is more useful than regexes. However, an EBNF that isn't rigorous isn't much use (to me, anyhow). Wouldn't you agree that having the (excellent, informative) prose *and* a real, robust, correct grammar in the spec would be better than the current situation?

I would say that defining something like Lua/C strings with EBNF, and
even more so with regex, is awkward. I'm not sure where this
expectation is coming from, anyway, since string constants usually
aren't described this way.

This is a grammar for short form string literals. Notice how verbose
it is in comparison to the explanation in $ S3.1 "Lexical

s = dq | sq;

dq = '"', dqb, '"';

sq = "'", sqb, "'";

dqb = { dnc | ec };

dnc = ?? regex [^"\] ??;

sqb = { snc | ec };

snc = ?? regex [^'\] ??;

ec = '\',
   ( ?? regex [abfnrtv\"'z] ??
   | Newline
   | 'x', hexdigit [, hexdigit ]
   | decdigit [, decdigit [, decdigit ] ]
   | '0' );