Introduction to Programming Languages

Programming in C, C++, Scheme, Prolog, C#, and SOA

Yinong Chen and Wei-Tek Tsai

Arizona State University

 

Contents

 

Preface (Second Edition) ix

Preface (First Edition) xi

Chapter 1      Basic Principles of Programming Languages. 1

1.1     Introduction. 2

1.1.1     Programming concepts and paradigms  2

1.1.2     Program performance and features of programming languages  3

1.1.3     Development of programming languages  4

1.2     Structures of programming languages. 7

1.2.1     Lexical structure  8

1.2.2     Syntactic structure  8

1.2.3     Contextual structure  8

1.2.4     Semantic structure  9

*1.2.5   BNF notation  9

1.2.6     Syntax graph  11

1.3     Data types and type checking. 12

1.3.1     Data types and type equivalence  12

1.3.2     Type checking and type conversion  13

1.3.3     Orthogonality  14

1.4     Program processing and preprocessing. 16

1.4.1     Interpretation and compilation  16

1.4.2     Preprocessing: macro and inlining  18

*1.5   Program development 21

1.5.1     Program development process  21

1.5.2     Program testing  22

1.5.3     Correctness proof 26

1.6     Summary. 28

1.7     Homework and programming exercises. 29

Chapter 2      The Imperative Programming Languages, C/C++. 36

2.1     Getting started with C/C++. 37

2.1.1     Write your first C/C++ program   37

2.1.2     Basic input and output functions  38

2.1.3     Formatted input and output functions  39

2.2     Control structures in C/C++. 41

2.2.1     Operators and the order of evaluation  41

2.2.2     Basic selection structures (if-then-else and the conditional expression) 42

2.2.3     Multiple selection structure (switch) 43

2.2.4     Iteration structures (while, do-while and for) 46

2.3     Data and basic data types in C/C++. 48

2.3.1     Declaration of variables and functions  48

2.3.2     Scope rule  49

2.3.3     Basic data types  51

2.4     Complex types. 53

2.4.1     Array  53

2.4.2     Pointer 56

2.4.3     String  59

2.4.4     Constants