Programming Languages

Programming Languages

Compiler:
A program that decodes instructions written in a high-level language and produces an assembly language program. More precisely, the compiler is system software that translates source (human readable code) program into object program which is readable by the machine (machine code). Each language has its own compiler.

A = A+1; -> assignment statement
var expression
= ; -> syntax of the assignment statement.

Lexeme:
The lowest-level (smallest) lexical unit in a language, as a word or base; vocabulary item. A lexeme is merely a string of characters known to be of a certain kind;
i.e. a string literal. A program is referred to as a “string of lexemes” rather than a “string of chars”.

Syntax:
The set of rules that define which combinations of symbols are considered to be syntactically valid programs in that language. Syntactic categories are defined by grammar rules synonymous with productions. The syntax of a PL is the form of its expressions [E], Statements [S], and Program Components [PC].

Semantics:
The meaning of, or results of executing, a program. The meaning of the sum of the [E], [S], and [PC].
Consider the following statments for C or Java:

(i) if () -> syntax
(ii) while () -> syntax

The semantics of (i) is: if the current value of the expression is true the statement gets executed.
(ii) is actually the if and while construct; meaning if it is true then the statement gets executed until it is false.

Token:
Is a categorized block of text. The block of text corresponding to the token is known as a lexeme. The categories of lexemes are token-types as follows:
(i) identifiers (ii) literals (iii) operators (iv) special words (keywords).

Linker: (Link Editor):
A program that takes at least one machine readable object(s) and combines them into a single executable program while resolving symbols that refer to other modules.

Loader:
The run-time entity of an OS that is responsible for loading programs from executables into memory, preparing them for execution and then executing them.

Reliability: (comprised of the following metrics):
POFOD (probability of failure on demand)
ROCOF (rate of failure occurrence)
MTTF (mean time to failure)
AVAIL (availability or uptime)

Tree Structure: (Graph Theory):
A planar, connected graph, which has a distinct root and has no cycles. i.e. – classification graph.

Cycle: (Graph Theory):
A circuit in which no node except the first and last is repeated;
i.e. – (1, 3, 2, 1).

Parse Tree:
A hierarchical representation of a derivation. The compiler decides what code to generate for a statement by examining its parse tree. The parse tree must indicate precedence levels for the operators, such that there is no ambiguity.

Sentential Form:
A sentential form of a grammar G to be any sequence of grammar symbols (terminals or nonterminals) derived in 0 or more steps from the start symbol of G. A sentence is a sentential-form which contains only terminal symbols.

Ambiguity:
A grammar is ambiguous iff it generates a sentential form that has > 1 distinct parse trees; i.e. – non-deterministic meaning for the compiler.

Context-Free Grammars: (CFG):
A formal method for describing a PL; a series of grammar rules. Grammar rules are also called productions sincey they produce the strings of the language using derivations. A CFG is a meta-language in that it is a language used to describe another language, where the LHS is the abstraction being defined and the RHS is the mixture of tokens & lexemes. A Grammar is composed of a finite, non-empty set of rules. Sentences of a CFG are generated through a sequence of applications of rules beginning with a special non-terminal start symbol, which is the abstraction to be defined.

Extended Bachus-Naur Form: (EBNF):
A meta-syntactical notation used to express (CFG). EBNF is an extension of BNF which breaks the grammar rules into two types:
(i) lexical and (ii) syntactical rules.

Precondition:
An assertion before a statement states the relationship and constraints among variables are true at that point in execution.

s1, s2,…, sn are program statements:

s1, s2,…, sn/sn
s1^sn->for all n

Axiomatic Semantics:
Developed to prove the correctness of programs, as based on mathematical logic. as are logical expressions…proof of a given program requires that every statement in the program…
The definition of a PL is only complete when its semantics as well as its syntax and type system is fully defined.

Denotational Semantics:
A program can be expressed as a collection of functions operating on the program state. Mathematical objects are used to denote syntactic entities. Elements as a collection of environment and state transformation functions, where environment of a program is the set of objects and types that are active at each step during program execution. The state of a program is the set of all active objects and their current values.

let Sigma -> represent the set of all program states: delta
let MU -> is a mapping from a particular member of a given abstract class and current state in Sigma to a new state in Sigma. [M:class X Sigma -> Sigma]

Type:
A well defined set of values and operations on those values.

Type Error:
A runtime error that occurs when an operation is attempted on a value for which it is not well defined.

Strongly Typed:
A PL is strongly-typed it is type system allows all type errors in programs to be detected, either at compiler-time or at run-time, i.e. – Java.

Type Safe:
A program is type is type-safe if it is known to be free from type errors. All programs in a strongly-typed language are safe. Moreover, a PL is type-safe if all its programs are.

The state of a program is represented as a set of ordered pairs: {, , …, }
where each i is a var_name and v’s are the current-value of the i’s.

P. 163: Questions {2, 6, 7, 8, 10, 13, 14, 16, 18, 19}

Static Scope:
Binding names to non-local variables. All scopes are associated with program units.

Blocks:
Static-scopes inside program units.

Dynamic Scoping:
Based on the calling sequence of subs, not on their textual layout. Scope in this case can only be determined at run-time.

Scope and Lifetime:
The duration of an object is the duration of its allocation in the environment