10.07.2015 Views

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

172 van Wijngaarden, etal.ALGOL <strong>68</strong> Revised Report173set read mood (f)fi)esacelse undefinedfi ¢ read mood is still set ¢ ;c) proc ~ check pos = (ref file D void :begin bool reading = read mood off;bool not ended : = true;while not ended : = not ended ^ get good page (f, reading);line ended (f) ^ not endeddo not ended : = (line mended off) (f) odend;{The routine check pos is used in formatted transput before each call ofput char or get char. If the position is not good (10.3.1.6.dd), it calls theappropriate event routine, and may call further event routines if true isreturned. If the event routine corresponding to on page end returns false,newpage is called but, if any other event routine returns false, no defaultaction is taken and no more event routines are called. On exit, theread/write mood is as on entry, but the current position may not be good,in which case undefined will be called in the following put char or getchar. However, check pos is also called when getting strings (hh), in whichcase the string is then terminated if the current position is not good.}10.3.4. Format texts{In formatted transput, each straightened value from a data list(cf. 10.3.3) is matched against a constituent picture of a format-textprovided by the user. A picture specifies how a value is to be converted toor from a sequence of characters and prescribes the layout of thosecharacters in the book. Features which may be specified include thenumber of digits, the position of the decimal point and of the sign, if any,suppression of zeroes and the insertion of arbitrary strings. For example,using the picture -d.3d "." 3d "." e z+d, the value 1234.567 would betransput as the string ".1.234.567.1o.+3".A "format" is a structured value (i.e., an internal object) of mode'FORMAT', which mirrors the hierarchical structure of a format-text(which is an external object). In this section are given the syntax offormat-texts and the semantics for obtaining their corresponding formats.The actual formatted transput is performed by the routines given insection 10.3.5 but, for convenience, a description of their operation is givenhere, in association with the corresponding syntax.}10.3.4.1. Collections and pictures10.3.4.1.1. Syntax{The following mode-declarations (taken from 10.3.5.a) are reflected inthe metaproduction rules A to K below.A) mode format = struct (flex [1 : O ] piece F) ;B) mode piece = struct (int cp, count, bp, flex [ 1 : 0 ] collection c) ;C) mode collection =union (picture, collitem) ;D) mode collitem =struct (insertion il, proc int rep, int p, insertion i2);E) mode insertion =flex [1 : O] struct (proc int rep, union (string, char) sa) ;F) mode picture = struct(union (pattern, cpattern, fpattern, gpattern, void) p, insertion i);G) mode pattern = struct (int type, flex [1 : O] frame frames);H) mode frame =struct (Insertion i, proc int rep, bool supp, char marker) ;I) mode cpattern =struct (insertion i, int type, flex [1 : O] insertion c);J) mode fpattern = struct (insertion i, proc format pf) ;K) mode gpattern = struct (inserUon i, flex [1 : O] proc int spec) ; }A) FORMAT :: structured with row of PIECE field letter aleph mode.B) PIECE :: structured with integral field letter c letter pintegral field letter c letter o letter u letter n letter tintegral field letter b letter prow of COLLECTION field letter c mode.C) COLLECTION :: union of PICTURE COLLITEM mode.D) COLLITEM :: structured with INSERTION field letter i digit oneprocedure yielding integral field letter r letter e letter pintegral field letter pINSERTION field letter i digit two mode.E) INSERTION :: row of structured with procedure yielding integralfield letter r letter e letter punion of row of character character mode fieldletter s letter a mode.F) PICTURE :: structured with union ofPATTERN CPATTERN FPATTERN GPATTERN void modefield letter p INSERTION field letter i mode.G) PATTERN :: structured withintegral field letter t letter y letter p letter erow of FRAME fieldletter f letter r letter a letter m letter e letter s mode.H) FRAME :: structured with INSERTION field letter iprocedure yielding integral field letter r letter e letter pboolean field letter s letter u letter p letter p character fieldletter m letter a letter r letter k letter e letter r mode.I) CPATTERN :: structured with INSERTION field letter iintegral field letter t letter y letter p letter erow of INSERTION field letter c mode.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!