Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 2 : Language Design Principles ( PART 1), Its semantics is the…
Chapter 2 : Language Design Principles
( PART 1)
SYNTAX
form of its expressions, statements,
and program units.
Language:
Set of string of
characters from
some alphabet.
Token:
Category of its
lexeme. Example
identifier.
Lexeme:
basic lexical unit of
a language. Includes
of identifier, literals,
operator, special
word.
Sentence:
String of a language
aka statements
SEMANTIC
Static Semantic
is only indirectly
related to the meaning
of programs during
executions.
Dynamic Semantic
can be done at run
time
Operational Semantics
Describe the meaning of a program by executing its
statement on a machine, either real or simulated.
Axiomatic Semantics
Defines a programming language behavior by
applying mathematical logic and the development of method
to prove the correctness of programs.
Denotational Semantics
Defines a programming language behavior by
applying mathematical functions to programs
and program components to represent their meaning.
Syntax analysis
Often called parsing.
Syntax analyzer is a parser.
Lexical analysis
Lexical analyzer is the first
phase of a compiler.
Its main task is to read input
character and process as
output a sequence of tokens
that parser uses for syntax
analysis.
Names
Keywork
Special only in certain context.
Reserved Word
A special word that cannt be used as a (user defined) name.
Predefined Word
Assigns a meaning to a name.
Data Types
Built in data types
Composite data type
Homogenous (array) and heterogenous (struct)
Group – fixed sized data type (array, strings,
pointers, structures, functions, list) and dynamic
sized data type (linked list, stacks, queues)
Recursive data type
– commonly used in
functional and logic
Primitive data type
– 4 main types: int, real
(float), Boolean, character
User define data type
Enumeration Type, Subrange Type, Object
Type
Scopes
Static scoping
• Also known as lexical scoping.
• Definition is resolved by searching it containing block or function. If
that fail, then searching the outer containing block and so on.
Dynamic scoping
• In dynamic scoping, the definition of the variable is resolved by
searching it containing block and if it is not found, then searching its
calling function and if it still not found then the function which called
that calling function will be such will be searched and so on.
Binding
Static binding
• Early binding
• Binds attribute at compile time & translate into
Dynamic binding
• Binds attribute at run time
• Type of variable is not specified at declaration
statement
• Bind when it is assigned to a value
Type checking
Constructed types
are arrays, records, sets, pointer, function
Static and dynamic checking type
Checking done by compiler is
static
while if done at runtime is
dynamic.
Basic types
are the atomic types with no internal structure such as boolean,
integer, real, character, subrange and enumerated.
Its semantics is the meaning of those
expressions, statements, and program
units.