Ppl ppt


Published on

Programming Languages and Functional Programming

Published in: Education, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ppl ppt

  1. 1. PRINCIPLES OF PROGRAMMING LANGUAGE AND FUNCTIONAL PROGRAMING By:Tauseef Jamal(100101243) Siddharth Khurana(100101220) Pooja Singh(100101167) Varun Kumar(100101254)
  3. 3. INTRODUCTION • 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 Syntax o Names & Types o Semantics
  4. 4. • Syntax:- Describes what constitutes a structurally correct programs. • Names & Types:-Enables the programmer to understand and properly implement operations on the values of various types. • 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.
  5. 5. PROGRAMMING PARADIGMS • A Programming Paradigm is a pattern of problem-solving thoughts that underlies a particular genre of programs and languages. • Types:- Imperative Programming Object-Oriented Programming Functional Programming Logic Programming
  6. 6. COMPILERS  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. Source program program Target Error messages
  7. 7. STAGES OF COMPILER Source Program Lexical Analyzer Syntax analyzer Semantic analyzer Symbol Table Manager Intermediate code generator Code optimizer Code generator Target Program Error Handler
  8. 8. LEXICAL ANALYZER • 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 commas.
  9. 9. SYNTACTICAL ANALYZER • 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.
  10. 10. SEMANTIC ANALYZER • 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.
  11. 11. 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 intermediate code. • The complexity of this code lies between the source language code and the object code.
  12. 12. CODE OPTIMIZER • 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
  13. 13. CODE GENERATOR • Converts some intermediate representation of source code into a form that can be readily executed by a machine. • 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 modes.
  14. 14. BNF GRAMMAR • 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 & program. • Non-Terminals are written in angle brackets which also appear in the left hand side of at least one production. Example:-<A>::=<A><B> <B>
  15. 15. FUNCTIONAL PROGRAMMING • 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.
  16. 16. Example Summing the integers 1 to 10 in Java: total = 0; for (i = 1; i 10; ++i) total = total+i; The computation method is variable assignment. 16
  17. 17. Example Summing the integers 1 to 10 in Haskell: sum [1..10] The computation method is function application. 17
  18. 18. Basic Concepts Used In Functional Programming • • • • • Types and classes Defining functions List comprehensions Recursive functions Higher-order functions
  19. 19. 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
  20. 20. THANK YOU