Sign In
Not register? Register Now!


Pages:
0 pages/≈0 words
Sources:
Check Instructions
Style:
Check Instructions
Subject:
IT & Computer Science
Type:
Essay
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 5
Topic:

Principles of Programming Languages

Instructions:
The principles of programming languages is a document that can be used to answer exam questions about computer science and IT. The document contains well documented notes that are short and precise.
Content:
BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 1



1. DATA TYPES AND TYPE CHECKING
A data type is defined by the set of primary values allowed and the
operations defined on these values. A data type is used to declare
variables (e.g., integer, real, array of integer, string, etc.).
Type checking is the acti vity of ensuring that the data types of
operands of an operator are legal or equivalent to the legal type.
TWO MAJOR TYPE EQUIVALENCE POLICIES:
1. structural equivalence
2. name equivalence
structural equivalence policy is used, the two types are equivalent i f they
have the same set of values (data range) and the same operations.
This policy follows the stored program concept and gives programmers the
maximum flexibility to manipulate data. The stored program concept
suggests that instruction and data are stor ed in computer memory as binary bit
patterns and it is the programmer’s responsibility to interpret the meanings
of the bit patterns.
name equivalence policy is used, two types are equivalent only if they
have the same name. Since no programming language w ill normally
allow two different data types to have the same name, this policy does
not allow any variable of one type to be used in the place where a variable
of another type is expected without explicit type conversion. If name
equivalence policy is used , the statement “i = s + a;” is then illegal.

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 2

INTRODUCTION TO LANGUAGE TRANSLATION:

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 3

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 4

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 5


1

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 6


LESSON 4: INTRODUCTION TO LANGUAGE TRANSLATION

BSCS 311 PRINCIPLES OF PROGRAMMING LANGUAGES. 7

PHASES OF COMPILATION:
LEXICAL ANALYSIS
Lexical analysis involves the recognit ion of the elementary constituents of a
program.
– These are the keywords, operators, comments, delimiters, identifiers, literals,
etc.
– The individual characters of the source program must be grouped together to
form these constituents.
• The scanner must identify each lexeme and associate with it the grammatical
component within the program with which the lexeme is associated.
We call the grammatical component the token.
• The formal model for lexical analysis is a finite automaton.
In the program void main() { printf("Hello World \n"); }
the tokens are void, main, (, ), {, printf, (, "Hello World \n", ), ;, }

SYNTACTIC ANALYSIS (PARSING)
• The grammatical structure of the program is identified (e.g., statements,
procedures, expressions, etc.)
• T he parser must recognize how lexemes are grouped to form expressions,
statements, declarations, etc.
• The actions of semantic analysis are are usually initiated by the parser.
Get the Whole Paper!
Do you need a custom essay? Order right now:
Need a Custom Essay Written?
First time 15% Discount!