GE 6261 Computer Aided Drafting and Modelling Lab Viva questionsFull description
Basic Viva Questions in NED University
Machine Tools Viva QuestionsFull description
Full description
Full description
Network Programming Lab Viva Questions
Full description
5th semester VTU system software viva questions
Heat Transfer Viva QuestionsFull description
Full description
Full description
Important viva questions for OOAD lab
very useful for viva in machine shop labFull description
Full description
Concrete Lab
Required for 1st year studentsFull description
Translator A program that accepts text expressed expressed in one language and generates semantically equivalent equivalent text expressed expressed in another language. source language The input language of a translator. target language The output language of a translator. assembler A translator translator from an assembly assembly language to the the corresponding machine machine language. compiler A translator translator from a high level language to a low level language. high-level translator A translator translator from one high-level high-level language to another. another. disassembler A translator translator from machine machine language to assembler assembler language. decompiler A translater translater from a low level level language to a high level language. source program The input text of an assembler or compiler. object program The output text of an assembler or compiler. implementation language The language in which a program is expressed. tombstone diagram A graphical graphical representation of the overall function function of a system. system. cross compiler A compiler compiler which generates code for a machine different from the machine on which which it is run. Portable program A program which can be (compiled (compiled and) run on any machine. machine. interpretive compiler A program which combines a compiler that produces produces object code in an intermediate language language with an interpreter for that intermediate language. What is a compiler A compiler compiler is a computer computer program (or set of of programs) that transforms transforms source code code written in a programming programming language (the source language) into another computer language (the target language often having a binary form !nown as object code). Difference between compilers & interpreters. A compiler compiler first ta!es ta!es in the entire program chec!s for errors compiles it and then executes executes it. "hereas "hereas an interpreter does this line by line so it ta!es one line chec!s it for errors and then executes it. #g of $ompiler - $ #g of %nterpreter & '' Language processor. a parser which parses a particular language are called language processors Smbol table. a symbol table is a data structure used by a language translator such as a compiler or interpreter where each identifier in a programs source code is associated with information relating to its declaration or appearance in the source such as its typescope level and sometimes its location.
!"plain Different Phases #f $ %ompiler With $n !"ample *exical analysis This is the initial part of reading and analysing the program text+ The text is read and divided into to!ens each of which corresponds toa symbol in the programming language e.g. a variable name !eyword or number. ,. yntax analysis This phase ta!es the list of to!ens produced by the lexical analysis and arranges these in a tree-structure (called the syntax tree ) that reects the structure of the program. This phase is often called parsing /. emantic analysis - chec!s for errors. 0. %ntermediate $ode generation - generates machine code. 1. $ode optimi2ation (3achine independent)- loo!s for ways to ma!e code smaller and more efficient. 4. $ode 5enerator 6. Target program (machine dependent)- creates the output ( .exe .com .dll etc.). isc 7asically 8%$ $'9s ( eg+ A83 processer...) contain an instruction set where every instruction and operand is of the exact same length. This ma!es the $'9 design much simpler since every instruction an operand fits in the pipeline with no wasted cycles %'S% $%$ $'9s (x:4 :;1< etc...) contain complex variable length instruction sets and operands. " hile having complex variable length instructions ma!e low level programming much easier it comes at the price of greatly increasing the complexity of the $'9 and reducing efficiency. $pplication of compiler technolog. pattern recognition systems. diagram recognition and diagram-processing tas!s by use of grammars Le"ical $nal(er lexical analysis is the process of converting a sequence of characters into a sequence of to!ens. A program or function which performs lexical analysis is called a lexical analy2er lexer or scanner. To)ens* Patterns* Le"emes A lexical to!en is a sequence of characters that can be treated as a unit in the grammar of the programming languages. #xample of to!ens+ = Type to!en (id num real . . . ) Patterns There is a set of strings in the input for which the same to!en is produced as output. This set of strings is described by a rule called a pattern associated with the to!en. 8egular expressions are an important notation for specifying patterns. >or example the pattern for the 'ascal identifier to!en id is+ id ? letter (letter @ digit). Le"eme A lexeme is a sequence of characters in the source program that is matched by the pattern for a to!en. >or example ( B C DB) egular !"pressions <. The regular expressions over alphabet specifies a language according to the following rules. is a regular expression that denotes E F that is the set containing the empty string. egular Definitions A regular definition gives names to certain regular expressions and uses those names in other regular expressions. Deterministic +inite $utomata ,D+$ A deterministic finite automation is a special case of a non-deterministic finite automation (G>A) in which
<. no state has an -transition ,. for each state s and input symbol a there is at most one edge labeled a leaving s. ondeterministic +inite $utomata ,+$ A nondeterministic finite automation is a mathematical model consists of <. a set of states H ,. a set of input symbol I called the input symbols alphabet. /. a transition function move that maps state-symbol pairs to sets of states. 0. a state so called the initial or the start state. 1. a set of states > called the accepting or final state. Snthesi(ed $ttributes/ An attribute is synthesi2ed if its value at a parent node can be determined from attributes of its children. Snta"-Directed Definitions/ = A syntax-directed definition uses a $>5 to specify the syntatic structure of the input. = A syntax-directed definition associates a set of attributes with each grammar symbol. = A syntax-directed definition associates a set of semantic rules with each production rule. Parsing 'arsing is the process of determining if a string of to!ens can be generated by a grammar. A parser must be capable of constructing the tree or else the translation cannot be guaranteed correct. >or any language that can be described by $>5 the parsing requires J(n/) time to parse string of n to!en. owever most programming languages are so simple that a parser requires just J(n) time with a single left-to-right scan over the iput string of n to!ens. There are two types of 'arsing <. Top-down 'arsing (start from start symbol and derive string) A Top-down parser builds a parse tree by starting at the root and wor!ing down towards the leaves. o #asy to generate by hand. o #xamples are + 8ecursive-descent 'redictive. ,. 7ottom-up 'arsing (start from string and reduce to start symbol) A bottom-up parser builds a parser tree by starting at the leaves and wor!ing up towards the root. o Got easy to handle by hands usually compiler-generating software generate bottom up parser o 7ut handles larger class of grammar o #xample is *8 parser. Pridictive Parsing/ 8ecursive-descent parsing is a top-down method of syntax analysis that executes a set of recursive procedure to process the input. A procedure is associated with each nonterminal of a grammar. A predictive parsing is a special form of recursive-descent parsing in which the current input to!en unambiguously determines the production to be applied at each step. Left ecursion/ The production is left-recursive if the leftmost symbol on the right side is the same as the non terminal on the left side. >or example expr ? expr K term. 'ssues in the Design of %ode generator $ode generator concern with+ <. 3emory management. ,. %nstruction election. /. 8egister 9tili2ation (Allocation). 0. #valuation order. What is le"
*ex is a computer program that generates lexical analy2ers (LscannersL or LlexersL). *ex is commonly used with the yacc parser generator. *ex reads an input stream specifying the lexical analy2er and outputs source code implementing the lexer in the $ programming language. Le"ical error/ A lexical error is any input that can be rejected by the lexer. This generally results from to!en recognition falling off the end of the rules youve defined. Tpes of parsers Top-down parsers M start at the root of derivation tree and Mll in M pic!s a production and tries to match the input M may require bac!trac!ing M some grammars are bac!trac!-free (predictive) #g+ recursive descent ** Bottom-up parsers M start at the leaves and Mll in M start in a state valid for legal Mrst to!ens M as input is consumed change state to encode possibilities (recogni2e valid preMxes) M use a stac! to store both state and sentential forms
#g+ *8 $NO (loo! ahead) parser slr lalr What does LL and L mean **(<) means & first P*Q represents scanning input from left to right. econd P*Q represents producing leftmost derivation. (<) one input symbol of loo!ahead at each step. *8(!) means & P*Q *eft to right scanning 8-rightmost derivation in reverse. O-; or < no. of iRp symbols. *oaders+ A loader is a system program which ta!es the object code of a program as input and prepares it for execution. = The loader performs the following functions + = Allocation - The loader determines and allocates the required memory space for the program to execute properly. = *in!ing -- The loader analyses and resolve the symbolic references made in the object modules. = 8elocation - The loader maps and relocates the address references to correspond to the newly allocated memory space during execution. = *oading - The loader actually loads the machine code corresponding to the object modules into the allocated memory space and ma!es the program ready to execute. %ompile-and-0o Loaders/ = A compile and go loader is one in which the assembler itself does the processes of compiling then place the assembled instruction inthe designated memory loactions. $bsolute Loader The assembler generates the object code equivalent of the source program bu the output is punched on
to the cads forming the object dec!s instead of loading in memory. elocation loader *oaders that allow for program relocation are called relocating loadersRrelative loaders. Lin)age !ditors A lin!age editor produces a lin!ed version for the program called an executable image which is written to a file for later execution. Dnamic Lin)ing Synamic lin!ing allows an object module to include only the information that is require at load time to execute a program. There are two types of dynamic lin!ing they are *oad time dynamic lin!ing and 8un time dynamic lin!ing. %ode 0eneration code generation is the process by which a compilers code generator converts some internal representation of source code into a form (e.g. machine code) that can be readily executed by a machine code optimi(ation $ode optimi2ation is the process of modifying the code to ma!e some aspect of software or hardware wor! more efficiently or use fewer resources or reduce compilation time or use memory efficiently etc $>5 is a grammar which naturally generates a formal language in which clauses can be nested inside clauses arbitrarily deeply but where grammatical structures are not allowed to overlap