Programming Language Concepts and Compilation

Definition of Algorithm

The following definition: “Prescription for a set of logical steps to solve the same type” corresponds to:

ABoolean LogicCAn algorithm
BA programming languageDA computer program

Answer: (C)

Stored Program Concept

When the sequence of instructions to be executed by a computer is stored in main memory, it is said that the computer is programmed internally, and this defines:

ASource languageCStored program
BTarget languageDProgram Instructions

Answer: (C)

Batch and Integral Processing

Batch Processing

These are processes where the inputs and outputs are data files in batches, whose records are processed by consignment by a program.

Integral Processing

These are processes where the computer system and computers are an integral part of a larger system, and a computer failure usually means higher system failure as well.

Syntax Definition

The arrangement of words as elements in a sentence to show a specific relationship, described by the sequence of symbols that can build effective programs, is the definition of:

ASemanticsCSyntax
BA programming languageDA computer program

Answer: (C)

Elements of Language Syntax

In general, the syntax of a language style is set by the choice of several basic elements of syntax. Three of the seven most prominent watched in class are:

ACharacter Set, symbols of operation, optional wordsCCharacter Set, white, meanings
BKeys and reserved words, data dictionary, commentsDNone of the above

Answer: (A)

Common Functions of a Semantic Analyzer

The exact functions of the semantic analyzer vary substantially, depending on the language and logical organization of the translator. Two of the most common are:

AOperation characters
Handling optional words
CMaintenance of the symbol table
Error Detection
BRegister of reserved words
Interruptions of data
DNone of the above

Answer: (C)

Lexical Analysis

It is the start of any translation to group the sequence of characters into its elemental parts: identifiers, delimiters, operation symbols, numbers, keywords, optional, white, comments, and everything else. The results are the same lexical items or tokens.

Optimization in Program Translation

Optimization as a stage in program translation refines the result of the semantic analyzer, evaluating the versatility and efficiency produced by this and producing, in most cases, an object program with better performance.

Syntactic Unit

A sequence of lexemes forms a syntactic unit such as an expression, a sentence, a statement, or a call to a subprogram.

Machine Language

The program stored in computer memory so it can run is written in:

AA source languageCAn algorithm
BA programming languageDA machine language

Answer: (D)

Compiler Front End

It is part of a compiler that analyzes the source code, checks its validity to a tree branch, and fills in the values of the symbol table. It is often independent of the platform which will compile.

AFront EndCStored program
BObject CodeDBack End

Answer: (A)

Language Interpreter

A language interpreter analyzes the source program and runs it directly without generating any equivalent code. Its action is equivalent to that of a human interpreter, who translates phrases heard on the fly without producing any permanent writing. Examples of interpreters are the languages BASIC, Lisp, and Prolog.

Mainframe Computers

Large computers meet a range of users either for batch processes or to address several linked workstations.

Ambiguity in Language Design

A central problem in the design of any language is when it supports two or more different interpretations in executing an operation or set of instructions:

ALack of definitionCSemantic error
BSyntax ErrorDAmbiguity

Answer: (D)

Syntactic Elements of Language

Expressions and statements are identified as:

APrograms and sub-structuresCOperation symbols
BSyntactic elements of languageDBasic instructions of a language

Answer: (B)

Syntactic Analysis and Link/Load Process

Syntactic Analysis

Here, the structural elements of the program (statements, declarations, expressions, etc.) are identified using the lexemes produced by the lexical analyzer.

Link and Load

This stage, when the program refers to external data or other applets, links and loads the various segments of the translated code in memory, using a table attached to link properly addresses the data and programs at the code where necessary.

Terminal Symbols

The symbols used to form chains, derived from grammar rules of a language, are called terminal symbols. After the translation of the program has been optimized, it must be assembled in declarations and statements that can be read in machine language, which is the output of the translation.

Code Generation

This stage in program translation is known as:

AConstruction and sub-programCCode Generation
BSemantic AnalysisDLanguage production

Answer: (C)

Basic Differences Between Programming Languages

All programs specify a set of operations applied to certain data in a certain sequence. There are basic differences between the languages in three basic aspects:

A) Type of data that support, type of operations available, and mechanisms to control the sequence of operations

B) Types that support reading, memory types available, and mechanisms to control the sequence of operations

C) Type of sequence data that support, type of codes available, and mechanisms to monitor operations

D) Type of mechanism to control data, type of transactions available, and sequence of operations

Answer: (A)

Elementary Data Objects

A data object is elementary if:

