ICS410 — Ch1 & Ch3

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

...

...

7.What is the disadvantage of having to many features in a language?

If a language has to many features, some programmers wont be familiar with them all, leading to the misuse of some features and disuse of others.

7. What three extensions are common to most EBNFs?

The first extension denotes an optional part of a RHS, which is delimited by brackets. For example: <if_stmt> -> if ( <expr> ) stmt [ else <stmt> ] The second extension is the use of braces in an RHS to indicate that the enclosed part can be repeated indefinitely or left out altogether. For example: <ident_list> -> ident {, <ident> } The third extension deals with multiple choice options. For example: <term> -> <term> ( *|/|% ) <factor>

29.Why is the Von Neumann bottleneck important?

The speed of the connection between a computers memory and its processor usually determines the the speed of the computer, because instructions often can be executed faster than they can be moved to the processor for execution. This connection is called the von Neumann bottleneck; it is the primary limiting factor in the speed of von Neuman architecture computers, The von Neumann bottleneck has been one of the primary motivations for the research and development of parallel computers.

20. Which part of an inference rule is the antecedent?

The top part of an inference rule is called the antecedent.

2. Who are language descriptions for?

it is for other language designers, implementers, and programmers (users of the language).

1. Why is it useful for a programmer to have some background in language design, even though he or she may never actually design a programming language

- Increased capacity to express ideas - Improved background for choosing appropriate languages - Increased ability to learn new languages - Better understanding of the significance of an implementation.

22. Give an example of an ambiguous grammar.

<program> →<stmts> <stmts> → <stmt> | <stmt> ; <stmts> <stmt> → <var> = <expr> <var> → a | b | c | d <expr> → <term> + <term> | <term> - <term> <term> → <var> | const

26. Which produces faster program execution, a compiler or pure interpreter?

A compiler, as a compiler translates directly into machine code.

3. Describe the operation of a general language generator.

A general language generator is a device that can be used to generate the sentences of the language. It generates unpredictable sentences which makes a generator seems to be a device of limited usefulness as language descriptor. However, people prefer certain forms of generators over recognizer because they can be more easily read and understand them. By contrast, the syntax-checking portion of the compiler which is a language recognizer is not as useful a language descriptor for programmers because it can be used in a trial-and-error mode. For example, to determine the correct syntax of a particular statement using the compiler, the programmer can only submit a guessed-at version and see if the compiler accepts it. On the other hand, it is often possible to determine whether the syntax of a particular statement is correct by comparing it with the structure of the generator

4. Describe the operation of a general language recognizer.

A general language recognizer is a recognition device capable of reading strings of characters from the alphabet. It would analyze the given string and it would either accept or reject the string based from the language given. These recognition devices are like filters separating correct sentences from those that are incorrectly. A recognizer is used in the syntax analysis part of the compiler. In this role, the recognizer need not test all possible strings of characters from some set to determine whether each is in the language. The syntax analyzer just determines whether the given programs are syntactically correct.

18.How is the cost of compilers for a given language related to the design of that language.

A language that requires many run-time type checks will prohibit fast code execution, regardless of the quality of the compiler.

13.What does it mean for a program to be reliable?

A program is said to be reliable if it performs to its specifications under all conditions. Factors that affect reliability are type checking, exception handling, aliasing, readability and write-ability

5. What is the difference between a sentence and a sentential form?

A sentence is a sentential form that has only terminal symbols. A sentence form is every string of symbols in the derivation.

28. What is the use of the wp function? Why it is called a predicate transformer?

A weakest precondition is the least restrictive precondition that will guarantee the postcondition. It is often called a predicate transformer because it takes a predicate, or assertion as a parameter and returns another predicate.

10. What language used orthogonality as a primary design criterion?

ALGOL 68 - ALGOL 68 is the most orthogonal programming language because every language constructs in ALGOL 68 has a type, and there are no restrictions on those types. But LISP can also be said as a good combination of simplicity and orthogonality. LISP a functional language is one in which computations are made primarily by applying a function to a given program.

15. What is aliasing?

