Copyright © 2013 by Gordon S. Novak Jr.
Permission is granted for individuals to make copies of these notes for personal use, or for instructors to make copies for classroom use.
Note: Many of these pages use math symbols such as: ∀ ∃ . Microsoft Internet Explorer will not display the math symbols, but Firefox will.
1. CS 375, Compilers: Class Notes
2.
3. Course Topics
4. Pascal Test Program
5. Introduction
6. Machine Language
7. Assembly Language
8. High-Level Language
9. Compilers
10. Sequential Phases of a Compiler
11. Data Flow through the Compiler
12. Line Handler
13. Lexical Analyzer
14. Syntactic Analyzer
15. Semantic Analysis
16. Lexical Analysis
17. Character Classes
18. Implementation of Character Classes
19. Hand-written Lexical Analyzer
20. Example Lexical Analyzer
21. Flowchart for Parsing Identifier
22. Lexical Language Design
23. Token Data Structure
24. Example Token Data Structure
25. Number Conversion
26. Simple Number Scanner
27. Lexical Analyzer Output
28. Floating Point Numbers
29. IEEE Floating Point Standard
30. Floating Point Examples
31. Errors
32. Error Messages
33. Formal Syntax
34. Grammar
35. Language Generation
36. Parsing
37. Ambiguity
38. Notation
39. Phrase Structure Grammar
40. Chomsky Hierarchy
41. Recognizing Automaton
42. Chomsky Language Hierarchy
43. Regular Languages
44. Example Regular Language
45. lex
46. Regular Expressions
47. Lex Specifications
48. Sample lex Specification
49. C for Lex Sample
50. lex.yy.c
51. Comments on Sample lex
52. Translation Section
53. Lex Conventions
54. The Lookahead Operator
55. Auxiliary Procedures
56. Parser Overview
57. Context Free Languages
58. Context Sensitive Languages
59. Derivations
60. Language Generated by a Grammar
61. Ambiguity and Left Recursion
62. Parsing
63. Top-down Parser
64. Bottom-up Parsing
65. Chart Parser
66. Augmented Transition Network Grammars
67. Augmented Transition Networks
68. Context Free Parser
69. Semantics Influences Parsing
70. Arithmetic Expressions
71. Example of Operator Precedence
72. Operator Precedence
73. Operator Precedence Parsing
74. Operator Precedence Parser
75. Examples
76. Stack Handling in C
77. Basic Routines
78.
79. Operator Precedence Parser
80.
81. Additional Considerations
82. Recursive Descent Parser
83. Bottom-up Table-driven (LR) Parsing
84. The LR Parsing Algorithm
85. Shift-Reduce Parser
86. Example Parsing Table
87. A Parse of id * id + id
88. Synthesized Translation
89. Using yacc
90. y.tab.c
91. Yacc Specifications
92. Example: Desk Calculator
93. Yacc: Pascal Subset
94. Auxiliary C Code
95. Auxiliary C Code ...
96. Controllability and Observability
97. Example
98. Examples ...
99. Examples ...
100. Hints for yacc
101. File trivb.tree
102. The Semantic Actions
103. Supporting C Routines
104. Example
105. Comments on the Example
106. Parsing Action Conflicts
107. Resolving Shift/Reduce Conflicts
108. Error Productions
109. Error Handling
110. Parsing Techniques
111. Looping Statements
112. Symbol Table
113. Symbol Table Organization
114. Symbol Table Organizations
115. Binary Tree Symbol Table
116. AVL Trees
117. Hash Table
118. Hash Functions
119. Indexed Buckets
120. Nested Procedures
121. Tree of Symbol Tables
122. Stack Symbol Table
123. Use of Symbol Table
124. Symbol Table Entry
125. Kinds of Symbols
126. Kinds of Symbols ...
127. Looking up ID in Symbol Table
128. Variable Declarations
129. Identifier List etc.
130. Data Addressing
131. Storage Allocation
132. Alignment and Padding
133. Installing Variables in Symbol Table
134. Record Declarations
135. Symbol Table Structures for Record
136. Array Declarations
137. Symbol Table Structures for Array
138. Type Checking, Coercion, and Inference
139. Structure References
140. Structure References....
141. Record References
142. Array References
143. Array References in Pascal
144. Does Array Order Matter?
145. Example of Structure Declaration
146. Example of Structure Reference
147. Pointer Reference
148. Types as Tree Structures
149. Dynamic Type Checking
150. Static Type Checking
151. Strong Typing
152. Type Equivalence
153. Type Signatures
154. Polymorphic Procedures
155. Table for Labels
156. Intermediate Code
157. Quadruples
158. Triples
159. Reverse Polish Notation
160. Trees and Reverse Polish
161. Converting a Tree to RPN
162. Executing Reverse Polish
163. Executing RPN
164. RPN as Intermediate Code
165. Code Generation
166. Loading Process
167. Absolute File
168. Initializing BSS Storage
169. Banked Memory
170. Location Counter
171. Example of Assembly Listing
172. Backpatching
173. Link Editing Process
174. Relocatable Code
175. Finding Relocatable Modules
176. Assigning Absolute Addresses
177. Absolute Addresses
178. Link Editor
179. Form of Relocatable Code
180. Static Allocation
181. Dynamically Linked Library
182. Run-Time Support
183. Operations by Subroutine
184. Special Subroutines
185. Memory Management
186. Returning Memory
187. Heap Memory Management
188. Garbage Collection
189. Garbage Collection
190. Mark-And-Sweep Garbage Collection
191. Mark-and-Sweep ...
192. Copying Garbage Collection
193. Reference Counting
194. Reference Counting...
195. Garbage Collection Is Expensive
196. Compiled Procedure
197. Subroutine Call Is Expensive
198. Activations and Control Stack
199. Environment
200. Run-time Memory Organization
201. Code Generation
202. Code Generation
203. Code Generation
204. Running Generated Code
205. Overview of Code Generation
206. Code Generation for Statements
207. Arithmetic Expressions
208. Basic Expression Algorithm
209. Trace of Expression Algorithm
210. Arithmetic Expression Algorithm
211. Register Management
212. Simple Register Allocation
213. Heuristic for Expressions
214. Improving Register Allocation
215. Register Allocation
216. Example of Code Generation
217. Example (2)
218. Example (3)
219. Example (4)
220. Reusing Register Contents
221. Register Targeting
222. x86 Processor
223. Move (Load/Store) Instructions
224. Kinds of Move Addressing
225. Move with Calculated Address
226. Literals
227. Integer Arithmetic Instructions
228. Compare and Jump
229. Floating Point
230. Intrinsic Functions
231. Function Calls
232. Volatile Registers
233. Details of Function Call
234. IF Statement Generation
235. IF Statement Optimization
236. Array References
237. Easy Array References
238. Better Array References
239. Pointer References
240. switch Statement
241. switch Statement Compiled
242. switch Statement Compiled -O
243. Table Lookup
244. Table Lookup Compiled
245. Table Lookup Compiled -O
246. Parameter Passing
247. Macros
248. In-line Compilation
249. Optimization
250. Correctness of Optimization
251. Optional Optimization
252. Local and Global Optimization
253. Easy Optimization Techniques
254. Constant Folding
255. Peephole Optimization
256. Loop Unrolling
257. Partial Evaluation
258. Partial Evaluation
259. Example
260. Simple Partial Evaluator
261. Simple Partial Evaluator...
262. Examples
263. Examples
264. Binding-Time Analysis
265. Futamura Projections
266. Interpreter
267. Specialization
268. Parameterized Programs
269. Pitfalls of Partial Evaluation
270. Pitfalls ...
271. Program Analysis
272. Basic Block
273. Finding Basic Blocks
274. Relations and Graphs
275. Graph Notations
276. Bit Vector Representations
277. Boolean Matrix Representation of Graph
278. Dominators
279. Intervals
280. Definition and Reference of Variables
281. Data Flow Analysis for a Block
282. Availability of Expressions
283. Data Flow Analysis for an Interval
284. Busy Variables
285. Variable Uses and Register Assignment
286. Register Allocation by Graph Coloring
287. Overview of Global Optimization
288. gcc Compiler Optimization Options
289. gcc Optimizations
290. Loop Transformations
291. Strip Mining
292. Induction Variable Transformation
293. Finite Differencing
294. Example: Computing Squares
295. General Case
296. Finite Differencing for Set Operations
297. Memoization
298. Hardware Assistance
299. PowerPC Features
300. SPARC Features
301. Hardware Trends
302. Object-oriented Programming
303. Access to Objects
304. Domain Analysis
305. Internal Implementation is Hidden
306. Encapsulation with OOP
307. Object-oriented Programming Terminology
308. Terminology ...
309. Implementation of Objects
310. Are Basic Types Objects?
311. Inheritance and Class Structure
312. Message Sending
313. Dynamic Method Lookup
314. Static Method Lookup
315. Multiple Inheritance
316. Improving OOP Efficiency
317. Smalltalk
318. Smalltalk Code
319. ThingLab
320. ThingLab Examples
321. Good Features of OOP
322. Unfortunate Features of OOP
323. Why OOP Is Not Enough
324. Top Ten Lies About OOP
325. Aspect-Oriented Programming
326. Lisp
327. History of Lisp
328. Advantages of Lisp
329. Lisp Interaction
330. Function Definition
331. List Structure
332. Abstract Syntax Tree
333. Binding Lists
334. Substitution
335. Copying and Substitution Functions
336. Substitution in C
337. Loop Unrolling
338. Instantiating Design Patterns
339. Pattern Matching
340. Pattern Matching
341. Transformation by Patterns
342. Transformation Patterns
343. Program Transformation using Lisp
344. Dot Matching
345. Looping Patterns
346. Code Expansion by Looping Patterns
347. More Complex Rules
348. Multi-Level Patterns
349. Use of Multi-Level Patterns
350. Function Inlining
351. Program Transformation
352. Pattern Optimization Examples
353. Examples ...
354. Examples ...
355. Examples ...
356. Paul Graham:
357. English
358. Expression Trees to English
359. Generating English
360. Parsing English
361. ATN in Lisp
362. Parsing Functions
363. Grammar Compiler
364. Access to Database
365. Restaurant Database Grammar
366. Restaurant Queries
367. Physics Problems
368. Physics Queries