Geek Story Hour: Parser of Death [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Sat 2009-11-07 14:13
Geek Story Hour: Parser of Death
LinkReply
[identity profile] pne.livejournal.comSat 2009-11-07 17:52
There is of course a well-known right way to resolve the if–else ambiguity, so I went away and did that.

Which is that well-known right way?

Attach the else to the most recent if which doesn't already have one?
Link Reply to this | Thread
[personal profile] simontSat 2009-11-07 18:57
Yes. The reason why that's the sensible choice has to do with bounding the amount of lookahead required by the parser: when you see the first else, you don't want to have to wait until the second (or absence thereof) in order to decide which if to attach it to, so you write the syntax so that it attaches to the same if whether there's a second else or not.
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]