











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Artificial intelligence - Answer: symbols rather than numbers manipulated, use of linked lists Systems Prgramming - Answer: Need efficiency because of continuous use Web Software - Answer: Eclectic collection of languages: markup, scripting, general purpose Type of Scientific application - Answer: Fortran Type of business application - Answer: COBOL
Type of artificial intelligence - Answer: LISP 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#
Readability vs. writability - Answer: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readability Writability (flexibility) vs. reliability - Answer: C++ pointers are powerful and very flexible but are unreliable Implementation Methods - Answer: compilation pure interpretation hybrid implementation systems Compilation - Answer: Programs are translated into machine language; includes JIT systems 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
If attributes inherited - Answer: tree could be decorated in top-down order If attributes were synthesized - Answer: tree could be decorated in bottom up order Operational Semantics - Answer: Describe the meaning of a program by executing its statements on a machine, either simulated or actual Denotational Semantics - Answer: Based on recursive function theory Axiomatic semantics - Answer: Based on predicate logic Preconditions, post-conditions, weakest preconditions Syntax Analysis parts - Answer: low level part, Lexical analyzer 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
--Syntax analysis --Semantics analysis --Code generation Preprocessor macros - Answer: commonly used to specify that code from another file is to be included Problems with machine code - Answer: Poor readability Poor modifiability Expression coding was tedious Machine deficiencies with indexing or floating point Data types of LISP - Answer: atoms and lists First Design Meeting - Answer: Pentagon May 1959 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
Three approaches to building a lexical analyzer - Answer: -Write a formal description of the tokens and use a software tool that constructs a table-driven lexical analyzer from such a description -Design a state diagram that describes the tokens and write a program that implements the state diagram -Design a state diagram that describes the tokens and hand-construct a table- driven implementation of the state diagram a naive state diagram - Answer: a transition from every state on every character in the source language Goals of parser - Answer: find all syntax errors Produce the parse tree Most common top down parsing algorithms - Answer: - Recursive descent - a coded implementation
Recursive Decent Parsing checks for errors - Answer: FALSE Left Recursion Problem - Answer: If a grammar has left recursion, either direct or indirect, it cannot be the basis for a top-down parser Pairsing prblem - Answer: finding the correct RHS in a right sentential form to reduce and get to the previous right sentential form in the derivation Advantages of LR parsers - Answer: work for nearly all grammars work on a larger class of grammars detect syntax errors asap LR parsers are table driven - Answer: TRUE Action table and a GoTo Table 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#
keyword - Answer: special only in certain contexts reserved workd - Answer: special work that cannot be used as a user defined name address - Answer: the memory address with which it is associated aliases - Answer: two variable names that point to the same data type - Answer: range of values of variables and the set of operations that are defined for values of that type value - Answer: the contents of the location with which the variable is associated 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
loss of error detection search process - Answer: search declarations, first locally, then in increasingly larger enclosing scopes, until one is found for the given name Let construct - Answer: first part binds names to values second part uses the names defined in the first part