Programmin Languages

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

__________________ is a graph representation of a derivation a) the parse tree b) oct tree c) binary tree d) none of the mentioned above

a) the parse tree

Consider the following grammar <S> -> a <S> c <B> | <A> | b <A> -> c <A> | c <B> -> d | <A> Which of the following sentences are in the language generated nu this grammar? a. abcd b. acccbd c. acccbcc d. acd e. accc

answer: a & e

whats the order from top to bottom a) Hardware -> Assembly language -> Machine language -> High Level language -> Fortran , C, Pascal b) Hardware -> machine language -> assembly language -> high level language -> Fortran, C, Pascal c) Machine language -> hardware -> high level language -> assembly language -> Fortran , C, Pascal

b) hardware -> machine language -> assembly language -> high level language -> Fortran , C, Pascal

which of the following is a phase of a compilation process ? a) lexical analysis b) code generation c) both of the mentioned d) none of the mentioned

c) both of the mentioned

symbol table

(--character stream-->)Scanner(lex analysis ) -> (--token stream-->) Parser (syntax analysis) -> (-- parse tree-->) semantic analysis & intermediate code generation -> (--abstract syntax tree or other intermediate form -->) machine-independent code improvement (op) -> (-- modified intermediate form -->) target code generation -> (--target language-->) machine specific code improvement (op) (-- modified target language--)

different languages ( classification by features)

- sequential - concurrent - modular - parallel - distributed - object oriented

formal methods of describing syntax

-context free grammars - origins of backus - Naur form(BNF grammar) - describing lists - grammars and derivation - parse tree

semantic analysis

-the discovery of meaning in a program - typically builds and maintains a symbol table data structure that maps each identifier to the information known about it. + static semantics + dynamic semantics

cache memory acts between a) CPU and RAM b) RAM and ROM c) CPU and Hard Disk d) none of the mentioned

CPU and Ram

suppose one of the operand is String and other is Integer then it does not throw error as it only checks whether there are two operands associated with '+' or not ( syntax analyzer) - true - false

True, syntax analyzer does not check the type of operand

Interpreter

Input - take single line of code, or instruction as its input Output - doesn't generate any intermediate object code Speed - executes slower Memory - less memory ( doesn't create object code Workload - has to convert high level languages to low level program at execution Errors - displays error when each instruction is run

Compiler

Input - takes entire prog. as its input Output - generates intermediate object code Speed - executes faster Memory - req. more memory in order to create obj code Workload - doesn't need to compile every single time just once Errors - displays errors once the entire program is checked

Interpreter function

Source program & input -> Interpreter -> Output

Compiler function

Source program -> Compiler ->(input ->) Target program -> output

Translator function

Source program -> translator -> Intermediate program & input -> virtual machine -> output

In short syntax analysis generates parse tree -True -False

True

Parsers are expected to parse the whole code - True - False

True

The computer language generally translated to pseudocode is a) assembly language b) machine c) pascal d) FORTRAN

a) assembly language

The context free grammar S-> SS | 0S1 | 1S0 | & generates a) equal number of 0's and 1's b) unequal number of 0's and 1's c) number of 0's followed by any number of 1's d) none of the mentioned

a) equal amount of 0's and 1's explanation: S -> 0S1S S -> 0S11S0 S -> 0110

Input to Lexical Analyzer is a) source code b) object code c) lexeme d) none of the mentioned

a) source code

A compiler program written in a higer level language is called a) source program b) object program c) machine language program d) none of the mentioned

a) source program

parse tree

concrete syntax tree + in the process of checking static semantic rules, the semantic analyzer typically transforms the parse tree into an abstract syntax by removing most of artificials nodes + the annotated syntax tree constitutes the intermediate form that is passed from front end to the back end

N= {S}, T = {a,b}, Starting symbol = S, P = S -> SS | aSb | & select the string: a) aabbba b) abbba c) aaab d) abaabb

d) abbaabb S -> SS -> aSbS -> abS -> abaSb -> abaabb

select a machine independent phase of the compiler a) syntax analysis b) intermediate code generation c) lexical analysis d) all of the mentioned

d) all of the mentioned

scope rules of a language

determine how reference to names are associated

declarative

no steps / no instruction functional -> lisp /scheme ML, Haskell dataflow -> Id, Val logic, constrained based -> prolog, spreadsheet , SQL

code improvement

referred to as optimization

imperative

steps/ instructions/ rules von Neuman -> C, Ada, Fortran object-oriented -> smalltalk, Eiffel, Java scripting -> pearl, python, php

target code generation

translates the intermediate form into the target language

The context free grammar is ambiguous if a) the grammar contains non-terminals b) produces more than one parse tree c) production has two non terminal side by side d) none of the mentioned above

b) the grammar produces more than one parse tree

which of these is not true about symbol table? a) all the labels of the instructions are symbols b) table has entry for symbol name address value c) perform the processing of the assembler directives d) created during pass1

c) performs the processing of the assembler

The output of lexical analyzer is a) A set of RE b) Syntax Tree c) Set of tokens d) String Character

c) set of tokens

A grammar for a programming language is a formal description of a) syntax b) semantics c) structure d) library

c) structure

type checking is normally done during a)lexical analysis b) syntax analysis c) syntax directed translation d) code generation

c) syntax directed translation (since it is its function)

Which of the following statement is false a) in derivation tree, the label of each leaf node is terminal b) in derivation tree, the label of all nodes except lead nodes is a variable c) in derivation tree, if the root of a sub tree is X then it is called - tree d) node of the mentioned

d) none of the mentioned

syntax

formal rules governing the construction of valid statements in a language

semantics

set of rules which give the meaning of a statement


Kaugnay na mga set ng pag-aaral

Vocabulary Workshop Level H Unit 4 Completing the Sentence

View Set

Chapter 25/26 Quiz study information

View Set

Intrapartum CH 8-11 Durham EXAM 2

View Set

IB Chemistry Topic 7 SL Equilibrium

View Set

Geography - Continents, Oceans, Imaginary Lines

View Set

Chapter 10 - Emotional Development and Attachment

View Set