On 5/2/06, Neal Norwitz <[EMAIL PROTECTED]> wrote:
> On 5/2/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> >
> > I think Guido had the best solution. Use set() for empty sets, use {}
> > for empty dicts, use {genexp} for set comprehensions/displays, use
> > {1,2,3} for explicit set literals, and use {k1:v1, k2:v2} for dict
> > literals. We can always add {/} later if demand exceeds distaste.
>
> Presumably {1, 2, 3: 4} would yield a syntax error?
Of course. I am thinking of the syntax as a kind of railroad diagram
for a finite state machine; from '{' you can go directly to '}' or to
EXPR; after that you can see ':' or ',' or '}'; if you see ':' from
then on you are constrained to EXPR:EXPR pairs; if you see '.' you are
constrained to single EXPRs alternating with commas. Taking the
current Grammar file we could do this:
atom: ... | '{' [dictorsetmaker] '}'
dictorsetmaker: test ':' test (',' test ':' test)* [','] | test
(',' test)* [',']
The apparent ambiguity between the two alternatives in the second rule
doesn't matter; our parser generator takes all the alternatives for a
rule together and turns them into a finite state machine as described
above.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com