Basic elements

Douglas Schenck, Peter W.F. Wilson · Oxford University Press eBooks · 1994

We start with the basic stuff used to build EXPRESS: the characters you use to build ‘words’ and the different kinds of words that may appear in the source. Computer languages call these words tokens. You compose characters according to syntax rules to form different kinds of tokens. In turn, tokens are composed into statements and statements are composed into blocks (we will get to statements and blocks directly). The syntax alone does not define the language however — we also need to be concerned with semantics. Semantics deals with the meaning of well formed syntax. As an example, EXPRESS has tokens for identifiers and reserved words. Although they both look like ‘words’ they are different; an identifier cannot be the same as a keyword. EXPRESS expects to see identifiers and reserved words in specific places within statements. It is an error to put an identifier where a reserved word is expected and vice versa. EXPRESS is correctly written only when both the syntactic and semantical rules are observed. EXPRESS source is composed as a stream of characters. The source stream is decoded into tokens, statements and blocks according to the syntax rules. The source is typically broken into a number of physical lines, which is any number (including zero) of characters ended by a ‘newline.’ The source will be more attractive and easier to read when statements are broken into lines and whitespace is used to set off different constructs. The following declarations are the same to an EXPRESS parser, but give different impressions to human readers. The EXPRESS character set is easy to explain —just look at your computer keyboard. Most of the characters you see there are used to write EXPRESS. However, there is a more complicated explanation which follows: the EXPRESS character set is denned as cells 00-7F of plane 00 of group 00 of ISO 10646. Of those characters, cells 20-7E as shown in Table 9.1 are actually used to write EXPRESS. Any other character (cells 00-1F, 7F) is called a ‘rogue’ character, and if used is treated as a space unless it appears within a string literal or a remark.

Read the paper · More papers on PaperTik