Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

Intermediate Code Generation
Programming Languages and Paradigms
Programming Languages and Paradigms The C Programming Language.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
1 Compiler Construction Intermediate Code Generation.
CS 415: Programming Languages Algol Aaron Bloomfield Fall 2005.
CS ExCo Advanced in Topics Object-Oriented Programming.
ECE 103 Engineering Programming Chapter 11 One Minute Synopsis Herbert G. Mayer, PSU CS Status 7/1/2014.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
ISBN Chapter 6 Data Types: Structured types.
G. Levine Chapter 6 Chapter 6 Encapsulation –Why do we want encapsulation? Programmer friendliness- programmer need not know about these details –Easier.
Copyright © 1995 by Addison-Wesley Publishing Co. 1 Names - Design issues: - Maximum length? - Are connector characters allowed? - Are names case sensitive?
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
Chapter 9: Subprogram Control
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
CSCE 330 Project Algol 68 Joe PuzioWael AL-Fayez Gaurav ShahRonak Patel.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
Block-Structured Procedural Languages Lecture 11: Dolores Zage.
PASCAL. HISTORY OF PASCAL Developed by Niklaus Wirth a member of the International Federation of Information Processing(IFIP) To provide features that.
Semantic Analysis Legality checks –Check that program obey all rules of the language that are not described by a context-free grammar Disambiguation –Name.
Pascal Course Spring Introduction Designed: 1968/9 by Niklaus Wirth Published: 1970 Imperative, structural, procedural Static and strong.
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001.
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Dr. Muhammed Al-MulhemICS Chapter 5 The Algol Family and Haskell.
1 CMPE 104 Pascal (Modified slides of Tom Rethard)
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
1 Type Checking Type checking ensures that the operands and the operator are of compatible types Generalized to include subprograms and assignments Compatible.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
Programming Languages and Paradigms Imperative Programming.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan.
ISBN Chapter 6 Structured Data Types Array Types Associative Arrays Record Types Union Types.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
Variables reference, coding, visibility. Rules for making names  permitted character set  maximum length, significant length  case sensitivity  special.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
Dr. M. Al-Mulhem Introduction 1 Chapter 6 Type Systems.
CSC 533: Programming Languages Spring 2016
Lecture 9 Symbol Table and Attributed Grammars
CSE3302 Programming Languages (notes continued)
Data Types In Text: Chapter 6.
Names and Attributes Names are a key programming language feature
CSC 533: Programming Languages Spring 2015
Def: A control structure is a control statement and
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
CS 326 Programming Languages, Concepts and Implementation
Records Design Issues: 1. What is the form of references?
Chapter 8: Control Structures
FORTRAN 04 February 1999; CS655.
Final Review In Text: Chapters 1-3, 5-11,
Chapter 6 Intermediate-Code Generation
Midterm Review In Text: Chapters 1-3, 5-9, 15.
Midterm Review In Text: Chapters 1-3, 5-10, 15.
Final Review In Text: Chapters 1-3, 5-12,
Symbol Table 薛智文 (textbook ch#2.7 and 6.5) 薛智文 96 Spring.
Midterm Review In Text: Chapters 1-3, 5-11, 15.
Types and Related Issues
Lecture 7: Types (Revised based on the Tucker’s slides) 10/4/2019
Presentation transcript:

Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan

Ch. 5 Ch. 52 jcmt CSE 3302 Programming Languages Return to Simplicity Attempts to extend Algol included: –PL /I very large intersection of FORTRAN, COBOL, and Algol “Swiss army knife” approach –Extensible languages Kernal: application independent Ex: operator extensions & syntax macros Inefficient; hard to debug

Ch. 5 Ch. 53 jcmt CSE 3302 Programming Languages Pascal Niklaus Wirth designed successor languages to Algol Goal was to compete with FORTRAN and keep the benefits of Algol Explicit goals –Suitable for teaching programming –Reliable, efficient implementation

Ch. 5 Ch. 54 jcmt CSE 3302 Programming Languages Pascal Structure Syntax is Algol-like Uses reserved words New structures added –Name –Data –Control

Ch. 5 Ch. 55 jcmt CSE 3302 Programming Languages Data Structures Primitives –Real, integer, boolean from Algol –Characters : type char Enumeration types –Replaces integer codes to represent lists –Limits range of values explicitly –Keeps types unique and separate –Defined as a binding construct –Only allows meaningful operations –Efficient implementation

Ch. 5 Ch. 56 jcmt CSE 3302 Programming Languages Data Structures, continued Subrange types –Security and efficiency Set types –Mathematical application –Efficient –Set operations defined - implemented with bit operations

Ch. 5 Ch. 57 jcmt CSE 3302 Programming Languages Arrays Generalized index types (integer subranges) Allowable element types - any other Pascal base type including other arrays, etc. No multi dimensional arrays BUT can have an array whose element type is array and “syntactic sugar” allows appearance of multi- dim arrays Restrictions on Pascal arrays –Static bounds : determinable at compile time –Dimensions are part of array type –Feature interaction problem with bounds

Ch. 5 Ch. 58 jcmt CSE 3302 Programming Languages Records Aggregate heterogeneous data –Components can be primitive types or complex data types including records and arrays –Component selection within a record is done with dot notation – with statement opens a record for accessing multiple fields within the block of the with

Ch. 5 Ch. 59 jcmt CSE 3302 Programming Languages Arrays vs. Records Structure Element typesSelectors Array HomogeneousDynamic (computable) Record HeterogeneousStatic

Ch. 5 Ch. 510 jcmt CSE 3302 Programming Languages Variant Records Groups different fields according to a status value The status value is called the tag field Creates a loophole related to type because variant fields do not have to be initialized and previous values of different type may be accessible

Ch. 5 Ch. 511 jcmt CSE 3302 Programming Languages Data types (cont.) Pascal structures allow efficient information storage Pascal has pointers –Pointers have data types to support strong typing in Pascal –Pointer base types can be any other type Initially type equivalence was not clearly defined –Structural, Name (simpler and safer) –Subrange equivalence within Name eq

Ch. 5 Ch. 512 jcmt CSE 3302 Programming Languages Name Structures Bindings –Constant –Type –Variable –Procedure and function –Implicit enumeration –Label

Ch. 5 Ch. 513 jcmt CSE 3302 Programming Languages Name Structures Constants abstract out dependencies Constants cannot be described by an expression Expressions cannot be used in variable or type declarations

Ch. 5 Ch. 514 jcmt CSE 3302 Programming Languages Name Struct Constructors Records Procedures –Much like Algol in format and scope –Order of declarations was important for one-pass compilation Reverses top-down order No way to define mutually recursive procs – forward declaration (like C prototype decl) Group order important also

Ch. 5 Ch. 515 jcmt CSE 3302 Programming Languages Control Structures More structures than Algol but simpler I/O routines provided Structured control is supported –One entry, one exit Supports recursion Has a goto to facilitate adoption

Ch. 5 Ch. 516 jcmt CSE 3302 Programming Languages Structures for –Austere & even simpler than FORTRAN DO while / do –Condition at beginning repeat / until –Condition at end case –Labeled cases

Ch. 5 Ch. 517 jcmt CSE 3302 Programming Languages Parameters Pass by reference Pass by value Pass by constant –Input parameter treated as a constant inside called routine –Compiler can either copy or pass address of parameter –Left loophole similar to aliasing problem

Ch. 5 Ch. 518 jcmt CSE 3302 Programming Languages Procedural parameters Can pass procedures and functions as parameters Originally, formal specification gave procedure name and return type but not parameters of procedure being passed Standard required parameters to be specified also

Ch. 5 Ch. 519 jcmt CSE 3302 Programming Languages Pascal Excellent teaching language Suitable for “real” programming Usage goes beyond original intent

Ch. 5 Ch. 520 jcmt CSE 3302 Programming Languages Other Languages PL /I extensions BCPL - Cambridge Plus London B - BCPL based & used in 1st Unix (8k PDP-7) C - successor of ‘B’ by Dennis Ritchie –Used to rewrite Unix kernel –Characteristics of 1st, 2nd, and 3rd gen languages PL /I extensions BCPL - Cambridge Plus London B - BCPL based & used in 1st Unix (8k PDP-7) C - successor of ‘B’ by Dennis Ritchie –Used to rewrite Unix kernel –Characteristics of 1st, 2nd, and 3rd gen languages

Ch. 5 Ch. 521 jcmt CSE 3302 Programming Languages Third Generation Languages Simplicity and efficiency Data structures support applications –Support nesting –User definition –Pointers Name structures have bindings for new types Control structures are simplified and efficient –Case