Languages and Translation cs 362 Exam 1 Fall 2003 9/25/03 (100 points) Name



Download 21.33 Kb.
Date09.01.2017
Size21.33 Kb.
#8313


Languages and Translation

CS 362 Exam 1

Fall 2003 9/25/03 (100 points)

Name _________________________________


  1. Define what a programming language is.

[4 pts]


  1. Which of the following are NOT part of the minimum requirements for a language to be Turing complete:

[3 pts]

_____ Sequential execution

_____ Floating point variables and arithmetic

_____ Parallel execution

_____ Selection

_____ Looping

_____ Object orientation

_____ Integer variables and arithmetic

_____ Assignment






  1. For each of the run time environments (static, stack or dynamic) describe some component of a language that requires the run time environment. Also mention the language you are referring to.

[6 pts]

Environment

Component/language


Static allocation





Stack allocation





Dynamic allocation






  1. Identify and describe at least 3 bindings in the following C/C++ declaration/initialization statement.

    char * x = malloc(n*2); //malloc is a built in function in C

[10 pts]

Token

Attribute

Binding time































  1. List all the tokens in the C declaration/initialization from the question above.

[5 pts]


  1. Why is this grammar for simple expressions considered ambiguous? Be sure to explain how a parse tree is used in defining ambiguity, or show an example.
    E → E + E | E * E | ( E ) | |

[5 pts]


  1. Language design criteria.

[10 pts]

Explain how the “readability” and “writability” criteria may be in conflict.


How does Java support the “portability” criterion?
Assume a language contains a set of simple data types and the standard 6 relational operators and we said the language was highly “orthogonal”, what do we mean?


  1. Put these modules of a compiler in order of theoretical data flow:

[5 pts]

___ Lexical analysis (scanner)

___ Optimization

___ Code generation

___ Syntactic analysis (parser)

___ Intermediate code generation

___ Semantic analysis


  1. Assume language L contains and infinite number of elements and the patterns of those elements are,
    { ab, ac, aab, aac, aaab, aaac, aaaab, aaaac,……, abc, abd, acc, acd, abcc, abcd, abdc, abdd. accc, accd,…},
    That is, a string of a’s, followed by a ‘b’ or ‘c’, followed by a string of c’s and d’s in any order.

[15 pts]

a) Give a regular expression to define this language:


b) Draw a FSM from this regular expression


c) Write a corresponding BNF grammar limited to the form AxB | y

FSM

BNF









  1. Give an example programming language that represents the language paradigm and a short reason why you chose the language to represent it.

[8 pts]

Procedural programming



Object Oriented programming



Functional programming



Logic programming





  1. Assume the set of productions representing simple algebraic expressions.

[20 pts]

S ® V := E

E ® E + T | T

T ® T * F | F

F ® V | ( E )
V ® i | j | k


  1. The alphabet or set of terminals is ____________________________________ [3]

  2. The set of nonterminals is ___________________________________ [3]

  3. The start symbol is ____________ [2]

  4. Show a top down derivation for j := i + k * j starting with the start symbol. [5]

  5. Draw the corresponding parse tree. [5]

Derivation

Parse tree






f) Was your derivation leftmost? ______ (it wasn’t required to be) [2]




  1. What is a coercion? What happens in C when assigning reals to integers?

[4 pts]


  1. Describe how a Java program is executed in terms of the various layers of software and hardware necessary to accomplish it. Consider the JVM, what it’s written in, operating system support and the hardware instruction set.

[8 pts]


Directory: faculty -> rhodes
faculty -> Course overview
faculty -> Curriculum vitae wei chen professor
faculty -> Digital image warping
faculty -> Samples of Elements Exam Question III contains All Prior Exam Qs III except
faculty -> 【Education&Working Experience】
faculty -> References Abe, M., A. Kitoh and T. Yasunari, 2003: An evolution of the Asian summer monsoon associated with mountain uplift —Simulation with the mri atmosphere-ocean coupled gcm. J. Meteor. Soc. Japan, 81
faculty -> Ralph R. Ferraro Chief, Satellite Climate Studies Branch, noaa/nesdis
faculty -> Unit IV text: Types of Oil, Types of Prices Grammar: that/those of, with revision
rhodes -> Languages and Translation cs 362 Exam 1 Fall 2015 10/1/15 (100 points) Name
rhodes -> Languages and Translation cs 362 Exam 1 Fall 2015 10/1/15 (100 points) Name key

Download 21.33 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page