Aliasing is having two or more distinct names that can be used to access the same memory cell. It is now widely accepted that aliasing is a dangerous feature in a programming language. In some languages, aliasing is used to overcome deficiencies in the language's data abstraction facilities.

26. Explain what the preconditions and postconditions of a given statement mean in axiomatic semantics.

An assertion before a statement (a precondition) states the relationships and constraints among variables that are true at that point in execution. An assertion following a statement is a postcondition.

12. What is the primary use of attribute grammars?

An attribute grammar is a device used to describe more of the structure of a programming language than is possible with a context-free grammar. An attribute grammar is an extension to a context-free grammar. The primary purpose of an attribute grammar is it allows certain language rules to be described, such as type of compatibility. An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler.

Describe the approach of using axiomatic semantics to prove the correctness of a given program.

Axiomatic semantics are based on mathematical logic and the first step is to identify the preconditions and the postconditions for each statement and make sure such pre and post conditions are satisfied.Often times valid results or post-conditions will be specified but not preconditions. We can calculate the least restrictive of the preconditions, the weakest precondition, by substituting the postcondition into the last assignment statement.

4. What programming language has dominated business applications over the past 45 years?

COBOL - COBOL was the first successful high-level language for business. It is the most commonly used language for business applications because business languages are characterized by facilities for producing elaborate reports, precise ways of describing, strong decimal numbers, character data and the ability to specify decimal arithmetic operations.

9. What is one example of lack of orthogonality in the design of C?

Consider the following rules and exceptions in C. Although C has two kinds of structured data-types arrays and records (structs). records can be any data type except void or a structure of the same type. An array element can be any data type except a void or a function. Parameters are passed by value, unless they are arrays, in which they are , in effect, passed by reference.

18. Which semantics approach is most widely known?

Denotational semantics.

16.What is exception handling?

Exception handling is the ability of a program to intercept run-time errors (as well as the unusual conditions detectable by the program), take corrective measures, and then continue in an obvious aid to reliability.

3. What programming language has dominated scientific computing over the past 45 years?

FORTRAN - FORTRAN has been used for a long time for scientific computing. It was the first language for scientific applications because FORTRAN provides efficiency which was the primary concern for scientific applications.

14. Why can machine languages not be used to define statements in operational semantics?

First the individual steps in the execution of machine language and the resulting changes to the state of the machine are too small and too numerous. Second the storage of a real computer is too large and complex. There are usually several levels of memory devices, as well as connections to enumerable other computers and memory devices through networks.

8.How can user-defined operator overloading harm readability of a program?

If a programmer doesn't do it sensibly, it can reduce readability.

2. How can knowledge of programming language characteristics benefit the whole computing community?

If those who choose a language, are better informed, then perhaps better languages would eventually squeeze out poorer ones.

In what fundamental way do operational semantics and denotationalsemantics differ?

In operational semantics, programming language constructs are translated into simpler programming language constructs, which become the basis of the meaning of the construct. In denotational semantics, programming language constructs are mapped to mathematical objects, either sets or, more often, functions. However,unlike operational semantics, denotational semantics does not model the step-by-step computational processing of programs.

11. What primitive control statement is used to build more complicated control statements in languages that lack them?

It is "goto", but in the 1970s, the use of "goto" statements was replaced by structured programming, which could be read from top to bottom. (While, in newer languages)

5. What programming language has dominated artificial intelligence over the past 45 years?

LISP - LISP which appeared in 1959.Artificial Intelligence (AI) is a broad area of computer applications characterized by the used of symbolic rather than numeric computations.

19. What has been the strongest influence of programming language design over the past 50 years.

Most of the past 50 years have been designed around the prevalent computer architecture, called the von Neumann architecture, after one of its originators, John von Neumann.

28. What does a linker do?

Most user programs also require programs from the operating system. Among the most common of these are programs for input and output. The compiler builds calls to required system programs when they are needed by the user program. Before the machine language programs produced by a compiler can be executed. The required programs from the operating system must be found and linked to the user program. The process of collecting system programs and linking them to user programs is called linking and loading or just linking. in addition user programs may have to be linked to other user programs.

