60 likes | 166 Views
A Short Example. This example is from Chapter 11 of the text book It is a small example of specifying an “identifier” or “name” table with Z language The identifier table : Holds unique names of program variables, process names, or file names
E N D
A Short Example • This example is from Chapter 11 of the text book • It is a small example of specifying an “identifier” or “name” table with Z language • The identifier table : • Holds unique names of program variables, process names, or file names • Has an upper limit, max-id, in the total # of names. • Three operations against the identifier table is specified
Example (cont.) • The set of identifiers or names is stated as follows: [ Identifiers ] • The schema for the table is : Sym_Table max-id : N table : F Identifiers # table =< max-id
Example (cont.) • The schema representing the before and after states of the Sym_Table is as follows and note that • # table =<max-id and • # table’=<max-id Sym_Table Sym_Table Sym_Table’
Example (cont.) • Specifying the “adding” of an identifier to the table Add_id id ? : Identifier Sym_Table id ? table table’ = table U { id? }
Example (cont.) • Specifying the “removal” of an identifier fro the table Remove_id id ? : Identifier Sym_Table id ? table table’ = table \ { id? }
Example (cont.) • Search for an id in the table. • This requires an additional definition by enumeration: Results ::= T I F Search_id id ? : Identifier Sym_Table found ! : Results id ? table -> found ! = T id? table -> found ! = F