The Extended WHILE Statement
One obvious example would be ORP.selector, which could be expressed using the Dijkstra guarded repetition as follows: PROCEDURE selector(VAR x: ORG.Item); VAR y: ORG.Item; obj: ORB.Object; BEGIN WHILE sym = ORS.lbrak DO REPEAT ORS.Get(sym); expression(y); IF x.type.form = ORB.Array THEN CheckInt(y); ORG.Index(x, y); x.type := x.type.base ELSE ORS.Mark("not an array") END UNTIL sym # ORS.comma; Check(ORS.rbrak, "no ]") ELSIF sym = ORS.period DO ORS.Get(sym); IF sym = ORS.ident THEN IF x.type.form = ORB.Pointer THEN ORG.DeRef(x); x.type := x.type.base END ; IF x.type.form = ORB.Record THEN obj := ORB.thisfield(x.type); ORS.Get(sym); IF obj # NIL THEN ORG.Field(x, obj); x.type := obj.type ELSE ORS.Mark("undef") END ELSE ORS.Mark("not a record") END ELSE ORS.Mark("ident?") END ELSIF sym = ORS.arrow DO ORS.Get(sym); IF x.type.form = ORB.Pointer THEN ORG.DeRef(x); x.type := x.type.base ELSE ORS.Mark("not a pointer") END ELSIF (sym = ORS.lparen) & (x.type.form IN {ORB.Record, ORB.Pointer}) DO (*type guard*) ORS.Get(sym); IF sym = ORS.ident THEN qualident(obj); IF obj.class = ORB.Typ THEN TypeTest(x, obj.type, TRUE) ELSE ORS.Mark("guard type expected") END ELSE ORS.Mark("not an identifier") END ; Check(ORS.rparen, " ) missing") END END selector;
Thank you to Michael and Andreas for your examples. I had already offered the free Professional copy of the Astrobe compiler to Michael. He very kindly redirected the offer to Paul Reed who was grateful for his offer. However, I had excluded him a) because we had discussed the Extended WHILE at length and he had 'inside information' and b) he already has the Astrobe compilers :) Michael then agreed with me to give it to 'gray' in recognition of his extensive work with Oberon-RTK <https://oberon-rtk.org/> I consider Andreas to be similarly deserving so I'll contact him directly with the offer and now declare that the challenge is ended.
participants (2)
-
Andreas Pirklbauer -
Chris Burrows