compilers

code optimizer

code optimization

optimization  is  the  strategy  of  examining  intermediate  code  as
produced  by or  during  the code  generation  phase with  the aim  of
producing code that runs  very efficiently.Production of code that use
very  little  space   has  also  been  a  goal   of  some  optimizers;
nevertheless, the main emphasis has  traditionally been and will be in
this chapter on the generation of very fast executing code.


Reference/Source :
Theory and Practice of Compiler Writing.
Jean-Paul Tremblay and Paul G. Sorenson.

intermediate code generation

Intermediate Code Generation

Because of the complexity of code generation, a compiler typically breaks up this
phase into several steps,involving various intermediate data structures, often
including some form of abstract code called intermediate code.


Reference/Source :
Compiler Construction: Principles and Practice
Kenneth C Louden

semantic analysis

Semantic Analysis

Semantic analysis is the phase in which the compiler adds semantic information
to the parse tree and builds the symbol table.This phase performs semantic
checks such as type checking (checking for type errors), or object binding
(associating variable and function references with their definitions), or definite assignment (requiring all local variables to be initialized before use), rejecting
incorrect programs or issuing warnings.

Semantic analysis usually requires a complete parse tree,
meaning that this phase logically follows the parsing phase,
and logically precedes the code generation phase, though it
is often possible to fold multiple phases into one pass over
the code in a compiler implementation.


Reference/Source:
http://en.wikipedia.org/wiki/Semantic_analysis_(compilers)#Front_end

Lexical Analysis

Lexical analysis is the process of taking an input string
of characters (such as the source code of a computer
program) and producing a sequence of symbols called
"lexical tokens", or just "tokens", which may be handled
more easily by a parser.
A token, in computing, is a segment of text, regardess
whether it be readable or comprised of symbols. Tokens
are generally defined abstractly in a context free grammar,
which is fed into a program such as yacc which checks the
stream of tokens for conformity to this grammar.
A parser is a computer program or a component of a program
that analyses the grammatical structure of an input, with
respect to a given formal grammar, a process known as parsing.
In linguistics, grammar is the set of structural rules that govern
the composition of sentences, phrases, and words in any given
natural language.

Related Notes :

Lexical analysis is concerned with scanning the
input for significant clusters of characters called tokens.
The input stream of characters is analyzed using delimiters
and a careful description of the way various types tokens
may be constructed.


Reference/Source :
http://en.wikipedia.org/wiki/Grammar
http://www.wordiq.com/definition/Parser
http://www.wordiq.com/definition/Token_(parser)
http://www.wordiq.com/definition/Lexical_analysis
D. Soda, G. W. Zobrist
February 1989
CSC '89: Proceedings of the 17th conference on ACM Annual Computer Science Conference

object oriented programming

Class Definition Related


