• STAGES OF COMPILER
• FUNCTIONAL PROGRAMMING
• USES OF FUNCTIONAL PROGRAMMING
• Language Designers have a basic vocabulary about
language structure, meaning and pragmatic concerns that
help them understand how language works. Their
vocabulary falls into three major categories that we call
programming language design.
o Names & Types
• Syntax:- Describes what constitutes a structurally correct
• Names & Types:-Enables the programmer to understand
and properly implement operations on the values of
• Semantics:-Defines the meaning of a program.
i.e. when a program is executed, the effect of each
statement on the values of the variable in the program is
given by the semantic of the language.
• A Programming Paradigm is a pattern of problem-solving
thoughts that underlies a particular genre of programs and
A compiler is a program that reads a program written in
one language – the source language – and translate it
into an equivalent program in another language – the
target language. As an imp part of this translation
process, the compiler reports to its user the presence
errors in the source program.
STAGES OF COMPILER
Intermediate code generator
• Also called “Scanner”.
• Scanner separates characters of the source language into
groups that logically belong together, these groups are
called tokens. Usual tokens are keywords such as Do or
IF, identifiers such as NUM, operators such as <,= ,+,
and punctuation symbols such as parentheses or
• Also called “Parser”.
• It is the process of analyzing a string of symbols, either
in natural language or in computer languages, according
to the rules of a formal grammar.
• In this phase the compiler adds semantic information to
the parse tree and builds the symbol table.
• Performs semantic checks such as type checking, object
binding, definite assignment, rejecting incorrect programs
or issuing warnings.
INTERMEDIATE CODE GENERATOR
• It is machine independent.
• During the translation of a source program into the object
code for a target machine, a compiler may generate a
middle-level language code, which is known as
• The complexity of this code lies between the source
language code and the object code.
• The intermediate language representation is transformed
into functionally equivalent but faster (or smaller) forms.
It tries to minimize or maximize some attributes of
an executable computer program
• Converts some intermediate representation of source
code into a form that can be readily executed by a
• This involves resource and storage decisions, such as
deciding which variables to fit into registers and memory
and the selection and scheduling of appropriate machine
instructions along with their associated addressing
• Backus-Naur Form.
• Adopted from Chomsky Theory.
• Used for defining programming language syntax, the non-
terminals N identify the language's grammatical
categories like identifiers,integers,expression,statement &
• Non-Terminals are written in angle brackets which also
appear in the left hand side of at least one production.
• Functional programming is style of programming in which
the basic method of computation is the application of
functions to arguments;
• A functional language is one that supports and
encourages the functional style.
Summing the integers 1 to 10 in Java:
total = 0;
for (i = 1; i
total = total+i;
The computation method is variable assignment.
Summing the integers 1 to 10 in Haskell:
The computation method is function application.
Basic Concepts Used In Functional
Types and classes
WHY IS IT USEFUL?
The abstract nature of functional programming leads to
considerably simpler programs;
It also supports a number of powerful new ways to
structure and reason about programs