AIs an aggregate of other data objectsCContains a data value that is always manipulated as a unit
BIs an array of other data objectsDContains a data value that is always manipulated as an object

Answer: (C)

Data Type, Stored Representation, and Abstract Data Type

Data Type

A data type is a kind of integrated data object to a set of operations to create and manipulate.

Stored Representation

The stored representation represents data objects of the data types in computer memory during program execution.

Abstract Data Type

An abstract data type is defined as:

  • A set of data objects, using one or more definitions of types
  • A set of abstract operations on these data objects
  • Encapsulation of the sets so that the user of the new type cannot manipulate the data objects except for using defined operations.

Abstraction Support in Programming Languages

A programming language provides support for abstraction in two ways:

A) 1 provided space for two objects by providing aid to the programmer to design process tools

B) A virtual computer 2 provided a facilitator helps the programmer to build abstractions

C) One providing a virtual link two data providing aid to the programmer to establish redundancy

D) Providing a support structure for facilitating the programmer abstractions in February to build virtual links

Answer: (B)

Largest Block of Storage

The largest block of storage on any system should be designated to store:

AControl routines memory manager at runtimeCThe code segments that represent user-compiled programs
BKeys and keywords, data dictionary, commentsDNone of the above

Answer: (C)

Information Concealment

Information concealment is primarily a matter of program design. An abstraction is encapsulated effectively only when the language prohibits access to information hidden in the abstraction.

Storage Elements

Elements that require storage:

  • Segments of code for compiled programs
  • Programs runtime system
  • Data structures and user-defined constants
  • Return subprogram points
  • Temporary evaluation of expressions

Sequence Control Structure Categories

Sequence control structures can be categorized into four groups. Two of them are:

  • Expressions
  • Declarations
  • Declarative programming
  • Subprograms

Syntax Tree

Parsing imposes a hierarchical structure to the chain of lexical components performed using syntactic trees.

Compiler Phases: Front End and Back End

In 1958, Strong and others proposed a solution where a compiler could be used by several machines. This is done by dividing the compiler into two phases:

AAnalyzer and SynthesizerCFront End and Back End
BTranslator and IntegratorDNone of the above

Answer: (C)

Compiler Error Detection

The phases that usually handle a large proportion of errors detected by the compiler are:

ALexical AnalyzerCCode Optimization
BSyntactic and Semantic AnalysisDCode Generation

Answer: (B)

Compiler vs. Interpreter

Compilers translate during development time before the program runs. The compiler receives the source code, analyzes, optimizes, and translates it into machine language, creating a complete program ready for implementation.

Interpreters translate during runtime. As the program runs, the interpreter translates instructions into machine language.

Software Tools for Source Code Analysis

Many software tools manipulate source programs by performing some analysis first. Examples include:

  • Structure Editors: Analyze program text and give it a hierarchical structure.
  • Pretty Printers: Analyze and print a program to make its structure clear.
  • Static Checkers: Analyze a program to discover potential errors without running it.
  • Interpreters: Perform the operations of the source program instead of producing an object program.

Module Design in Large Programs

Large programs are divided into components called modules. Module design usually includes two aspects:

  • Functional decomposition of the program
  • Data decomposition of the program

Memory Allocation Demand

The operation often requiring the most memory allocation is the activation of a subprogram record and other information upon calling a subprogram.

Static Memory Management

The simplest form of allocation is static mapping. Storage segments of program code and system users are assigned statically, such as I/O buffers and various miscellaneous system data.

Infix Notation

Infix notation is suitable for binary operations, where the operation symbol is written between the two operands, commonly used for arithmetic, relational, and logical operations.

Information Hiding

Information hiding is primarily a program design concern. Abstraction is effectively encapsulated only when the language prevents access to the hidden information within the abstraction.

Abstraction Support and Storage Allocation

A programming language supports abstraction in two ways:

  1. Providing a virtual computer
  2. Providing tools for programmers to build abstractions

The largest storage block should be designated for user-compiled program code segments.

Temporary Storage Areas

Input and output operations usually work through buffers, temporary storage areas holding data between transfer and program processing.

Compiler vs. Assembler

Compilers translate higher-level source code into machine code during development, while assemblers translate assembly language (a low-level language) into machine code. Assembly language has a near one-to-one correspondence with machine instructions.

Lexicographic Recognition

In the late 1950s, Rabin and Scott proposed using deterministic and nondeterministic automata for lexicographic recognition (the process of identifying and categorizing words or tokens in a sequence of characters).