Please enable JavaScript.
Coggle requires JavaScript to display documents.
Language Design Principles - Coggle Diagram
Language Design Principles
Syntax
The syntax of a programming language is
the form of its expressions, statements, and program units.
Set of rules how language element may be
grammatically combined
Describing
Syntax
Sentence:
String of a language
aka statements
Lexeme:
basic lexical unit of
a language. Includes of identifier, literals,
operator, special word.
Language:
Set of string of
characters from some alphabet.
Token:
Category of its
lexeme. Example identifier.
Language
recognizers:
A device capable of reading string of characters from a language & determine the character, in effect a device capable of recognize all the characters from the language
A recognizer determines whether the given programs are in the language and syntactically correct.
Language
Generator
A device that is used to generate sentence of a language.
Grammar
Type 1
Grammar
Context sensitive grammar
Type 2
Grammar
Context-free grammar
Type 0
Grammar
Unrestricted grammar
Type 3
Grammar
Regular grammar or restrictive grammar
Parse tree
Every internal node labeled as non-
terminal symbol.
Every leaf is labeled with a terminal
symbol
Naturally describe the syntactic
structure of the language define.
Every subtree describes one
abstraction instances.
Also known as derivation tree
Semantic
Its semantics is the meaning of those
expressions, statements, and program units.
How each grammatically correct sentence
is to be interpreted
Describing semantic
Static Semantic
is only indirectly related to the meaning of programs during executions;
The analysis required to check the specifications can be
done at compile time.
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.
The changes that
occur in the machine’s state when it executes
a given statement define the meaning of
that statement.
Axiomatic Semantics
Defines a programming
language behavior by applying mathematical
logic and the development of method
to prove the correctness of
programs.
Axiomatic semantics is
based on mathematical logic. The logical
expressions are called predicates, or
assertions.
Denotational Semantics
Defines a programming
language behavior by applying mathematical
functions to programs and program
components to represent their meaning.
It is based on recursive
function theory.
Lexical and
syntax analysis
Lexical analysis
Its main task is to read input
character and process as output a sequence of tokens
that parser uses for syntax analysis.
It matches a given pattern of
character.
Lexical analyzer is the first
phase of a compiler.
Part of syntax analysis.
Syntax analysis
Often called parsing.
Syntax analyzer is a parser.
Names and
Data Types
Data Types
Built in data types
Composite data type:
Recursive data type
Primitive data type
User define data type
Enumeration Type, Subrange Type, Object
Type
String of characters used to identify some entity in
a program.
Binding,
type checking,
scopes
Binding
A process of association of attribute variables during compilation
and execution of a program.
Static binding
Binds attribute at compile time & translate into
Early binding
Dynamic binding
Type of variable is not specified at declaration
statement
Bind when it is assigned to a value
Binds attribute at run time
Type checking
Basic types are the atomic types with no internal structure such as boolean, integer, real, character, subrange and enumerated.
Constructed types are arrays, records, sets, pointer, function
In most language, types either basic or constructed.
Scopes
The scope of a variable is the range of statements over which it is
visible:
Variable yyy is visible in statement st1 if yyy can be referenced in st1.
The scope rules of a language determine how occurrences of names
are associated with variables:
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.