Formal Systems & Programming Languages: An Introduction
Formal Systems & Programming Languages: An Introduction
Languages
An Introduction
Contents
Introduction to Formal Systems
Uses
Formal Specification
Formal Grammars
Types and Hierarchy of Languages
Examples
Formal System
Uninterpreted calculus
Logistic system
Consists of
◦ An alphabet
◦ Set of words (Axioms)
◦ Finite set of relations (Rules of Inference)
Examples
◦ Set Theory, Boolean Algebra, Proposition and
Predicate Calculus
Uses
Important in design, implementation and
study of programming languages
Used for
◦ Syntax – specification
◦ Syntax – directed compilation
◦ Compiler verification
◦ Complexity studies
◦ Analysis of structure of languages
Syntax Specification
Define the form of programming
language
Important both to
◦ User – needs clear description
◦ Implementer – problem of transferability &
maintenance
Exact specification of acceptable strings
of corresponding language
Syntax – Directed Compilers
Parse – recognize, find sequence of rules that generate the
string
Formal systems used as
◦ Database of syntactical rules of source language
Increasing no. of programming languages & machines –
automatic generation of compilers – formal definition of
both input & output language
Lsource, Lobject
Output of compiler generator – translator T: Lsource
-› Lobject
Similar problem – generating test-programs for validating
language processors
Complexity Structure Studies
Complexity of programming languages &
their compilers
Compiler writers & language designers
need to know
◦ Features of language – that increase
complexity of recognition phase
◦ Basis of evaluation of compiler performance
◦ Optimum level of performance
Structure Analysis
Used in attempt to prove
◦ Equivalence
◦ Validity of programs
Global optimization
Structure Analysis of Languages
Analysis & comparison of languages as of
◦ Basic language features
◦ Constructs & various combinations of
constructs available
◦ Categories of problems that can be programmed
◦ Cost/difficulty of writing a program
Regular Grammar
Restrictionon number of terminals and
nonterminals generated at each step
Type 3
Recognized by Finite State Automata