Replies: 1 comment
-
That's a fun analysis!
And yeah, the ambiguity doesn't really bother me. There's no way to make
extensions that are guaranteed not to break in the future anyway, since Lua
itself may change, so instead of trying to guess by using free sigils and
the like (which may conflict with a future Lua version!), I went with a
practical approach of adding these extensions which are readable, and
which, as you said, are unlikely to cause real-world conflicts. Further, we
keep them as soft keywords, so that they can still be used in
non-conflicting contexts.
Lua itself has an ambiguous grammar with a tie-break decided by the parser
implementation (in function calls of parenthesised expressions), so there's
even precedent for that.
If somebody hits a non-contrived real-world issue, we might revisit that,
but so far I think Teal's additions to the Lua grammar have been pretty
unproblematic!
… |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Does it bother you that Teal's grammar is ambiguous? For example:
local type foo = nil print ( foo )
In the above line,
local type
andfoo = nil
can be parsed as separate statements according to Teal's grammar.This is due to the fact that
type
is aName
, not a keyword. (In addition totype
, it appears there are 7 otherName
s that are used as faux-keywords in Teal's grammar.)At present, the below line is also grammatically and syntactically correct (at least according to the grammar), yet it too results in syntax errors:
local record foo = nil
Whereas,
local record ; foo = nil
generates non-syntax errors.It might be possible to remove the ambiguity by replacing this:
with the below two lines (as has been done for
global
):I have not been able to come up with a "real world" example where the ambiguity is likely to cause a serious problem.
It might be worth pointing out on the grammar page that the 8 faux-keywords are
Name
s that get special treatment in certain contexts, and that Teal's reserved keywords are exactly the same as Lua's reserved keywords.Beta Was this translation helpful? Give feedback.
All reactions