div.entry h2.title, div.entry h1.title
{ padding-bottom: 22px; background-color: #4e9258 ; font-family: serif; font-size:150%;}

Object-oriented programming (OOP) is a programming paradigm
that uses "objects" – data structures consisting of data fields and
methods together with their interactions – to design applications
and computer programs

Reference/Source: http://en.wikipedia.org/wiki/Object-oriented_programming


Code Exposition


p.first{ color: blue; }
p.second{ color: red; }
<html>
<body>
<p>This is a normal paragraph.</p>

<p class="first">This is a paragraph that uses the p.first CSS code ! </p>
<p class="second">This is a paragraph that uses the p.second CSS code!</p>
...

Reference/Source:
http://www.tizag.com/cssT/class.php

Related Research

Actually, every OOP language should be concurrent in nature.
As previously stated, OOP attempts to model objects found in
the real world, and in the real world many of these objects con-
currently exist and communicate with one another. In the 'ideal'
environment (sort of a virtual machine), every object would have
its own processor as well as its own memory space, allowing
maximum concurrency at all times. Inherently concurrent obje-
cts could even have multiple processors assigned to them.

CONCURRENCY IN CONVENTIONAL OOP LANGUAGES
C-Based Languages. C++ [Str86, WP88] and Objective-C
[Cox86] do not include any constructs for handling concur-
rency. However, since they are extensions of C [KR78], they
can do anything that C can do. Although C itself does not
support concurrency, any extension to C could most likely
be implemented in a C-based OOP language. Additionally,
any scheme in which C is allowed to make a call to the
operating system to start (spawn) a new process could also
be accomplished from a C-based OOP language. Eiffel
[Mey88] does not include any form of concurrency, but they
are reportedly making an effort in this direction.

Lisp-Based Languages. Similar to C-based languages, CLOS
[BDG88, Kee89, Moo89] (an extension of Common Lisp
[Ste84]), does not include any  constructs for handling concurrency
and, unfortunately, Common Lisp does not support concurrency
in any form either. However, as Lisp is a form of functional
programming (which is based on the lambda calculus), some
form of concurrency is possible. In pure functional programming,
a program may be expressed as a single function call, with the
arguments to the function themselves being function calls; the
arguments to these functions can in turn be function calls, etc.
Since the value returned by a pure function is determined solely
by the arguments passed to it, implementations can be devised
which allow for all of the arguments

which are function calls to be executed in parallel. The arguments
of these function calls which are themselves functions can then be
executed in parallel, and so on. This is sometimes referred to as
divide and conquer in that a program is divided up into concurrent
subprograms (the arguments which are function  calls) which can
then be conquered (solved) by again using the divide and conquer
 scheme [Pey87].

Reference/Source:
CONCURRENCY & OBJECT-ORIENTED PROGRAMMING
Michael L. Nelson, Major, USAF
Department of Computer Science
Naval Postgraduate School
Monterey, CA 93943

gcc limits and -Wformat



#include <stdio.h>
#include <limits.h>
int main (void)
{
unsigned long ul = LONG_MAX;
short int si = SHRT_MIN;
printf ("%d\n", ul);
printf ("%s\n", si);
return 0;
}


$gcc printme.c
$./a.out
-1
Segmentation fault
$gcc printme.c -Wformat
printme.c: In function ‘main’:
printme.c:7: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
printme.c:8: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
$

The <limits.h> header shall define various symbolic names.
The names represent various limits on resources that the
implementation imposes on applications.

about "-Wformat"
Check calls to printf and scanf, etc., to make sure that the
arguments supplied have types appropriate to the format
string specified, and that the conversions specified in the
format string make sense
 
Reference/Source:
The Definitive Guide to GCC Second Edition
William von Hagen
http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

gcc options.



$gcc hello.c -o hello
$du -h hello
8.0K hello
$gcc -pg hello.c -o hello
$du -h hello
8.0K hello
$ls -l hello
-rwxr-xr-x 1 7417 Nov 2 05:46 hello
$rm hello
$gcc hello.c -o hello
$ls -l hello
-rwxr-xr-x 1 6593 Nov 2 05:47 hello
$
some content supressed.

The gcc compiler accepts both single-letter options, such as
-o, and multiletter options, such as -ansi. Because it accepts both
types of options you cannot group multiple single-letter options
together as you may be used to doing in many GNU and Unix
/Linux programs. For example, the multiletter option -pg is not
the same as the two single-letter options -p -g. The -pg option
creates extra code in the final binary that outputs profile information
for the GNU code profiler, gprof. On the other hand, the -p -g options
generate extra code in the resulting binary that produces profiling
information for use by the prof code profiler (-p) and causes gcc to
generate debugging information using the operating system’s normal
format (-g).


Reference/Source:
The Definitive Guide to GCC Second Edition
William von Hagen

Languages

There are three types of languages:
1. Imperative.
2. Functional.
3. Logical.

In computer science, imperative programming is a programming
paradigm that describes computation in terms of statements that
change a program state. In much the same way that imperative
mood in natural languages expresses commands to take action,
imperative programs define sequences of commands for the
computer to perform.

In computer science, functional programming is a programming
paradigm that treats computation as the evaluation of mathematical
functions and avoids state and mutable data. It emphasizes the
application of functions, in contrast to the imperative programming
style, which emphasizes changes in state.[1] Functional programming
has its roots in lambda calculus, a formal system developed in the
1930s to investigate function definition, function application, and
recursion. Many functional programming languages can be viewed as
elaborations on the lambda calculus.[1]

Logic programming languages, of which PROLOG (programming
in logic) is the best known, state a program as a set of logical
relations (e.g., a grandparent is the parent of a parent of someone).
Such languages are similar to the SQL database language. A
program is executed by an “inference engine” that answers a query
by searching these relations systematically to make inferences
that will answer a query. PROLOG has been used extensively in
natural language processing and other AI programs.


Reference/Source:
http://en.wikipedia.org/wiki/Imperative_programming
http://en.wikipedia.org/wiki/Functional_programming
http://www.britannica.com/EBchecked/topic/130670/computer-programming-language/248126/Declarative-languages?anchor=ref849840