13. Explain the primary uses of a methodology and notation for describing the semantics of programming languages.

Programmers obviously need to know precisely what the statements of a language do before they can use them effectively in their programs Compiler writers must know exactly what language constructs mean to design implementations for them correctly Language designers who would develop the semantic descriptions of their languages could in then process discover ambiguities and inconsistencies in their design

12. What construct of a programming language provides process abstractions?

Programming languages usually contain abstractions for defining and manipulating data structures or controlling the flow of execution. The practical necessity that a programming language supports adequate abstractions is expressed by the abstraction principal. This principle is sometimes formulated as recommendation to the programmer to make proper use of such abstractions.

17. Why is reliability important to write-ability?

Readability is important to write-ability because if a programming language is difficult to read and understand then it can be difficult for a programmer to create new code that might need to interact or use other code. Often times code needs to be modified and if a program is difficult to read then it is difficult to add new code to it.

8. Distinguish between static and dynamic semantics.

Static semantics is more on the legal forms of programs (syntax rather semantics) and is only indirectly related to the meaning of the programs during execution. Static semantics is so named because the analysis required to check these specifications can be done at compile time. In many cases, the semantic rules of language state its type constraints. Dynamic semantics is describing the meaning of the programs. Programmers need to know precisely what statements of a language do. Compile writers determine the semantics of a language for which they are writing compilers from English descriptions

1. Define syntax and semantics!

Syntax is the form of its expressions, statements, and program units. Semantics is the meaning of those expressions, statements, and program units.

6. In what language was UNIX written?

The UNIX operating system is written almost entirely in C which has made it relatively easy to port, or move to different machines. Some of the characteristics of C make it a good choice for systems programming. It is low level, execution efficient and doesn't burden the user with many safety restrictions.

30. What are the advantages of implementing a language with pure interpreter?

The advantages of a pure interpreter, is allowing easy implementation of many source level debugging operations, because all run time errors messages can refer to source level units.

27. What is loop invariant? Explain with an example.

The corresponding step in the axiomatic semantics of a while loop is finding an assertion called a loop invariant, which is crucial to finding the weakest precondition. The loop invariant must satisfy a number of requirements to be useful. First, the weakest precondition for the while loop must guarantee the truth of the loop invariant. In turn, the loop invariant must guarantee the truth of the postcondition upon loop termination. These constraints move us from the inference rule to the axiomatic description. During execution of the loop-controlling Boolean expression and the loop body statements. Hence, the name invariant.

25. What is the problem with using a software pure interpreter for operational semantics?

The detailed characteristics of the particular computer would make actions difficult to understand. Such a semantic definition would be machine-dependent.

24. What is an example of two language design criteria that are in direct conflict with each other?

The example of two language design criteria that are in direct conflict with each other are reliability and cost of execution. For example the Java language definition demands that all references to array elements be checked to ensure that the index or indices are in their legal ranges. This step adds a great deal to the cost of execution of Java programs that contain large numbers of references to array elements. C does not require index range checking, so C programs execute faster than semantically equivalent Java programs, although Java programs are more reliable. The designers of Java traded execution efficiency for reliability.

23. What language was the first to support the three fundamental features of the object-orientated programming?

The first language that supported the three fundamental features of object-oriented programming was Smalltalk. Although Smalltalk never became as widely used as many other languages, support for object-oriented programming is now part of most popular imperative languages, including Ada 95, Java, C++ , and C#.

21 What two programming language deficiencies were discovered as a result of the research in software development in the 1970s.

The late 1960s and early 70s brought intense analysis of software development. the result in large begun the structure programming movement of both the software development process and program language design. An important reason for this research was the shift in the major cost of computing from hardware to software. The primary programming language deficiencies that were discovered were in-completeness of type checking and inadequacy of control statements (requiring the extensive use of gotos).

16. In denotational semantics, what are the syntactic and semantic domains?

