










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Theory Of Programming Languages Exam Containing 130+ Questions with Certified Solutions/ 2024-2025. Terms like: Type of systems programming - Answer: C Type of Web software - Answer: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) Language Categories - Answer: Imperative Functional Logic Markup/programming Hybrid Imperative Language - Answer: •Central features are variables, assignment statements, and iteration •Include languages that support object-oriented programming •Include scripting languages •Include the visual languages Examples of Imperative languages - Answer: C, Java, Perl, JavaScript, Visual BASIC .NET, C++
Typology: Exams
1 / 18
This page cannot be seen from the preview
Don't miss anything!











Type of systems programming - Answer: C Type of Web software - Answer: markup (e.g., HTML), scripting (e.g., PHP), general-purpose (e.g., Java) Language Categories - Answer: Imperative Functional Logic Markup/programming Hybrid Imperative Language - Answer: •Central features are variables, assignment statements, and iteration
•Include languages that support object-oriented programming •Include scripting languages •Include the visual languages Examples of Imperative languages - Answer: C, Java, Perl, JavaScript, Visual BASIC .NET, C++ functional language - Answer: •Main means of making computations is by applying functions to given parameters Examples of functional languages - Answer: •LISP, Scheme, ML, F# Scientific applications - Answer: Large numbers of floating point computations; use of arrays Business applications - Answer: Produce reports, use decimal numbers and characters Logic language - Answer: Rule-based (rules are specified in no particular order) Example of logic language - Answer: prolog Markup/programming hybrid language - Answer: •Markup languages extended to support some programming
Pure Interpretation - Answer: Programs are interpreted by another program known as an interpreter No Translation Slower execution Hybrid Implementation Systems - Answer: A compromise between compilers and pure interpreters Faster than pure interpretation Compilation use - Answer: Large commercial applications Pure Interpretation use - Answer: Small programs or when efficiency is not an issue Hybrid implementation systems - Answer: Small and medium systems when efficiency is not the first concern Sentence - Answer: a string of characters over some alphabet language - Answer: a set of sentences lexeme - Answer: lowest level syntactic unit token - Answer: category of lexemes
recognizers - Answer: reads input strings over the alphabet of the language and decides whether the input strings belong to the language generators - Answer: generates sentences of a language BNF - Answer: Backus-Naur Form BNF is equivalent to context-free grammars abstractions are used to represent classes of syntactic structures •Terminals are lexemes or tokens Left hand side of BNF rule - Answer: a nonterminal Right hand side of BNF rule - Answer: a string of terminals and/or nonterminals grammar - Answer: finite non empty set of rules terminals - Answer: lexemes or tokens elementary symbols of the language defined by a formal grammar nonterminals - Answer: replaced by groups of terminal symbols according to the production rules unambiguous expression grammar - Answer: generates a sentential form that has only one distinct parse tree
high level part, Syntax analyzer Lexical analyzer - Answer: a finite automaton based on a regular grammar Syntax analyzer - Answer: a push-down automaton based on a context-free grammar, or BNF Categories of parsers - Answer: Top down Bottom up Top down parser - Answer: produce the parse tree, beginning at the root Order is that of a leftmost derivation Traces or builds the parse tree in preorder Bottom up parser - Answer: produce the parse tree, beginning at the leaves Order is that of the reverse of a rightmost derivation If a grammar has left recursion, either direct or indirect, it cannot be the basis for a top-down parser - Answer: True The other characteristic of grammars that disallows top-down parsing is the lack of - Answer: pairwise disjointness Variable - Answer: abstraction of a memory cell
Variable attributes - Answer: Name, Address, Value, Type, Lifetime, Scope Binding - Answer: an association between an entity and an attribute, such as between a variable and its type or value, or between an operation and a symbol Binding time - Answer: the time at which a binding takes place Static binding - Answer: when binding first occurs before run time and remains unchanged throughout program execution Dynamic binding - Answer: when binding first occurs during execution or can change during execution of the program Allocation - Answer: getting a cell from some pool of available cells Deallocation - Answer: Putting a cell back into the pool Lifetime - Answer: time it is bound to memory cell Scope - Answer: range of statements over which it is visible Scope rules - Answer: determine how references to names are associated with variables Reliability Criteria - Answer: Type checking
PASCAL - Answer: Designed for teaching structured programing C - Answer: Designed for systems programing Powerful set of operators Poor type checking Syntax - Answer: form or structure of the expressions, statements and program units Senabtucs - Answer: the meaning of the expressions, statements and program units Sentential form - Answer: every string of symbols in a derivation Leftmost derivation - Answer: the leftmost nonterminal in each sentential form is the one that is expanded If parse trees are used to indicated precedence levels we cannot have - Answer: ambiguity Axiomatic Semantics - Answer: based on formal logic, purpose is formal program verification Assertions - Answer: logic expressions
Precondition - Answer: an assertion before a statement states the relationships and constraints among variables that are true at that point in execution Postcondition - Answer: an assertion following a statement Weakest precondition - Answer: least restrictive precondition that will guarantee the Postcondition The postcondition for the entire program is - Answer: the desired result Loop invariant - Answer: a weakened version of the loop postcondition and it is also a precondition in operational semantics the state changes are defined by - Answer: coded algorithms in denotational semantics the state changes are defined by - Answer: rigorous mathematical functions BNF advantages - Answer: provides clear and concise syntax parser can be based directly on BNF Simplicity - Answer: less complex approaches can be used for lexical analysis
Most common top down parsing algorithms - Answer: - Recursive descent - a coded implementation
Action table - Answer: specifies the action of the parser, given the parser state and the next token GOTO table - Answer: specifies which state to put on top of the parse stack after a reduction action is done Languages that allow variable declarations to appear anywhere a statement can appear - Answer: C99, C++, Java, and C# Languages where variables can be declared in for statements - Answer: C++, Java, and C# These languages allow variable declarations to appear outside function definitions or in file - Answer: C, C++, PHP, and Python Problems with static scoping - Answer: too much access is possible initial structure is destroyed and local variables often become global Dynamic scope - Answer: based on calling sequences of program units, not their textual layout Advantage of dynamic scoping - Answer: convenience Disadvantages of dynamic scoping - Answer: 1.While a subprogram is executing, its variables are visible to all subprograms it calls
abstract memory cell - Answer: the physical cell or collection of cells associated with a variable language design time - Answer: Bind operator symbols to operations language implementation time - Answer: bind floating point type to a representation compile time - Answer: bind a variable to a type in C or Java load time - Answer: bind a C or C++ static variable to a memory cell runtime - Answer: bind a nonstatic local variable to a memory cell explicit declaration - Answer: a program statement used for declaring the types of variables implicit declaration - Answer: a default mechanism for specifying types of variables through default conventions, rather than declaration statements type inferencing - Answer: determine types of variables dynamic type binding - Answer: specified through an assignment statement lifetime - Answer: the time during which it is bound to a particular memory cell
static - Answer: bound to memory cells before execution begins and remains bound to the same memory cell throughout execution Stack-dynamic - Answer: storage bindings are created for variables when their declaration statements are elaborated Explicit heap-dynamic - Answer: Allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution Implicit heap-dynamic - Answer: allocation and deallocation caused by assignment statements disadvantages of stack dynamic variables - Answer: overhead of allocation and deallocation subprograms cannot be history sensitive inefficient references advantages of explicit heap-dynamic variables - Answer: provides for dynamic storage management disadvantages of explicit heap-dynamic variables - Answer: inefficient and unreliable