What are the specifications and operations of data structures in compiler design?

The major attributes for specifying data structures include the following −

  • Number of components − A data structure can be of fixed size if the number of components is even during its lifetime or of the variable size if the number of components transforms dynamically. Variable size data structure types generally define operations that insert and delete elements from structures.

Arrays and records are examples of fixed-size data structure types. Stacks, lists, sets, tables, and files are an example of variable size data types. Variable size data objects use a pointer data type that enables fixed-size data objects to be connected explicitly by the programmer.

  • Type of each component − A data structure is homogeneous if all its elements are of an equal type. It is heterogeneous if its elements are of multiple types. Arrays, sets, and files are generally homogeneous, whereas records and lists are generally heterogeneous.

  • Names to be used for selecting components − A data structure type requires a selection structure for recognizing a single element of the data structure. For an array, the name of a single component can be an integer subscript or sequence of subscripts, for a table, the name can be a programmer-defined identifier; for a record, the name is generally a programmer-defined identifier.

  • Maximum number of components − For a variable size data structure including a stack, a maximum size for the structure because of multiple components can be defined.

Operations on data structures − Specification of the domain and range of operations on data structure types can be given in much the similar form as for elementary data types. Some new classes of operations are of specific importance −

  • Component selection operations − Processing of data structures often proceeds by fetching each component of the structure. Two types of selection operations access components of a data structure and produce them accessible for processing by different operations such as random selection, in which an arbitrary component of the data structure is created, and sequential selection, in which components are selected in a predetermined sequence.

  • Whole-data structure operations − Operations can take whole data structures as arguments and create new data structures as results. The most language supports a definite set of such whole-data structure operations. For example, the addition of two arrays, assignment of one data to another, or a union operation on sets.

  • Insertion/deletion of components − Operations that convert the several components in a data structure have a major impact on storage representation and storage management for data structures.

  • Creation/destruction of data structures − Operations that create and destroy data structures also have a major impact on storage management for data structures.