[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Announce] Alpha release of a Lua debugger
- From: David Given <dg@...>
- Date: Fri, 13 Apr 2007 16:31:54 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Rici Lake wrote:
> Looked at from another perspective, the use of barewords as
> table keys is completely syntactically separate from their
> use as keywords. A table key must either follow '.' or ':'
> in postfix position, 'function' in a <function> statement,
> or it must be used as the first token in a table field and
> followed by '='.
By designing your grammar appropriately, it's quite possible to produce a
language with no reserved words. You just need to make sure you can determine
what type a token is from context. For example, addition of let and call
keywords would disambiguate assignments and function calls:
let x = 1;
let let = 1;
In both cases, this is completely unambiguous. Note the use of ; at the end of
statements, to tell the parser that the next token is a keyword.
Some Algol variants in fact went one step further and required all keywords to
'IF' IF 'THEN'
THEN = 0;
THEN = 1;
C is notoriously irritating to parse because the parse rules for a token can
change during compilation. This:
...may be a function call (if T is an identifier), or a function prototype (if
T is a type). This is a good example of how *not* to design a grammar. In
another life I'm writing an Objective C preprocessor, and dealing with this
sort of thing is a total pain in the arse.
┌── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ─── http://www.cowlark.com ───────────────────
│ "Thou who might be our Father, who perhaps may be in Heaven, hallowed be
│ Thy Name, if Name Thou hast and any desire to see it hallowed..." ---
│ _Creatures of Light and Darkness_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----