Вы находитесь на странице: 1из 3

ADVANCED PROGRAMMING LANGUAGE Name: Schedule: Rating:

Prelim Exam

I. SIMPLE RECALL Directions: Identify the following concepts describe below then write your answer in the blanks space provided before each number. ___________ 1. A complex translator program that is initially involved with breaking down the source program into its components. ___________ 2. A translator program in which the execution of each statement in a program is done one at a time. ___________ 3. A phase of compilation process that scans and groups the characters of the source program statements into tokens such as identifier, operator, constant etc. ___________ 4. A phase of compilation process that produces an explicit intermediate representation of the source program which can be thought of as a program for an abstract machine. ___________ 5. The final phase of the compilation process which consists normally of relocatable machine code or assembly code. ___________ 6. A phase that deals with errors that are encountered so that compilation can proceed, allowing further errors in the source program to be detected. ___________ 7. A phase of compilation process which involves grouping of the tokens of the source program into grammatical phrases that are used by the compiler to synthesize output. ___________ 8. A phase of compilation process that checks the source program for semantic errors and gathers type of information for the subsequent code-generation phase. ___________ 9. A data structure containing a record for each identifier with fields for the attributes of the identifier. ___________10. A mechanism for interpreting high level programs that have been expressed in the stylized formal notation of the programming language. II. COMPLETION Directions: Supply the missing parts of the compilation and interpretation processes below. COMPILATION PROCESS
SOURCE PROGRAM

INTERPRETATION PROCESS
SOURCE PROGRAM

Input Data

(1)

(9)

(6)

(2)

(7)

(10)

(3)

(4)

(8)

Computer

(5)

III. EXPRESSION NOTATIONS Directions: Convert the following into prefix and postfix notation. Prefix Notation 1. ((A+B)*C D) + F / G 2. (A + B/C)*(D-E)/F + G Postfix Notation

___________________________ ___________________________ ___________________________ ___________________________

Programming Language - pg.1

ADVANCED PROGRAMMING LANGUAGE

Prelim Exam

IV. SYNTACTIC ANALYZER A. Directions: Given the grammar for simple assignment statements, make the leftmost derivation of the input string then draw its parse tree. Grammar: <assign> <expr> <term> <factor> <id> <num>

::= id := <expr> ::= <expr> + <term> | <expr> - <term> | <term> ::= <term> * <factor> | <term> / <factor> | <factor ::= id | num | ( <expr> ) ::= A|B|C|D|E := 0|1|2|3||9

Input Expression: A = B+C*(D - E) Leftmost Derivation: Rightmost Derivation:

V. SIMPLE RECALL Directions: Given the grammars below, identify the terminal symbol, non-terminal symbol and the start symbol Example: <S>:: = a<S>| <T> <T>:: = ab | a : <S>,<T> : a, ab : <S>

Non-terminal Symbol Terminal Symbol Start Symbol

1. <start> ::= if ( <expr> ) <stmt> else <stmt> if ( <expr> ) <stmt> Non-terminal Symbol : _____________________ Terminal Symbol : _____________________ Start Symbol : _____________________ 2. <loop-statement> ::= do <statement> while (<expression>) Non-terminal Symbol : _____________________ Terminal Symbol : _____________________ Start Symbol : _____________________ 3. <assign> ::= id := <expr> <expr> ::= <expr> + <term> | <expr> - <term> | <term> <term> ::= <term> * <factor> | <term> / <factor> | <factor <factor> ::= id | num | ( <expr> ) <id> ::= A|B|C|D|E <num> ::= 1|2|3| : _____________________ : _____________________ : _____________________

Non-terminal Symbol Terminal Symbol Start Symbol

Programming Language - pg.2

ADVANCED PROGRAMMING LANGUAGE

Prelim Exam

VI. Create your own grammar and its equivalent derivation using (left derivation, right derivation and parse tree) based on the given expression below: 1. A = (B + C) * (A C) 2. 154.595 3. Program = begin A = B + C * 1; B = C end

Programming Language - pg.3

Вам также может понравиться