The mapping functions of a denotational semantics programming language specification, like all functions in mathematics, have a domain and a range. the syntactic domain is called the domain because it is syntactic structures that are mapped. The domain is the collection of values that are legitimate parameters to the function; the range is the collections of objects to which the parameters are mapped. the semantic domain is called the range.

11. How is the order of evaluation of attributes determined for the trees of a given attribute grammar?

The parse tree is evaluated based on its underlying BNF grammar, with a possibility of having empty set of attributes values attached to each node.

17. What is stored in the state of a program for denotational semantics?

The state of a program for denotational semantics is the value of all its current variable.

27. What role does a symbol table play in a compiler?

The symbol table serves as a database for the compilation process. The primary contents of the symbol table are the type and attribute information of each user-defined name in the program. This information is placed in the symbol table by the lexical and syntax analyzers and is used by the semantic analyzer and the code generator.

10. What is the difference between a synthesized and an inherited attribute?

The synthesized attributes are the result of the attribute evaluation rules, and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes. In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down it. For instance, when constructing a language translation tool, such as a compiler, it may be used to assign semantic values to syntax constructions. Also, it is possible to validate semantic checks associated with a grammar, representing the rules of a language not explicitly imparted by the syntax.

22. What are the three fundamental features of Object-orientated programming language.

The three fundamentals features of an object-oriented programming language are data abstraction, which encapsulates processing with data objects and controls access to data, adds inheritance and dynamic method binding. Inheritance is a powerful concept that greatly enhances the potential reuse of existing software, thereby providing the possibility of significant increases in software development productivity. Dynamic (run-time) method binding allows more flexible use of inheritance.

25. What are the three general methods of implementing a programming language?

The three general methods of implementing a programming language are compilation (programs are translated into machine language), pure interpretation (programs are translated by another programs known as interpreter), and Hybrid Implementation (a compromise between compilers and pure interpreter).

9. What purpose do predicates serves in an attribute grammar?

The use of predicates functions is to state the static semantic rules of the language.

15. Describe the two levels of uses of operational semantics!

There are different levels of uses of operational semantics. At the highest level, the interest is in the final result of the execution of a complete program. This is called natural operational semantics. At the lowest level, operational semantics can be used to determine the precise meaning of a program through an examination of the complete sequence of state changes that occur when the program is executed, This use is called structural operational semantics.

20. What is the name of the category of programming languages whose structure is dedicated by the Von Neumann computer architecture?

These languages are called the imperative languages.

14. Why is type checking the parameters of a subprogram important?

Type checking is important because run-time type checking is expensive, compile-time type checking is more desirable. Furthermore, the earlier errors in programs are detected, the less expensive it is to make the required repairs..

6. Define a left-recursive grammar rule.

When a grammar rule has its LHS also appearing at the beginning of its RHS, the rule is said to be left-recursive. Left-recursive specifies left associativity. Unfortunately, left recursion disallows the use of some important syntax analysis algorithms. When such algorithms are to be used, the grammar must be modified to remove the left-recursion. This in turn, disallows the grammar from precisely specifying that certain operators are left associative. Fortunately, left associativity can be enforced by the compiler, even though the grammar does not dictate it.

21. When a grammar rule said to be left recursive?

When a grammar rule has its LHS also appearing at the beginning of its RHS, the rule is said to be left-recursive. This left recursion specifies left associativity.

24. On what branch of mathematics is denotational semantics based?

mathematical objects (called denotations)

23. On what branch of mathematics is axiomatic semantics based?

mathematics logic

19. What two things must be defined for each language entity in order to construct a denotational description of the language?

objects and functions

Describe the basic concept of denotational semantics.

programming language constructs are mapped to mathematical objects, either sets or, more often, functions.


संबंधित स्टडी सेट्स

Pharmacology: Module 6- Lesson 2 Post Test

View Set

Coterminal Angles/Reference Angles/The Unit Circle

View Set

Maternity Test 2 Chapter 19 Application

View Set

UNIT 2-SECURITY REGULATION UNDER THE USA-2.1-2.3 (REVIEW QUESTIONS)

View Set