Python language spec

Nolan Darilek nolan_d at bigfoot.com
Sun Jan 2 22:11:28 EST 2000


>>>>> "Neel" == Neel Krishnaswami <neelk at brick.cswv.com> writes:

    Neel> Now, a reasonable question to ask is: why are there so many
    Neel> different kinds of expression when they all seem to reduce
    Neel> to the same thing?  (This seemed to me to be the thing that
    Neel> was confusing you. Let me know if I misunderstood.)

Exactly.

    Neel> The answer is that different operators have different
    Neel> precedences, and having separate rules is a way of ensuring
    Neel> that the parser will emit a syntax tree that properly
    Neel> observes the operator precedences that are expected.  A
    Neel> simple way of getting an intuition about this is to write
    Neel> down some arithmetic expressions and then manually reduce
    Neel> them using the rules of the grammar.

Ah. So, if I am to understand you correctly, this syntax is being used
such that precedences are expressed in a neutral fassion. That
wouldn't be necessary using Yacc since it offers %left and friends to
describe operator precedences. Is that accurate?

Thanks for the tip; I'm downloading the source to have a look at the
grammar.




More information about the Python-list mailing list