Tim Roberts schrieb: > Scott David Daniels <[EMAIL PROTECTED]> wrote: > > > >What kind of shenanigans must a parser go through to translate: > > <x**2 with(x)><<x**3 with(x)> > > > >this is the comparison of two functions, but it looks like a left- > >shift on a function until the second with is encountered. Then > >you need to backtrack to the shift and convert it to a pair of > >less-thans before you can successfully translate it. > > C++ solves this exact problem quite reasonably by having a greedy > tokenizer. Thus, that would always be a left shift operator. To make it > less than and a function, insert a space: > <x**2 with(x)>< <x**3 with(x)> > -- > - Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc.
Python does have such a greedy/longest match tokenizer too: >>> 2 .__add__(3) # insert whitespace before dot 5 >>> 2.__add__(3) # 2. is a float -> Exception Kay -- http://mail.python.org/mailman/listinfo/python-list