.sp 1.5i .LP .vs 14 .nh .ft B Appendix A: ISO-PASCAL grammar .ft R \fBA.1 Lexical tokens\fR The syntax describes the formation of lexical tokens from characters and the separation of these tokens, and therefore does not adhere to the same rules as the syntax in A.2. The lexical tokens used to construct Pascal programs shall be classified into special-symbols, identifiers, directives, unsigned-numbers, labels and character-strings. The representation of any letter (upper-case or lower-case, differences of font, etc) occurring anywhere outside of a character-string shall be insignificant in that occurrence to the meaning of the program. letter = \fBa\fR | \fBb\fR | \fBc\fR | \fBd\fR | \fBe\fR | \fBf\fR | \fBg\fR | \fBh\fR | \fBi\fR | \fBj\fR | \fBk\fR | \fBl\fR | \fBm\fR | \fBn\fR | \fBo\fR | \fBp\fR | \fBq\fR | \fBr\fR | \fBs\fR | \fBt\fR | \fBu\fR | \fBv\fR | \fBw\fR | \fBx\fR | \fBy\fR | \fBz\fR . digit = \fB0\fR | \fB1\fR | \fB2\fR | \fB3\fR | \fB4\fR | \fB5\fR | \fB6\fR | \fB7\fR | \fB8\fR | \fB9\fR . The special symbols are tokens having special meanings and shall be used to delimit the syntactic units of the language. special-symbol = \fB+\fR | \fB\-\fR | \fB*\fR | \fB/\fR | \fB=\fR | \fB<\fR | \fB>\fR | \fB[\fR | \fB]\fR | \fB.\fR | \fB,\fR | \fB:\fR | \fB;\fR | \fB^\fR | \fB(\fR | \fB)\fR | \fB<>\fR | \fB<=\fR | \fB>=\fR | \fB:=\fR | \fB..\fR | \h'\w'special-symbol = 'u'word-symbol . word-symbol = \fBand\fR | \fBarray\fR | \fBbegin\fR | \fBcase\fR | \fBconst\fR | \fBdiv\fR | \fBdo\fR | \fBdownto\fR | \fBelse\fR | \fBend\fR | \fBfile\fR | \fBfor\fR | \fBfunction\fR | \h'\w'word-symbol = 'u'\fBgoto\fR | \fBif\fR | \fBin\fR | \fBlabel\fR | \fBmod\fR | \fBnil\fR | \fBnot\fR | \fBof\fR | \fBor\fR | \fBpacked\fR | \fBprocedure\fR | \fBprogram\fR | \fBrecord\fR | \h'\w'word-symbol = 'u'\fBrepeat\fR | \fBset\fR | \fBthen\fR | \fBto\fR | \fBtype\fR | \fBuntil\fR | \fBvar\fR | \fBwhile\fR | \fBwith\fR . Identifiers may be of any length. All characters of an identifier shall be significant. No identifier shall have the same spelling as any word-symbol. identifier = letter { letter | digit } . A directive shall only occur in a procedure-declaration or function-declaration. No directive shall have the same spelling as any word-symbol. directive = letter {letter | digit} . Numbers are given in decimal notation. .nf unsigned-integer = digit-sequence . unsigned-real = unsigned-integer \fB.\fR fractional-part [ \fBe\fR scale-factor ] | unsigned-integer \fBe\fR scale-factor . digit-sequence = digit {digit} . fractional-part = digit-sequence . scale-factor = signed-integer . signed-integer = [sign] unsigned-integer . sign = \fB+\fR | \fB\-\fR . .fi .bp Labels shall be digit-sequences and shall be distinguished by their apparent integral values and shall be in the closed interval 0 to 9999. label = digit-sequence . A character-string containing a single string-element shall denote a value of the required char-type. Each string-character shall denote an implementation- defined value of the required char-type. .nf character-string = \fB'\fR string-element { string-element } \fB'\fR . string-element = apostrophe-image | string-character . apostrophe-image = \fB''\fR . string-character = All 7-bits ASCII characters except linefeed (10), vertical tab (11), and new page (12). .fi The construct: \fB{\fR any-sequence-of-characters-and-separations-of-lines- not-containing-right-brace \fB}\fR shall be a comment if the "{" does not occur within a character-string or within a comment. The substitution of a space for a comment shall not alter the meaning of a program. Comments, spaces (except in character-strings), and the separation of consecutive lines shall be considered to be token separators. Zero or more token separators may occur between any two consecutive tokens, or before the first token of a program text. No separators shall occur within tokens. .bp .po \fBA.2 Grammar\fR The non-terminal symbol \fIprogram\fR is the start symbol of the grammar. .nf actual-parameter : expression | variable-access | procedure-identifier | function-identifier . actual-parameter-list : \fB(\fR actual-parameter { \fB,\fR actual-parameter } \fB)\fR . adding-operator : \fB+\fR | \fB\-\fR | \fBor\fR . array-type : \fBarray\fR \fB[\fR index-type { \fB,\fR index-type } \fB]\fR \fBof\fR component-type . array-variable : variable-access . assignment-statement : ( variable-access | function-identifier ) \fB:=\fR expression . base-type : ordinal-type . block : label-declaration-part constant-definition-part type-definition-part variable-declaration-part \h'\w'block : 'u'procedure-and-function-declaration-part statement-part . Boolean-expression : expression . bound-identifier : identifier . buffer-variable : file-variable \fB^\fR . case-constant : constant . case-constant-list : case-constant { \fB,\fR case-constant } . case-index : expression . case-list-element : case-constant-list \fB:\fR statement . case-statement : \fBcase\fR case-index \fBof\fR case-list-element { \fB;\fR case-list-element } [ \fB;\fR ] \fBend\fR . component-type : type-denoter . component-variable : indexed-variable | field-designator . compound-statement : \fBbegin\fR statement-sequence \fBend\fR . conditional-statement : if-statement | case-statement . conformant-array-parameter-specification : value-conformant-array-specification | \h'+18.5m'variable-conformant-array-specification . conformant-array-schema : packed-conformant-array-schema | unpacked-conformant-array-schema . constant : [ sign ] ( unsigned-number | constant-identifier ) | character-string . constant-definition : identifier \fB=\fR constant . constant-definition-part : [ \fBconst\fR constant-definition \fB;\fR { constant-definition \fB;\fR } ] . constant-identifier : identifier . control-variable : entire-variable . domain-type : type-identifier . else-part : \fBelse\fR statement . empty-statement : . entire-variable : variable-identifier . enumerated-type : \fB(\fR identifier-list \fB)\fR . expression : simple-expression [ relational-operator simple-expression ] . .bp .po factor : variable-access | unsigned-constant | bound-identifier | function-designator | set-constructor | \h'\w'factor : 'u'\fB(\fR expression \fB)\fR | \fBnot\fR factor . field-designator : record-variable \fB.\fR field-specifier | field-designator-identifier . field-designator-identifier : identifier . field-identifier : identifier . field-list : [ ( fixed-part [ \fB;\fR variant-part ] | variant-part ) [ \fB;\fR ] ] . field-specifier : field-identifier . file-type : \fBfile\fR \fBof\fR component-type . file-variable : variable-access . final-value : expression . fixed-part : record-section { \fB;\fR record-section } . for-statement : \fBfor\fR control-variable \fB:=\fR initial-value ( \fBto\fR | \fBdownto\fR ) final-value \fBdo\fR statement . formal-parameter-list : \fB(\fR formal-parameter-section { \fB;\fR formal-parameter-section } \fB)\fR . formal-parameter-section : value-parameter-specification | variable-parameter-specification | \h'\w'formal-parameter-section : 'u'procedural-parameter-specification | functional-parameter-specification | \h'\w'formal-parameter-section : 'u'conformant-array-parameter-specification . function-block : block . function-declaration : function-heading \fB;\fR directive | function-identification \fB;\fR function-block | \h'\w'function-declaration : 'u'function-heading \fB;\fR function-block . function-designator : function-identifier [ actual-parameter-list ] . function-heading : \fBfunction\fR identifier [ formal-parameter-list ] \fB:\fR result-type . function-identification : \fBfunction\fR function-identifier . function-identifier : identifier . functional-parameter-specification : function-heading . goto-statement : \fBgoto\fR label . identified-variable : pointer-variable \fB^\fR . identifier-list : identifier { \fB,\fR identifier } . if-statement : \fBif\fR Boolean-expression \fBthen\fR statement [ else-part ] . index-expression : expression . index-type : ordinal-type . index-type-specification : identifier \fB..\fR identifier \fB:\fR ordinal-type-identifier . indexed-variable : array-variable \fB[\fR index-expression { \fB,\fR index-expression } \fB]\fR . initial-value : expression . label : digit-sequence . label-declaration-part : [ \fBlabel\fR label { \fB,\fR label } \fB;\fR ] . member-designator : expression [ \fB..\fR expression ] . multiplying-operator : \fB*\fR | \fB/\fR | \fBdiv\fR | \fBmod\fR | \fBand\fR . .bp .po new-ordinal-type : enumerated-type | subrange-type . new-pointer-type : \fB^\fR domain-type . new-structured-type : [ \fBpacked\fR ] unpacked-structured-type . new-type : new-ordinal-type | new-structured-type | new-pointer-type . ordinal-type : new-ordinal-type | ordinal-type-identifier . ordinal-type-identifier : type-identifier . packed-conformant-array-schema : \fBpacked\fR \fBarray\fR \fB[\fR index-type-specification \fB]\fR \fBof\fR type-identifier . pointer-type-identifier : type-identifier . pointer-variable : variable-access . procedural-parameter-specification : procedure-heading . procedure-and-function-declaration-part : { ( procedure-declaration | function-declaration ) \fB;\fR } . procedure-block : block . procedure-declaration : procedure-heading \fB;\fR directive | procedure-identification \fB;\fR procedure-block | \h'\w'procedure-declaration : 'u'procedure-heading \fB;\fR procedure-block . procedure-heading : \fBprocedure\fR identifier [ formal-parameter-list ] . procedure-identification : \fBprocedure \fR procedure-identifier . procedure-identifier : identifier . procedure-statement : procedure-identifier ( [ actual-parameter-list ] | read-parameter-list | readln-parameter-list | \h'\w'procedure-statement : procedure-identifier ( ['u'write-parameter-list | writeln-parameter-list ) . program : program-heading \fB;\fR program-block \fB.\fR . program-block : block . program-heading : \fBprogram\fR identifier [ \fB(\fR program-parameters \fB)\fR ] . program-parameters : identifier-list . read-parameter-list : \fB(\fR [ file-variable \fB,\fR ] variable-access { \fB,\fR variable-access } \fB)\fR . readln-parameter-list : [ \fB(\fR ( file-variable | variable-access ) { \fB,\fR variable-access } \fB)\fR ] . record-section : identifier-list \fB:\fR type-denoter . record-type : \fBrecord\fR field-list \fBend\fR . record-variable : variable-access . record-variable-list : record-variable { \fB,\fR record-variable } . relational-operator : \fB=\fR | \fB<>\fR | \fB<\fR | \fB>\fR | \fB<=\fR | \fB>=\fR | \fBin\fR . repeat-statement : \fBrepeat\fR statement-sequence \fBuntil\fR Boolean-expression . repetitive-statement : repeat-statement | while-statement | for-statement . result-type : simple-type-identifier | pointer-type-identifier . set-constructor : \fB[\fR [ member-designator { \fB,\fR member-designator } ] \fB]\fR . set-type : \fBset\fR \fBof\fR base-type . sign : \fB+\fR | \fB\-\fR . simple-expression : [ sign ] term { adding-operator term } . simple-statement : empty-statement | assignment-statement | procedure-statement | goto-statement . simple-type-identifier : type-identifier . .bp .po statement : [ label \fB:\fR ] ( simple-statement | structured-statement ) . statement-part : compound-statement . statement-sequence : statement { \fB;\fR statement } . structured-statement : compound-statement | conditional-statement | repetitive-statement | with-statement . subrange-type : constant \fB..\fR constant . tag-field : identifier . tag-type : ordinal-type-identifier . term : factor { multiplying-operator factor } . type-definition : identifier \fB=\fR type-denoter . type-definition-part : [ \fBtype\fR type-definition \fB;\fR { type-definition \fB;\fR } ] . type-denoter : type-identifier | new-type . type-identifier : identifier . unpacked-conformant-array-schema : \fBarray\fR \fB[\fR index-type-specification { \fB;\fR index-type-specification } \fB]\fR \fBof\fR \h'\w'unpacked-conformant-array-schema : 'u'( type-identifier | conformant-array-schema ) . unpacked-structured-type : array-type | record-type | set-type | file-type . unsigned-constant : unsigned-number | character-string | constant-identifier | \fBnil\fR . unsigned-number : unsigned-integer | unsigned-real . value-conformant-array-specification : identifier-list \fB:\fR conformant-array-schema . value-parameter-specification : identifier-list \fB:\fR type-identifier . variable-access : entire-variable | component-variable | identified-variable | buffer-variable . variable-conformant-array-specification : \fBvar\fR identifier-list \fB:\fR conformant-array-schema . variable-declaration : identifier-list \fB:\fR type-denoter . variable-declaration-part : [ \fBvar\fR variable-declaration \fB;\fR { variable-declaration \fB;\fR } ] . variable-identifier : identifier . variable-parameter-specification : \fBvar\fR identifier-list \fB:\fR type-identifier . variant : case-constant-list \fB:\fR \fB(\fR field-list \fB)\fR . variant-part : \fBcase\fR variant-selector \fBof\fR variant { \fB;\fR variant } . variant-selector : [ tag-field \fB:\fR ] tag-type . while-statement : \fBwhile\fR Boolean-expression \fBdo\fR statement . with-statement : \fBwith\fR record-variable-list \fBdo\fR statement . write-parameter : expression [ \fB:\fR expression [ \fB:\fR expression ] ] . write-parameter-list : \fB(\fR [ file-variable \fB,\fR ] write-parameter { \fB,\fR write-parameter } \fB)\fR . writeln-parameter-list : [ \fB(\fR ( file-variable | write-parameter ) { \fB,\fR write-parameter } \fB)\fR ] . .fi .vs .bp .po