Question: Suppose we are testing a compiler for a new programming language, and one of its features is declaring arrays. An array declaration has the following

Suppose we are testing a compiler for a new programming language, and one of its features is declaring arrays. An array declaration has the following format:

Array

where specifies the data type of an array. There are five types to choose from: Integer, Real, Bool, Characters and Decimal. stands for an array name. An array name can be one to four letters or digits, the first of which must be a letter. The Array keyword is optional.

describes the number of dimensions of an array. An array can have at least one dimension and at most 5 dimensions. Dimensions of an array follow the following form:

[ {,}]

The curly braces { } are not part of the dimensions representation but are used to indicate that item enclosed inside the braces can occur zero or more times.

describes the size of the array and the range of values that the array index can take.

:

Both values may be a numeric integer value in the range of -500 to 750 or a variable name but cannot be a function call. The lower bound is optional, and if it is not specified then it is assumed to be one. The value of upper bound should always be greater than or equal to the lower bound.

Examples of valid array declarations:

  • Integer A Array [-2:3]
    • is a one-dimensional integer array of six elements with indices -2, -1, 0, 1, 2 and 3.
  • Decimal arr2 [1:5, 4]
    • is a two-dimensional array of five rows and four columns. The values of the first index: 1, 2, 3, 4, 5 and the second index: 1, 2, 3, 4.

- Bool b Array [5:5,-20:-15]

  • is a two-dimensional array of one row and six columns. The only value of the first index is: 5 and the values of the second index is: -20, -19, -18, -17, -16, -15.

Need to derive all equivalence classes(valid / invalid) from the above question

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!