Programming Language Project

Question Set #2

Due: November 4, 2004 at start of class

Answers MUST be keyed in before printing

 

Name  Christopher Payne           Programming Language  Object Oriented Turing (OOT)

 

Note:  For each of these question sets, you should look first in the reports you were given.  You should then check the information on the Web or in a book.  If the information is not in the report, you should say so and then find it on the Web or in a book.

 

1.         How is  the symtax of your language described?  (i.e. using BNF,  with syntax diagrams, with examples, in words) feel free to provide links to where you found examples and an  example. If you found it in a book, give the title, author and page numbers;   If you found it on the web, give a URL. Refer back to the mini-language Core handout to see examples of BNF description of Mini-Language Core and syntax diagrams for Mini-Language Core.

      All sites I have found have described the language in words with examples of code.  The following is a list of URLs I have used so far.

 

    http://publish.edu.uwo.ca/rick.kitto/resource_files/Other/Turing1.pdf

    http://www.turingtutor.cjb.net/

    http://www.holtsoft.com/turing/

    http://www.doc.ic.ac.uk/lab/firstyear/turing_lecture_notes/turing_notes.html

    http://www.student.cs.uwaterloo.ca/~cs100/Resources/Turing/1-Basic_Building_Blocks.html#variables

 

With regard to variable names (not values)

2.        What characters are allowed (i.e. letters, underscores, numbers, etc.)

 Variable names in OOT must start with a letter and can contain letters, numbers, and the underscore character.  Spaces are not allowed.

 

Information found at http://www.student.cs.uwaterloo.ca/~cs100/Resources/Turing/1-Basic_Building_Blocks.html#variables

 

With regard to variable names (not values)

3.        What is the maximum length allowed and how many characters are significant?  (not a bad idea to indicate compiler)

 According to the website http://www.student.cs.uwaterloo.ca/~cs100/Resources/Turing/1-Basic_Building_Blocks.html#variables

the there is no maximum length for a variable name.  I am unable to test this or the above question though since the compiler for OOT can only be bought from

The Holts Software website for $75.  I am still searching for a free download.

 

4.        What is the assignment operator in your language?

 The assignment operator is the same as in Ada and Pascal; :=    

 

Information was given in the report.

 

    5.       Does your language have reserved words and/or  key words ?  If your language does something strange, include examples.

According to the report I was given there are 104 reserved words (cannot be used as variable names) in OOT. I have yet to find anything on keywords for OOT.

All the special words in OOT look to be reserved.

 

6.        Show a typical assignment statement

 Here is a typical assignment statement in OOT

 

     x := y

 

assigns y to x.

 

Examples of this were shown in the code in the report.

 

7.        What types of selection statements are available in your language?  (compared to any of the languages we have already looked at which have had various flavors of ifs and case statements ) FORTRAN had the arithmetic IF and the computed GOTO.  Your language may have something different.

 In OOT there are two types of selection statements, if then else and case statements.  If then else statements can have two forms:

 

    if <condition> then    OR    if <condition> then

      …<statements                 …<statements>

    else                            else if <condition2> then

      …<statements>                …<statements>

    end if                         else if <condition3> then

                                    

                                    end if

 

The other selection statement, case, has the following form:

 

   case <variable_name> of

     label <value> {, value}:

       …<statements>

     label <value> {, value}:

       …<statements>

     .

     .

     end case

 

 This information was in the report

 

8.        What types of iterative statements are available in your language?  (compared to any of the languages we have already looked at which have had various flavors of loops such as endless loops, counted loops, while loops, repeat loops).

There are three types of iterative statements in OOT.  These are a counting loop, conditional loop, and infinite loop. 

The counting loop is similar to that of Ada and Pascal, and equivalent to that of the Fortran DO loop. As in Ada two dots are used for the range.

There are two ways to use a counting loop, in increasing order or decreasing order, the latter by using the word decreasing before the LCV.

Here is an example of each:

 

for increasing order:           for decreasing order:

 

      for count : 1..10           for decreasing count : 10..1

 

       ….<statements>                …<statements>

 

      end for                                  end for

 

The conditional loop begins with the special word ‘loop’ and ends with ‘end loop’.  Within the body of statements are the words ‘exit when’ followed by a conditional statement, which ends execution of the loop.

 

      loop

 

        ….<statements>

        exit when num < 0

 

      end loop

 

The infinite loop is the same as above except there is no conditional statement within the loop body.

 

Information found in the report and at the website: http://www.turingtutor.cjb.net/

 

9.        Show a typical input statement in your language. (i.e. FORTRAN uses:  read(5,20) X;  Pascal uses: readln (X);  Ada uses: get(X); )

 In OOT the ‘get’ statement is used to get input from the keyboard.  There are three types of get statements: Token-oriented, Character-oriented, and line oriented.  The default is token-oriented:

 

              get <variable_name>

 

Character-oriented reads in the specified number of characters using a format identifier:

 

              get <var_name> : 5         reads in five characters

 

Line-oriented reads an entire line and is indicated by a * as the format identifier:

 

             get <var_name> : *

 

 Information was found in the report and also at http://publish.edu.uwo.ca/rick.kitto/resource_files/Other/Turing1.pdf

 

10.     Show a typical output statement in your language.

The ‘put’ statement is used to output in OOT.  The ‘put’ statement starts a new line after the output item.

An example of an output statement is as follows: 

 

             put <var_name>

 

This will print Hello to the screen.  Two dots following the ‘put’ statement causes the next put statement to output on the same line

 

             put.. “Hello”

 

Information was found in the report and also at http://publish.edu.uwo.ca/rick.kitto/resource_files/Other/Turing1.pdf