Discussion: new operators for numerical computation

John Lull lull at acm.org
Thu Jul 20 22:15:02 EDT 2000


Gregory Lielens <gregory.lielens at fft.be> wrote (with possible
deletions):

> I like the parethese a lot! except for ° which is probably out of
> question, 
> this is the prettier way to do it, but (alwas a but :-( )
> 
> - the solve operator indeed...The only thing i can come with is the ugly
> (%)
>   or the pretty but out-of-question (\)
> - patching the parser to deal with that looks a lot more difficult than
> @ or even
>   . variants (this is doable - in fact, this is already done...) because
> I think
>   (){}[] are treated in a more specific way by the Grammar...I think to
> implement that
>   we need a real Grammar guru!

I'm no expert on the Python lexical analyzer, but I'd be surprised if
the parens are a real problem.  The '\' yes -- but not the parens.  A
typical 'maximal munch' rule says that if the same character could be
the start of several different tokens, the longest matching token
wins. That's why Python has no trouble distinguishing between the
delimiter '=' and the operator '=='.

The \ is likely handled as a completely separate step, prior to
lexical analysis, so the lexical analyzer only sees it when the source
code has it doubled:
  source code:            '\\'
  lexical analyzer sees:  '\'

Regards,
John



More information about the Python-list mailing list