{ "course": "Principles_of_Programming_Languages", "course_id": "CO3005", "schema_version": "material.v1", "slides": [ { "page_index": 0, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_001.png", "page_index": 0, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:20+07:00" }, "raw_text": "Introduction Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam 08,2017 Dr. Nguyen Hua Phung Introduction 1/26" }, { "page_index": 1, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_002.png", "page_index": 1, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:22+07:00" }, "raw_text": "Outline Introduction Reasons to study Concepts of Programming Languages Language Evaluation Criteria Language Design Implementation Methods Dr. Nguyen Hua Phung Introduction 2/26" }, { "page_index": 2, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_003.png", "page_index": 2, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:23+07:00" }, "raw_text": "Lecturer In Charge o My name: Nguyen Hua Phung Email: nhphung@hcmut.edu.vn Office hour: Office hour: BKeL Facebook: Dr. Nguyen Hua Phung Introduction 4/26" }, { "page_index": 3, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_004.png", "page_index": 3, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:25+07:00" }, "raw_text": "References Concepts of Programming Languages, Robert W. Sebesta,12th edition, Pearson, 2019. Programming Languages: Principles And Paradigms, Maurizio Gabbrielli and Simone Martini, Springer, 2006. Programming Languages: Principles and Practices, Kenneth C. Louden, Thomson Brooks/Cole, 2003 Ngon Ngu Lap Trinh: Cac nguyen ly va mo hinh, Cao Hoang Tru, 2004. Dr. Nguyen Hua Phung Introduction 5/26" }, { "page_index": 4, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_005.png", "page_index": 4, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:27+07:00" }, "raw_text": "Assessment Tutorial/Lab/Online: 10% Assignment: 30% Midterm: 20% Final: 40% Note: Assignment is calculated by the following formula. A* B Assignment = 2 * A + B where A is from some given project and B is from some questions in midterm or final Dr. Nguyen Hua Phung Introduction 6/26" }, { "page_index": 5, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_006.png", "page_index": 5, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:30+07:00" }, "raw_text": "Objectives After complete this subject, students are able to: o describe formally lexicon and grammar of a programming language describe and explain some mechanism of a programming language implement a interpreter/compiler for a simple programming language Dr. Nguyen Hua Phung Introduction 8/26" }, { "page_index": 6, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_007.png", "page_index": 6, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:32+07:00" }, "raw_text": "Benefits of Studying Increased capacity to express idea Improved background for choosing appropriate languages Increased ability to learn new languages Better understanding of the significance of implementation Better use of languages that are already knowr o Overall advancement of computing Dr. Nguyen Hua Phung Introduction 9/26" }, { "page_index": 7, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_008.png", "page_index": 7, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:33+07:00" }, "raw_text": "Programming Domains Scientific Applications Fortran, ALGOL 60 Business Applications COBOL Artificial Intelligence LISP, Prolog Systems Programming PL/S,BLISS, Extended ALGOL, and O Web Software XHTML, JavaScript, PHP Dr. Nguyen Hua Phung Introduction 11/26" }, { "page_index": 8, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_009.png", "page_index": 8, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:35+07:00" }, "raw_text": "Language Characteristics Simplicity Orthogonality Support of abstraction (Control, Data) Safety Dr. Nguyen Hua Phung Introduction 12/26" }, { "page_index": 9, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_010.png", "page_index": 9, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:36+07:00" }, "raw_text": "Evaluation Readability Writability Reliability Cost Dr. Nguyen Hua Phung Introduction 13/26" }, { "page_index": 10, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_011.png", "page_index": 10, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:38+07:00" }, "raw_text": "nfluences on Language Design o Computer Architecture Von Neumann o Programming Methodologies Imperative o Machine-based Procedural o Declarative o Logic Functional o Constraint o Query-based Object-Oriented Dr. Nguyen Hua Phung Introduction 15/26" }, { "page_index": 11, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_012.png", "page_index": 11, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:40+07:00" }, "raw_text": "Computer Architecture Intluence Well-known computer architecture: Von Neumann Imperative languages, most dominant, because of von Neumann computers Data and programs stored in memory Memory is separate from CPU Instructions and data are piped from memory to CPU Basis for imperative languages Variables model memory cells Assignment statements model writing to memory cell Iteration is efficient Dr. Nguyen Hua Phung Introduction 16/26" }, { "page_index": 12, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_013.png", "page_index": 12, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:42+07:00" }, "raw_text": "Programming Methodologies lnfluences 1950s and early 1960s: Simple applications; worry about machine efficiency Late 1960s: Efficiency became important; readability better control structures Structured programming Top-down design and step-wise refinement Late 1970s: Process-oriented to data-oriented o data abstraction Middle 1980s: Object-oriented programming o Data abstraction + inheritance + polymorphism Dr. Nguyen Hua Phung Introduction 17/26" }, { "page_index": 13, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_014.png", "page_index": 13, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:44+07:00" }, "raw_text": "Language Paradigms Imperative (C, Pascal) o Central features are variables, assignment statements, and iteration Functional (LISP, Scheme, Haskel, Ocaml, Scala) Main means of making computations is by applying functions to given parameters o Logic (Prolog) Rule-based (rules are specified in no particular order) Object-oriented (Java, C++, Scala) Data abstraction, inheritance, late binding Markup (XHTML,XML) o New; not a programming per se, but used to specify the layout of information in Web documents Dr. Nguyen Hua Phung Introduction 18/26" }, { "page_index": 14, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_015.png", "page_index": 14, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:47+07:00" }, "raw_text": "Language Design Trade-Offs Reliability vs. cost of execution o Conflicting criteria . Example: Java demands all references to array elements be checked for proper indexing but that leads to increased execution costs Readability vs. writability Another conflicting criteria Example: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readability Writability (flexibility) vs. reliability o Another conflicting criteria o Example: C++ pointers are powerful and very flexible but not reliably used Dr. Nguyen Hua Phung Introduction 19/26" }, { "page_index": 15, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_016.png", "page_index": 15, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:50+07:00" }, "raw_text": "mplementation Methods Compilation Programs are entirely translated into machine language and then executed Pure Interpretation Programs are translated and executed line-by-line Hybrid Implementation Systems A compromise between compilers and pure interpreters Just-in-time Compiler A compiler inside an interpreter compiles just hot methods Dr. Nguyen Hua Phung Introduction 21/26" }, { "page_index": 16, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_017.png", "page_index": 16, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:52+07:00" }, "raw_text": "mplementation Methods Source - ( Compiler Execution Result Data Source Interpreter Result Data Source Compiler Interpreter Result Data Dr. Nguyen Hua Phung Introduction 22/26" }, { "page_index": 17, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_018.png", "page_index": 17, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:54+07:00" }, "raw_text": "Compilation Phases source program lexical analyzer syntax analyzer 4 front end semantic analyzer intermediate code generator code optimizer back end code generator target program Dr. Nguyen Hua Phung Introduction 24/26" }, { "page_index": 18, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_019.png", "page_index": 18, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:56+07:00" }, "raw_text": "Related Programs o Preprocessor Assembler Linker Loader Debugger Editor Dr. Nguyen Hua Phung Introduction 25/26" }, { "page_index": 19, "chapter_num": 0, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_0/slide_020.png", "page_index": 19, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:56+07:00" }, "raw_text": "Summary What are still in your mind? Dr. Nguyen Hua Phung Introduction 26/26" }, { "page_index": 20, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_001.png", "page_index": 20, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:15:58+07:00" }, "raw_text": "Case Study: Python Introduction Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam 08,2020 Dr. Nguyen Hua Phung Case Study:Python 1/1" }, { "page_index": 21, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_002.png", "page_index": 21, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:00+07:00" }, "raw_text": "ntroduction popular programming language created by Guido van Rossum, released in 1991. used in many areas: web, software, big data, system scripting,... originally implemented in hybrid model readability: new line to complete a command indentation to define scope static scoping and dynamically typed Dr. Nguyen Hua Phung Case Study: Python 2/1" }, { "page_index": 22, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_003.png", "page_index": 22, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:02+07:00" }, "raw_text": "Example C = 3 def gt(n) : if (n 0 or n return 1 else : return n * gt(n-1) print(gt(c)) def foo(a): return a * c print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 3/1" }, { "page_index": 23, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_004.png", "page_index": 23, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:05+07:00" }, "raw_text": "Example C = 3 def gt(n) : if (n == 0 or n == 1 return main 1 else : c 3 return n + gt(n-1) gt > code of gt print(gt(c)) def foo(a): return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 24, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_005.png", "page_index": 24, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:08+07:00" }, "raw_text": "Example C = 3 def gt(n) : i f (n == 0 or n == 1 return 1 main else : c 3 return n + gt(n-1) gt > code of gt print(gt(c)) def foo(a): return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 25, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_006.png", "page_index": 25, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:12+07:00" }, "raw_text": "Example C = 3 def gt(n) : gt if (n == 0 or n == 1) : n return 1 else : rv return gt(n-1) main n * print(gt(c)) C 3 def foo(a): gt > code of gt return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 26, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_007.png", "page_index": 26, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:15+07:00" }, "raw_text": "Example gt C = 3 n 2 def gt(n) : if (n == 0 or n == 1) : rv return 1 gt else : n return n * gt(n-1) rv print(gt(c)) main def foo(a): c 3 return a * C print(foo(2)) gt > code of gt Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 27, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_008.png", "page_index": 27, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:19+07:00" }, "raw_text": "Example gt n 1 C = 3 rv def gt(n): gt if (n == 0 or n 1) : == n 2 return 1 else : rv return n * gt(n-1) gt print(gt(c)) n def foo(a): rv return a * C main print(foo(2)) c 3 gt > code of gt Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 28, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_009.png", "page_index": 28, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:22+07:00" }, "raw_text": "Example gt n 1 C = 3 rv def gt(n): gt if (n == 0 or n == 1) : n 2 return 1 else : rv return n * gt(n-1) gt print(gt(c)) n def foo(a): rv return a * C main print(foo(2)) c 3 gt > code of gt Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 29, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_010.png", "page_index": 29, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:25+07:00" }, "raw_text": "Example gt C = 3 n 2 def gt(n) : if (n == 0 or n == 1) : rv return 1 gt else : n return n * gt(n-1) rv print(gt(c)) main def foo(a): c 3 return a * C print(foo(2)) gt > code of gt Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 30, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_011.png", "page_index": 30, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:29+07:00" }, "raw_text": "Example C = 3 def gt(n) : gt if (n == 0 or n == 1) : n return 1 rv 6 else : return n * gt(n-1) main print(gt(c)) C 3 def foo(a): gt > code of gt return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 31, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_012.png", "page_index": 31, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:32+07:00" }, "raw_text": "Example C = 3 def gt(n) : if (n == 0 or n 1 : print == return 1 6 else : main return n + gt(n-1) c 3 print(gt(c)) gt > code of gt def foo(a): return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 32, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_013.png", "page_index": 32, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:35+07:00" }, "raw_text": "Example C = 3 def gt(n) : if (n == 0 or n == 1 main return 1 c 3 else : gt code of gt return n gt(n-1) 1 + print(gt(c)) foo > code of foo def foo(a): return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 33, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_014.png", "page_index": 33, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:38+07:00" }, "raw_text": "Example C = 3 def gt(n) : if (n == 0 or n == 1 main return 1 c 3 else : gt code of gt return n gt(n-1) 1 + print(gt(c)) foo > code of foo def foo(a): return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 34, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_015.png", "page_index": 34, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:42+07:00" }, "raw_text": "Example C = 3 foo def gt(n) : if (n == 1) : a 2 0 or n == return 1 rv else : main return n + gt(n-1) c 3 print(gt(c)) gt > code of gt def foo(a): foo > code of foo return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 35, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_016.png", "page_index": 35, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:45+07:00" }, "raw_text": "Example C = 3 foo def gt(n) : if (n == 1 : a 2 0 or n == return 1 rv 6 else : main return n * gt(n-1) c 3 print(gt(c)) gt > code of gt def foo(a): foo > code of foo return a * c print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 36, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_017.png", "page_index": 36, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:47+07:00" }, "raw_text": "Example C = 3 def gt(n) : print if (n == 0 or n 6 return 1 main else : c 3 return n + gt(n-1) print(gt(c)) gt > code of gt def foo(a): foo > code of foo return a * C print(foo(2)) Dr. Nguyen Hua Phung Case Study:Python 4/1" }, { "page_index": 37, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_018.png", "page_index": 37, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:50+07:00" }, "raw_text": "Basic Things Variables: Like variables in C++ [a-zA-Z 1[a-zA-Z0-9 1* case-sensitive keep a pointer to an object declared by an assigment to the variable Comments: Line comment: # Block comment: 11I111 111111 Dr. Nguyen Hua Phung Case Study:Python 5/1" }, { "page_index": 38, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_019.png", "page_index": 38, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:52+07:00" }, "raw_text": "Statements Assignments: o a = 23 a,b = b,a (swap) a = b = c = 23 pass statement: like empty statement in C++ if statement: use indentation for sub-statements if : (elif : )* (else : )? no dangling-else Dr. Nguyen Hua Phung Case Study:Python 6/1" }, { "page_index": 39, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_020.png", "page_index": 39, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:54+07:00" }, "raw_text": "Loop Statements while: loop when the condition is true while : [else : 1 else block is executed when becomes false o for: iterates over a sequence for in : [else : 1 else block is executed after iterating all elements of break: like C++ => terminating the loop continue:like C++ => ignoring the rest of the Dr. Nguyen Hua Phung Case Study: Python 7/1" }, { "page_index": 40, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_021.png", "page_index": 40, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:56+07:00" }, "raw_text": "Example for x in range(1,11): if (x == 8): break print(x) else: print(\"loop, full\") Dr. Nguyen Hua Phung Case StudyPython 8/1" }, { "page_index": 41, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_022.png", "page_index": 41, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:57+07:00" }, "raw_text": "Functions User-defined function: def () : Dr. Nguyen Hua Phung Case Study:Python 9/1" }, { "page_index": 42, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_023.png", "page_index": 42, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:16:59+07:00" }, "raw_text": "Functions User-defined function: def () : o Example def giaithua(n) : if n == 0 or n == 1: return 1 else: return n * giaitthua(n-1) Dr. Nguyen Hua Phung Case Study:Python 9/1" }, { "page_index": 43, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_024.png", "page_index": 43, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:01+07:00" }, "raw_text": "Functions User-defined function: def () : o Example def giaithua(n) : if n == 0 or n == 1: return 1 else: return n * giaitthua(n-1) Built-in functions or libraries: import from import from import * Dr. Nguyen Hua Phung Case Study:Python 9/1" }, { "page_index": 44, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_025.png", "page_index": 44, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:03+07:00" }, "raw_text": "Functions o User-defined function: def () : o Example def giaithua(n) : if n == 0 or n == 1 : return 1 else: return n * giaitthua(n-1) Built-in functions or libraries: import from import from import * Example import functools functools.reduce(lambda x,y:x + y,[1,2,3] Dr. Nguyen Hua Phung Case Study: Python 9/1" }, { "page_index": 45, "chapter_num": 1, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_1/slide_026.png", "page_index": 45, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:05+07:00" }, "raw_text": "References I [1] Python Tutorial, http: w3schools.com/python,10 08 2020 [2] Python Programming Language, https ://www . geeksforgeeks.org/python-programming-language/. 1008 2020. [3] Python Tutorial, https://www.tutorialspoint.com/python,10 082020 [4] Introduction to Python 3, https://realpython.com/python-introduction/,1008 2020. Dr. Nguyen Hua Phung Case Study:Python 10/1" }, { "page_index": 46, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_001.png", "page_index": 46, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:06+07:00" }, "raw_text": "Lexical Analysis Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam 08,2016 Dr. Nguyen Hua Phung Lexical Analysis 1/33" }, { "page_index": 47, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_002.png", "page_index": 47, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:08+07:00" }, "raw_text": "Outline ntroduction Roles Implementation Use ANTLR to generate Lexer Dr. Nguyen Hua Phung Lexical Analysis 2/33" }, { "page_index": 48, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_003.png", "page_index": 48, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:10+07:00" }, "raw_text": "Compilation Phases source program lexical analyzer syntax analyzer 4 front end semantic analyzer intermediate code generator code optimizer back end code generator target program Dr. Nguyen Hua Phung Lexical Analysis 4/33" }, { "page_index": 49, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_004.png", "page_index": 49, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:12+07:00" }, "raw_text": "Lexical Analysis Like a word extractor in= i n = in o Like a spell checker I ogog to socholsochol Like a classification 1 am a student pronoun verb article noun Dr. Nguyen Hua Phung Lexical Analysis 6/33" }, { "page_index": 50, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_005.png", "page_index": 50, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:13+07:00" }, "raw_text": "Lexical Analysis Roles ldentify lexemes: substrings of the source program that belong to a grammar unit Return tokens: a lexical category of lexemes Ignore spaces such as blank, newline, tab Record the position of tokens that are used in next phases Dr. Nguyen Hua Phung Lexical Analysis 7/33" }, { "page_index": 51, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_006.png", "page_index": 51, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:16+07:00" }, "raw_text": "Example on Lexeme and Token e S u + 0 ldsum - value / 100; Lexemes Kind of Tokens result IDENT = ASSIGN OP oldsum IDENT SUBSTRACT OP value IDENT / DlV OP 100 INT LIT . SEMICOLON 7 Dr. Nguyen Hua Phung Lexical Analysis 8/33" }, { "page_index": 52, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_007.png", "page_index": 52, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:18+07:00" }, "raw_text": "How to build a lexical analyzer? How to build a lexical analysis for English? o 65000 words Simply build a dictionary: {(I,pronoun);(We,pronoun);(am,verb),...} Extract, search, compare But for a programming language? o How many words? o Identifiers: abc, cab, Abc, aBc, cAb, .. Integers: 1, 10, 120, 20, 210, ... Too many words to build a dictionary, so how? o Apply rules for each kind of word (token) Dr. Nguyen Hua Phung Lexical Analysis 11/33" }, { "page_index": 53, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_008.png", "page_index": 53, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:20+07:00" }, "raw_text": "Rule Representations o Finite Automata o Deterministic Finite Automata o Nondeterministic Finite Automata o Regular Expressions Dr. Nguyen Hua Phung Lexical Analysis 12/33" }, { "page_index": 54, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_009.png", "page_index": 54, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:22+07:00" }, "raw_text": "Finite Automata a a a .. Input Tape Head (Read only) 93 92 qn q1 qo Finite Control Dr. Nguyen Hua Phung Lexical Analysis 13/33" }, { "page_index": 55, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_010.png", "page_index": 55, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:25+07:00" }, "raw_text": "State Diagram a a b start 9o 91 b Input: abaabb Current state Read New State a qo b 91 91 a 91 91 a 91 91 b 00 b 91 Dr. Nguyen Hua Phung Lexical Analysis 14/33" }, { "page_index": 56, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_011.png", "page_index": 56, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:27+07:00" }, "raw_text": "Deterministic Finite Automata Definition Deterministic Finite Automaton(DFA) is a 5-tuple M =(K,,,s,F) where o K = a finite set of state = alphabet s E K = the initial state F C K = the set of final states o = a transition function from K x to K Dr. Nguyen Hua Phung Lexical Analysis 15/33" }, { "page_index": 57, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_012.png", "page_index": 57, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:30+07:00" }, "raw_text": "Example M =(K,,,s,F) where K={qo,q1} Z={a,b} s=90 F={q1} and K (K,) a 9o b 91 91 a 91 91 b 9o a a b V start 91 b Dr. Nguyen Hua Phung Lexical Analysis 16/33" }, { "page_index": 58, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_013.png", "page_index": 58, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:32+07:00" }, "raw_text": "Nondeterministic Finite Automata o Permit several possible \"next states\" for a given combination of current state and input symbol Accept the empty string e in state diagram Help simplifying the description of automata o Every NFA is equivalent to a DFA Dr. Nguyen Hua Phung Lexical Analysis 17/33" }, { "page_index": 59, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_014.png", "page_index": 59, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:33+07:00" }, "raw_text": "Example Language L = ({ab} U{aba}) a start 91 b a b 92 Dr. Nguyen Hua Phung Lexical Analysis 18/33" }, { "page_index": 60, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_015.png", "page_index": 60, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:35+07:00" }, "raw_text": "Example Language L = ({ab} U{aba}) a start - qo 91 E b a 92 Dr. Nguyen Hua Phung Lexical Analysis 19/33" }, { "page_index": 61, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_016.png", "page_index": 61, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:37+07:00" }, "raw_text": "Regular Expression (regex) Describe regular sets of strings Symbols other than () 1 * stand for themselves Use e for an empty string Concatenation a = First part matches a, second part p Union a6 = Match a or 6 Kleene star a* = 0 or more matches of a Use ) for grouping Dr. Nguyen Hua Phung Lexical Analysis 20/33" }, { "page_index": 62, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_017.png", "page_index": 62, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:40+07:00" }, "raw_text": "Example RE Language 0 {0} => 01 {01} => 01 => {0,1} 0(01) => {00,01} (01)(01) => {00,01,10,11} 0* {E,0,00,000,0000,...} (01)* => {E,0,1,00,01,10,11,000,001,...] Dr. Nguyen Hua Phung Lexical Analysis 21/33" }, { "page_index": 63, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_018.png", "page_index": 63, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:42+07:00" }, "raw_text": "Example (iI)(fF) Keyword if of language Pascal IF If iF 0 E(0123456789)* An E followed by a (possibly empty) sequence of digits E123 E9 0 E Dr. Nguyen Hua Phung Lexical Analysis 22/33" }, { "page_index": 64, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_019.png", "page_index": 64, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:44+07:00" }, "raw_text": "Regular Expression and Finite Automata a b start ab a C start b E E a start a* E E E Dr. Nguyen Hua Phung Lexical Analysis 24/33" }, { "page_index": 65, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_020.png", "page_index": 65, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:45+07:00" }, "raw_text": "Convenience Notation a+ = one or more (i.e. aa*) a? = 0 or 1 (i.e. (a e)) [xyz]= xyz [x-y]= all characters from x to y, e.g. [0-9] = all ASCll digits [x-y]= all characters other than [x-y] o . matches any character Dr. Nguyen Hua Phung Lexical Analysis 25/33" }, { "page_index": 66, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_021.png", "page_index": 66, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:47+07:00" }, "raw_text": "Example (01234) [0-4] => (aghm) [aghm] => 0123456789)(0123456789) [0-9]+ Ee)(+-E)(0123456789)+ [Ee][+-]?[0-9]+ Dr. Nguyen Hua Phung Lexical Analysis 26/33" }, { "page_index": 67, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_022.png", "page_index": 67, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:49+07:00" }, "raw_text": "ANTLR [1] ANother Tool for Language Recognition Terence Parr, Professor of CS at the Uni. San Francisco powertul parser/lexer generator Dr. Nguyen Hua Phung Lexical Analysis 29/33" }, { "page_index": 68, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_023.png", "page_index": 68, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:51+07:00" }, "raw_text": "Lexer /** * Filename : Hello.g4 */ lexer grammar Hello ; // match any digits INT: [0-9]+; // Hexadecimal number HEX: 0[Xx][0-9A-Fa-f]+; // match lower-case identifiers ID : [a-z]+ ; // skip spaces, tabs, newlines WS : [ trn]+ -> skip ; Dr. Nguyen Hua Phung Lexical Analysis 30/33" }, { "page_index": 69, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_024.png", "page_index": 69, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:53+07:00" }, "raw_text": "Lexical Analyzer Input Tape Look ahead 13 Token r2 rn with longest prefix match r1 ro Lexical Analyzer Dr. Nguyen Hua Phung Lexical Analysis 31/33" }, { "page_index": 70, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_025.png", "page_index": 70, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:54+07:00" }, "raw_text": "Summary A lexical analyzer is a pattern matcher that isolates small-scale parts of a program o Lexical rules are represented by Regular expressions or Finite Automata. o How to write a lexical analyzer (lexer) in ANTLR Dr. Nguyen Hua Phung Lexical Analysis 32/33" }, { "page_index": 71, "chapter_num": 2, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_2/slide_026.png", "page_index": 71, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:55+07:00" }, "raw_text": "References I [1] ANTLR, http:antlr.org,19 08 2016. Dr. Nguyen Hua Phung Lexical Analysis 33/33" }, { "page_index": 72, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_001.png", "page_index": 72, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:57+07:00" }, "raw_text": "Syntax Analysis Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn HCMC University of Technology, Viet Nam 07,2019 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 1/37" }, { "page_index": 73, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_002.png", "page_index": 73, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:17:59+07:00" }, "raw_text": "Outline Introduction to Syntax Analysis Context-free grammar Write a grammar Some issues Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 2/37" }, { "page_index": 74, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_003.png", "page_index": 74, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:02+07:00" }, "raw_text": "Introdution Roles read the sequence of tokens produce as output a parse tree or abstract syntax tree (AST) o give error messages when detecting syntax errors token parse source lexical syntax - tree / program analyzer analyzer AST get next token symbol table Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 4/37" }, { "page_index": 75, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_004.png", "page_index": 75, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:04+07:00" }, "raw_text": "Example Source program: a = b * 4 Lexer output (parser input): ID ASSIGN ID MULOP INTLIT Parser output: ID ASSIGN MULOP Ib INTLIT Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 5/37" }, { "page_index": 76, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_005.png", "page_index": 76, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:06+07:00" }, "raw_text": "Regular Expression Can we use regular expression to express the following language? L={a\"bhn> 0} Example In programming languages, there are some symmetric structure o (((...))) the number of ( must be equal to that of ) o repeat ... repeat ... until ... until Dr. Nguyen Hua Phung nhphung@hcmut . .edu.vn Syntax Analysis 7/37" }, { "page_index": 77, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_006.png", "page_index": 77, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:09+07:00" }, "raw_text": "Recursive Structure More generally, programming languages have many recursive structures Example ::= + ::= if then else Regular expressions cannot describe this kind of structure We need o A mean to describe this kind of language o A method to detect if a seguence of tokens is valid or invalid regarding to this kind of language Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Syntax Analysis 8/37" }, { "page_index": 78, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_007.png", "page_index": 78, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:10+07:00" }, "raw_text": "Context-free grammar A context-free grammar (CFG) consists of o A set of terminals T o A set of non-terminals N o A start symbol S E N o A set of productions P A production p E P is in the form: X -> a where X e N and a is a sequence of symbols in T and/or N Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 9/37" }, { "page_index": 79, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_008.png", "page_index": 79, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:13+07:00" }, "raw_text": "Example CFG for simple integer expressions consists of: o Set of terminals (tokens):{ADDOP, MULOP, INTLIT, LB RB} Set of non-terminals:{} Start symbol: Set of productions: ADDOP MULOP INTLIT LB RB Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 10/37" }, { "page_index": 80, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_009.png", "page_index": 80, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:15+07:00" }, "raw_text": "Example CFG for simple integer expressions consists of: o Set of terminals (tokens):{ADDOP, MULOP, INTLIT, LB RB} Set of non-terminals:{} Start symbol: Set of productions: ADDOP 1 MULOP 1 INTLIT 1 LB RB Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 11/37" }, { "page_index": 81, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_010.png", "page_index": 81, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:17+07:00" }, "raw_text": "Derivation How to know the language which a CFG describe? Language Generation 1 Start with the string containing only the start symbol Replace any non-terminal symbol X in the string with the right-hand side of some production X - a Repeat (2) until there are no non-terminals in the string Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 12/37" }, { "page_index": 82, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_011.png", "page_index": 82, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:20+07:00" }, "raw_text": "Example Grammar ADDOP (1) 1 MULOP (2) LB RB (3) 1 INTLIT (4) Derivation 21 MULOP (4) INTLIT MULOP INTLIT MULOP ADDOP (4) INTLIT MULOP INTLIT ADDOP 4 INTLIT MULOP INTLIT ADDOP INTLIT Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 13/37" }, { "page_index": 83, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_012.png", "page_index": 83, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:21+07:00" }, "raw_text": "Context-free language Let G be a context-free grammar with start symbol S. The language L(G) generated from G is: { a1a2...an ai e T and S a1a2...an} Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 14/37" }, { "page_index": 84, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_013.png", "page_index": 84, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:23+07:00" }, "raw_text": "Language Recognization CFG is a good mean to describe PL, but: Not only check if a string is valid but also its parse tree o how to handle gracefully error Parse Tree Start symbol as the parse tree's root For a production X - Y Y?...Yn, add children Y1 Y2... Yn to node X Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 15/37" }, { "page_index": 85, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_014.png", "page_index": 85, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:24+07:00" }, "raw_text": "Example Source: 12 * (4 + 5) Parser input: INTLIT MULOP LB INTLIT ADDOP INTLIT RB Parser output: MULOP INTLIT LB RB INTLIT INTLIT Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 16/37" }, { "page_index": 86, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_015.png", "page_index": 86, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:26+07:00" }, "raw_text": "Some tricks Based on the language specification Try to find out the hierarchy structure of a language Focus on the order of syntax units instead of their meaning or other constraints Use recursion to describe something occurring many times o Use recursion to describe nested structures Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 18/37" }, { "page_index": 87, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_016.png", "page_index": 87, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:29+07:00" }, "raw_text": "Based on language specification Each language has its own specification which sometimes differs from common sense o Smalltalk has the same precedence for all binary operators a+ b* c=((a+ b) *c) C specifies >, < , >= , <= higher priority than ==, !- while Pascal lets these operators same priority Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 19/37" }, { "page_index": 88, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_017.png", "page_index": 88, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:31+07:00" }, "raw_text": "Hierarchy Structure program declaration function variable constant parameter statement declaration declaration declaration type idlist expression Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 20/37" }, { "page_index": 89, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_018.png", "page_index": 89, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:33+07:00" }, "raw_text": "Example program program declaration variable decl declaration function const decl type_decl variable constant parameter idlist statement declaration declaration declaration function para_decl stmt type idlist expression exp Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 21/37" }, { "page_index": 90, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_019.png", "page_index": 90, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:35+07:00" }, "raw_text": "Just the order, not other constraints o CFG just helps to describe the order of tokens CFG cannot be used to describe type constraints Some other kinds of constraints such as scope, name resolution,... cannot be solved by CFG Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 22/37" }, { "page_index": 91, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_020.png", "page_index": 91, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:37+07:00" }, "raw_text": "Example 2.1 Constant Declaration: Each constant declaration has the form. = ; The will be discussed later in the Expression section. Note that the expression in a constant declaration must be evaluated statically, so it cannot include a variable or a method invocation. For example: My1stCons = 1 + 5; MyndCons = 2 *My1stCons, Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 23/37" }, { "page_index": 92, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_021.png", "page_index": 92, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:39+07:00" }, "raw_text": "One vs Many Some language structures may contain unlimited list of elements: o A variable declaration may have a list of identifiers a, c10, b: integer; o A function declaration may have a list of parameter function foo(a:integer; b:real) o A block may have many statements inside begin c := 1; m := 10; end Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 24/37" }, { "page_index": 93, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_022.png", "page_index": 93, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:43+07:00" }, "raw_text": "Write grammar rule for Use recursion to describe based on 1 [] E : symbol is used to separate elements in a list a, c10, d: integer function foo(a:integer;b:real) : the minimum number of elements ir the list if there is at least one element - if the list may be empty For example, listid ID tailid ID tailid COMMA ID tailid E Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Syntax Analysis 25/37" }, { "page_index": 94, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_023.png", "page_index": 94, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:45+07:00" }, "raw_text": "Nested structures In programming languages, there are many nested structures: o There may be a function declaration in a function declaration o A statement may appear inside another statement. A block may appear inside another block An expression may be an operand of another expressior Use recursion to describe a nested structures, for example lF THEN ELSE 1 WHILE DO 1 Dr. Nguyen Hua Phung nhphung@hcmut .edu. vn Syntax Analysis 26/37" }, { "page_index": 95, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_024.png", "page_index": 95, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:49+07:00" }, "raw_text": "Extended Backus-Naur Form(EBNF EBNF allow to use operators in regular expression in RHs higher expressiveness often supported by top-down parsing generators BNF EBNF (RHS) ANTLR '+' exp: 1 '-' (('+'I'-') ) term (('+'l'-') term)*; 1 ELSE else: (ELSE )? 1 (\"else\" stmt)?; ID ', idlist idlist: ID (; ID)* 1 ID ID (\",\" ID)* ; Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 27/37" }, { "page_index": 96, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_025.png", "page_index": 96, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:52+07:00" }, "raw_text": "Ambiguous grammar When more than one parse tree can be found for a string of tokens, the grammar is ambiguous Ambiguity makes the meaning of some programs ill-defined Example: INTLIT ADDOP INTLIT MULOP INTLIT MULOP ADDOP ADDOP INTLIT INTLIT MULOP INTLIT INTLIT INTLIT INTLIT ADDOP calculated first MULOP calculated first Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 29/37" }, { "page_index": 97, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_026.png", "page_index": 97, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:55+07:00" }, "raw_text": "Disambiguous ambiguous grammar o Rewrite the grammar unambiguously o In some grammar tools, there are disambiguating declarations ADDOP l MULOP 1 INTLIT LB RB The recursive term appeared in both sides of ADDOP and MULOP is the source of ambiguity. o Removing one recursive term in right hand side of productions can disambiguous the grammar. ADDOP MULOP 1 INTLIT 1 LB RB Dr. Nguyen Hua Phung nhphung@hcmut .edu . vn Syntax Analysis 30/37" }, { "page_index": 98, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_027.png", "page_index": 98, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:18:57+07:00" }, "raw_text": "Operator Association o A binary operator o is left-associated (or right-associated) when the left (or right) operator o in expression x o x o x is calculated first. For example, 9 - 5- 2= 6= 2 The operator side where the recursive term appears will determine the association of the operator For example, if ADDOP is left-associated, the grammar should be -> ADDOP if ADDOP is right-associated, the grammar should be ADDOP Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Syntax Analysis 31/37" }, { "page_index": 99, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_028.png", "page_index": 99, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:00+07:00" }, "raw_text": "Operator Precedence To priorize opterators, the left hand sides (lhs) of the rules where these operators appear should be different if operator 0 has higher priority than operator o2, 0's lhs is generated by oz's Ihs For example, - ADDOP 1 MULOP 1 - INTLIT 1 LB RB Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 32/37" }, { "page_index": 100, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_029.png", "page_index": 100, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:03+07:00" }, "raw_text": "If Statement lF THEN ELSE 1 lF THEN Draw parse tree for input lF THEN lF THEN ELSE IF THEN ELSE IF TH'EN or IF THEN IF THEN ELSE Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Syntax Analysis 33/37" }, { "page_index": 101, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_030.png", "page_index": 101, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:07+07:00" }, "raw_text": "Disambiguous grammar of if statement Natural if-statement grammar lF THEN ELSE 1 lF THEN Unambiguous if-statement grammar - lF THEN ELSE 1 lF THEN IF THEN ELSE Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 34/37" }, { "page_index": 102, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_031.png", "page_index": 102, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:10+07:00" }, "raw_text": "Declarations in grammar tools Some grammar tools has declarations to disambiguous grammar Write grammar in natural format and use declarations to disambiguous it For example,ANTLR has use option , for left- and right associativity, respectively. the order of these declarations makes the order of operator precedence Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 35/37" }, { "page_index": 103, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_032.png", "page_index": 103, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:11+07:00" }, "raw_text": "Example in ANTLR main : expr EOL r expr .. LB expr RB ADDOP expr // highest expr MULOP expr //default: left-assoc expr ADDOP expr expr '=' expr // lowest, right-assoc INT ID Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 36/37" }, { "page_index": 104, "chapter_num": 3, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_3/slide_033.png", "page_index": 104, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:13+07:00" }, "raw_text": "Summary o Context-free grammar: only one non-terminal symbol or the LHS Some issues when writing a CFG o ambiguous - dis-ambiguous o operator association : operator precedence Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Syntax Analysis 37/37" }, { "page_index": 105, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_001.png", "page_index": 105, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:14+07:00" }, "raw_text": "Object-Oriented Programming Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam 08,2016 Dr. Nguyen Hua Phung Object-Oriented Programming 1/46" }, { "page_index": 106, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_002.png", "page_index": 106, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:15+07:00" }, "raw_text": "Outline OOP Introduction Case Study: Scala Case Study: Python Dr. Nguyen Hua Phung Object-Oriented Programming 2/46" }, { "page_index": 107, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_003.png", "page_index": 107, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:17+07:00" }, "raw_text": "Object-Oriented Programming Goals Programs as collections of collaborating objects Object has public interface, hidden implementation Objects are classfied according to their behavior Objects may represent real-world entities or entities that produce services for a program o Objects may be reusable across programs Dr. Nguyen Hua Phung Object-Oriented Programming 4/46" }, { "page_index": 108, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_004.png", "page_index": 108, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:20+07:00" }, "raw_text": "ntroduction To OOP Languages There are many object-oriented programming (OOP) languages o Some are pure OOP language (e.g., Smalltalk) Newer languages do not support other paradigms but use their imperative structures (e.g., Java and Ct) Some support procedural and data-oriented programming (e.g., Ada and C++). Some support functional program (e.g., Scala) Dr. Nguyen Hua Phung Object-Oriented Programming 5/46" }, { "page_index": 109, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_005.png", "page_index": 109, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:21+07:00" }, "raw_text": "Some Important Features of OOP o Abstract data types Encapsulation Information Hiding Class Hierarchy Inheritance o Polymorphism - Dynamic Binding Dr. Nguyen Hua Phung Object-Oriented Programming 6/46" }, { "page_index": 110, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_006.png", "page_index": 110, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:23+07:00" }, "raw_text": "Data Abstraction An abstract data type is data type that satisfies the following two conditions: o Encapsulation: Attributes and operations are combined in a single syntactic unit compiled separately o Information Hiding: The access to members are controlled Reliability increased Dr. Nguyen Hua Phung Object-Oriented Programming 7/46" }, { "page_index": 111, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_007.png", "page_index": 111, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:25+07:00" }, "raw_text": "nformation Hiding 9.7 data structure internal data - operation interface operation interface data operation Dr. Nguyen Hua Phung Object-Oriented Programming 8/46" }, { "page_index": 112, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_008.png", "page_index": 112, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:27+07:00" }, "raw_text": "ADT Example Operations on a stack: Client code: create(stack) destroy(stack) create(stk1) : push(stk1, color1); empty(stack) push(stk1, color2); push(stack,element) if (! empty(stk1)) temp = top(stk1) : pop(stack) top(stack) Implementation can be adjacent or linked list. Client: don't care! Dr. Nguyen Hua Phung Object-Oriented Programming 9/46" }, { "page_index": 113, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_009.png", "page_index": 113, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:29+07:00" }, "raw_text": "Class Hierarchy A class may have some Subclasses A class may have one/many Superclass(es Animal 4 Fish Mammal WingedAnimal 4 Whale Dog Cat Bat Dr. Nguyen Hua Phung Object-Oriented Programming 10/46" }, { "page_index": 114, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_010.png", "page_index": 114, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:31+07:00" }, "raw_text": "nheritance A subclass is able to inherit non-private members of its superclasses A subclass can add its own members and override its inherited members Single vs. multiple inheritance Inheritance increases the reusability in OOP Dr. Nguyen Hua Phung Object-Oriented Programming 11/46" }, { "page_index": 115, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_011.png", "page_index": 115, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:32+07:00" }, "raw_text": "Example of Inheritance x,y Point draw() move(newX,newY) 4 radius Circle draw() Dr. Nguyen Hua Phung Object-Oriented Programming 12/46" }, { "page_index": 116, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_012.png", "page_index": 116, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:34+07:00" }, "raw_text": "Diamond Problem in Multiple Inheritance A B C D if D inherits from B and C different versions of the same behaviour, which version will be effective in D? this problem, called diamond problem, is solved differently in different OO language is there the diamond problem in Java? Dr. Nguyen Hua Phung Object-Oriented Programming 13/46" }, { "page_index": 117, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_013.png", "page_index": 117, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:37+07:00" }, "raw_text": "Class vs. Object; Method vs. Message Class vs. Object o A class defines the abstract characteristics of a thing o its attributes or properties and o its behaviors or methods or features A Dog has fur and is able to bark An object is a particular instance of a class. Lassie is a dog Method vs. Message o A method describes a behavior of an object. A dog can bark A message is a process at which a method of an object is invoked. Lassie barks Dr. Nguyen Hua Phung Object-Oriented Programming 14/46" }, { "page_index": 118, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_014.png", "page_index": 118, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:39+07:00" }, "raw_text": "Polymorphism Polymorphism: different objects can respond to the same message in different ways. x,y Point draw() radius Circle draw( p.draw() o Dynamic binding Dr. Nguyen Hua Phung Object-Oriented Programming 15/46" }, { "page_index": 119, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_015.png", "page_index": 119, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:42+07:00" }, "raw_text": "Other Concepts There are two kinds of variables in a class: o Class variables Instance variables o There are two kinds of methods in a class: Class methods - accept messages to the class Instance methods - accept messages to objects Abstract class vs. Concrete class: Abstract Class - no instance Concrete Class - able to have its instances Dr. Nguyen Hua Phung Object-Oriented Programming 16/46" }, { "page_index": 120, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_016.png", "page_index": 120, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:43+07:00" }, "raw_text": "Scala Programming Language Invented by Martin Ordesky at EPFL, Lausanne, Switzerland. EScala Similar to Java Work smoothly with Java Run on Java Virtual Machine OOP + FP Include lexer and parser generator Dr. Nguyen Hua Phung Object-Oriented Programming 18/46" }, { "page_index": 121, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_017.png", "page_index": 121, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:45+07:00" }, "raw_text": "Classes and Objects in Scala Class class [1] abstract class [5] trait [2] case class [3] Object new object Dr. Nguyen Hua Phung Object-Oriented Programming 19/46" }, { "page_index": 122, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_018.png", "page_index": 122, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:48+07:00" }, "raw_text": "Example [7] class Rational(n:Int , d: Int){ require(d != 0) private val g = gcd(n.abs, d.abs) private def gcd(a: Int , b: Int): Int = if (b == 0) a eIse gcd(b, a % b) val numer = n g val denom = d / g g def this(n: Int) = this(n, 1) def + (that : Rational): Rational : new Rational( numer * that.denom + that.numer * denom, denom * that.denom override def toString = numer +\"/\"+ denom 1 Dr. Nguyen Hua Phung Object-Oriented Programming 20/46" }, { "page_index": 123, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_019.png", "page_index": 123, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:51+07:00" }, "raw_text": "Example on Abstract class [4] abstract class Element { def contents : Array[String] //no body: abstract val height = contents.length val width = if (height == 0) 0 else contents(0).length 1 class ArrayElement(conts : Array [ String ]) extends Element { def contents : Array[String] = conts 1 class LineElement(s : String) extends ArrayElement(Array(s) { override def width = s.length override def height = 1 1 Dr. Nguyen Hua Phung Object-Oriented Programming 21/46" }, { "page_index": 124, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_020.png", "page_index": 124, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:53+07:00" }, "raw_text": "Example on Object [1] object Element { def elem(contents : Array[ String D) : Element = new ArrayElement(contents) def elem(line : String ) : Element = new LineElement(line) 1 val space = Element.elem(\" \" val hello = Element.elem(Array(\"hello\",\"world\")) Which kind of Element will be assigned to space and hello? Dr. Nguyen Hua Phung Object-Oriented Programming 22/46" }, { "page_index": 125, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_021.png", "page_index": 125, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:56+07:00" }, "raw_text": "Example on Case Class [3] abstract class Expr case class Var(name: String) extends Expr case class Number(num: Double) extends Expr case class UnOp(operator : String , arg : Expr) extends Expr case class BinOp(operator : String : Ieft : Expr, right : Expr) extends Expr val v = Var(\"x\") val op = BinOp(\"+\", Number(1), v) v.name op.left Dr. Nguyen Hua Phung Object-Oriented Programming 23/46" }, { "page_index": 126, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_022.png", "page_index": 126, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:19:59+07:00" }, "raw_text": "Example 1 on Traits [9 Reusability: abstract class Bird trait Flying { def flyMess: String def fly() = println(flyMess) 1 trait Swimming { def swim0 = printIn (\"I'm swimming\") 1 class Penguin extends Bird with Swimming class Hawk extends Bird with Swimming with Flying { val flyMess = \"I'm a good fIyer\" 1 class Frigatebird extends Bird with Flying { val flyMess = \"I'm an excellent fIyer\" 1 Dr. Nguyen Hua Phung Object-Oriented Programming 24/46" }, { "page_index": 127, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_023.png", "page_index": 127, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:02+07:00" }, "raw_text": "Example 2 on Traits [2] Stackable Modifications: abstract class IntQueue { def getO: Int def put(x: Int):Unit} class BasiclntQueue extends IntQueue private val buf = new ArrayBuffer[Int] def get( = buf.remove(0) def put(x: Int):Unit= { buf += x }} trait Doubling extends IntQueue { abstract override def put(x:Int {super.put(2*x)}} trait Incrementing extends IntQueue { abstract override def put(x:Int) {super.put(x+1)}} val queue = new BasiclntQueue with Incrementing with Doubling queue.put(10) queue.getO //??? Trait Linearization: Doubling-> Incrementing-> BasiclntQueue-> IntQueue-> AnyRef-> Any Dr. Nguyen Hua Phung Object-Oriented Programming 25/46" }, { "page_index": 128, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_024.png", "page_index": 128, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:04+07:00" }, "raw_text": "Trait Linearization: Resolving Diamond Problem in Scala A class extends just a single class but is able to have many \"with\" traits If these traits have the same method, which method is inherited Solution in Scala: Trait linearization Take the first extended trait/class and write its complete inherited hierarchy in vertical form, store this hierarchy as X Take the next trait/class after the with clause, write its complete hierarchy and cancel the classes or traits that are repeated in hierarchy X. Add the remaining traits/classes to the front of the hierarchy X. Go to step 2 and repeat the process, until no trait/class is left out. Place the class itself in front of hierarchy as head for which the hierarchy is being written. Dr. Nguyen Hua Phung Object-Oriented Programming 26/46" }, { "page_index": 129, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_025.png", "page_index": 129, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:07+07:00" }, "raw_text": "Example on Trait Linearization trait A { def name: String trait B extends A { override def name: String =\"class b\" 1 trait C extends A { override def name: String =\"class c\" 1 class D extends B with C {} var class d = new D println(class_d.name) B: B->A->AnyRef->Any o C: C->A->AnyRef->Any C->B->A->AnyRef->Any o D: D->C->B->A->AnyRef->Any Dr. Nguyen Hua Phung Object-Oriented Programming 27/46" }, { "page_index": 130, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_026.png", "page_index": 130, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:10+07:00" }, "raw_text": "Scala Hierarchy [8] Subtype View aia.Anyw scala.AnyFie caia.Doubi scala.Unit acain.Ficat scala.Boolea java.lang.String acala.Cha scala.Liat scala.in scala.Option ..(otherScalaclasses.. acaia.Dyte la.Nul Dr. Nguyen Hua Phung Object-Oriented Programming 28/46" }, { "page_index": 131, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_027.png", "page_index": 131, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:11+07:00" }, "raw_text": "Access Modifiers [6] in Scala protected private protected[] private[] Example, package Assignment protected[Assignment] val field1 = 100 private[this] val field2 = 2; Dr. Nguyen Hua Phung Object-Oriented Programming 29/46" }, { "page_index": 132, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_028.png", "page_index": 132, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:13+07:00" }, "raw_text": "OOP in Python Class vs. Object Instance vs. static fields Instance, Class, Static methods Encapsulation Inheritance Polymorphism Dr. Nguyen Hua Phung Object-Oriented Programming 31/46" }, { "page_index": 133, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_029.png", "page_index": 133, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:16+07:00" }, "raw_text": "Class vs. Object Class is a user-defined prototype for an obiect class : => Clsname: name of the class ' Optional. class. .documentation, string => fields, methods Object: an instance of the class class Employee : Common_baseclassforallemployees empCount = 0 => empCount: static field def init ( self ,n,s) :=>constructor self.name = n =>name: instance fiela self.salary = s =>salary: instance field Employee .empCount += 1 obj = Employee(\"Nam\",30) => create object Dr. Nguyen Hua Phung Object-Oriented Programming 32/46" }, { "page_index": 134, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_030.png", "page_index": 134, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:18+07:00" }, "raw_text": "nstance Methods Instance Method: method belongs to the instance class Employee : def displayEmployee( self ) : =>firstparam- eter for instance print( \"Name,:-\", self .name, , Salary : \", self.salary T1 obj = Employee(\"Nam\",30) obj.displayEmployee ( =>obj is passed to self able to access to instance fields through first parameter and : => self.name able to access to static field through class name and : => Employee.empCount Dr. Nguyen Hua Phung Object-Oriented Programming 33/46" }, { "page_index": 135, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_031.png", "page_index": 135, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:22+07:00" }, "raw_text": "Class and Static Methods class Employee : @classmethod =>to define class methoa def create(cls,n,s): =>first parameter for class print( cls . empCount) =>access to static fields return cls(n,s) @staticmethod =>to define static methoa def isHighSal(s): =>no parameter for class if s > 8: =>unable to access any fields print(\"High_Salary\") obj = Employee.create(\"Nam\",30) =>Employeeis passed to cls Employee.isHighSal(30 =>Employee is used to re- solve Dr. Nguyen Hua Phung Object-Oriented Programming 34/46" }, { "page_index": 136, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_032.png", "page_index": 136, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:23+07:00" }, "raw_text": "nformation Hiding to hide fields and methods based on name ot tields and methods Protected: prefix by a single underscore (_example) Private: prefix by a double underscores (_example) o Public: begin with a letter Dr. Nguyen Hua Phung Object-Oriented Programming 35/46" }, { "page_index": 137, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_033.png", "page_index": 137, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:25+07:00" }, "raw_text": "Class Hierarchy Python 3: root is object Multiple Inheritance class ((,)*)?: For example, class A : => superclass is object class Rectangle(Parallelogram) : => superclass is Parallelogram class Square(Rhombus, Rectangle ) : => superclasses are Rhombus and Rectangle Dr. Nguyen Hua Phung Object-Oriented Programming 36/46" }, { "page_index": 138, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_034.png", "page_index": 138, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:27+07:00" }, "raw_text": "Inheritance Subclass inherits non-private fields and methods from super-classes Diamond problem A B C D Method Resolution Order: determine search sequence of a class Dr. Nguyen Hua Phung Object-Oriented Programming 37/46" }, { "page_index": 139, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_035.png", "page_index": 139, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:30+07:00" }, "raw_text": "Method Resolution Order (MRO) MRO is used to determine search sequence L(M) of class M o L(object) = [object] o L(M(A,B,C)) = [M] + merge(L(A),L(B),L(C),[A,B,C] merge([H171],[H272],[H373] o Step 1: if H1 is a good head which is NOT in the tail of other lists, take H out as an output, remove H out of all lists, back to Step 1. Step 2: if H1 is not a good head, check if H2 is a good head. If it is, apply Step1 for H2. If it is not, check for Ha and so on. If there is no good head, give an error. Dr. Nguyen Hua Phung Object-Oriented Programming 38/46" }, { "page_index": 140, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_036.png", "page_index": 140, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:33+07:00" }, "raw_text": "Example A . B(A) C(A) D(B,C) L(A) =[A,object] L(B) = [B] + merge(L(A),[A]) = [B,A,object] L(C) = [C] + merge(L(A),[A]) = [C,A,object] L(D) = [D]+merge(L(B),L(C),[B,C]) = [D,B,C,A,object] merge([B,A,o],[C,A,o],[B,C1) => o B is a good head => [B]+merge([A,o],[C,A,o],[C] o A is NOT a good head, check C, and C is a good head => [B,C] + merge([A,o],[A,o],[]) A is a good head => [B,C,A] + merge([o],[o],[] o o is a good head => [B,C,A,o] Dr. Nguyen Hua Phung Object-Oriented Programming 39/46" }, { "page_index": 141, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_037.png", "page_index": 141, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:35+07:00" }, "raw_text": "super, isinstance, type super0 => refer to the superclass class A: def foo(self,x): 2 3 print(x) class B(A) : 4 def foo(self,x) : 5 super.foo(x) 6 B(O.foo(3) =>3 isinstance(o,T) => check if object o is of type T class A: pass class B(A): pass x = B(O) isinstance(x,B) => Trueisinstance(x,A) => Truetype(x) is B => Truetype(x) is A => False type(o) => return the type of object o Dr. Nguyen Hua Phung Object-Oriented Programming 40/46" }, { "page_index": 142, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_038.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_038.png", "page_index": 142, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:39+07:00" }, "raw_text": "Polymorphism Overloading: def func(param1,param2=0) : pass func(1,2) func(\"asbc\") o Universal Polymorphism: Parametric Polymorphism Subtyping Polymorphism class A: class A: def func1(self): def func1(self): print(\"A\") print(\"A\") def func2(self): pass def func2(self): pass class B: class B(A) : def func1(self): def func1(self): print(\"B\") print(\"B\") for x in [AO,BO]: for x in [AO,BO]: x.func1O) x.func10) x.func20 x.func20) Dr. Nguyen Hua Phung Object-Oriented Programming 41/46" }, { "page_index": 143, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_039.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_039.png", "page_index": 143, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:42+07:00" }, "raw_text": "Some other issues id0: address of the specified object x,y,z = 3,3,4 id(x) => address of object 3 which x points to id(y) => same above address => x, y -> same object id(z) => z points to different object is vs. == o is: True just when they are same object ==: True even when they are different obiects but their attributes are equal x,y = [1,2,3],[1,2,3] x is y => False id(x) == id(y) => False x == y=> True Dr. Nguyen Hua Phung Object-Oriented Programming 42/46" }, { "page_index": 144, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_040.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_040.png", "page_index": 144, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:44+07:00" }, "raw_text": "Some other issues o Context manager by with statement with as : must return an obiect which has enter and exit methods The with statement is executed like: = .__enter_0 ..exit_0 exit method is always executed before the control goes out of the used for managing resources: file, database,.. with open('abc.txt','r') as f: print(f.read0) f.closed => True Dr. Nguyen Hua Phung Object-Oriented Programming 43/46" }, { "page_index": 145, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_041.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_041.png", "page_index": 145, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:45+07:00" }, "raw_text": "Summary What are still in your mind? Dr. Nguyen Hua Phung Object-Oriented Programming 44/46" }, { "page_index": 146, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_042.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_042.png", "page_index": 146, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:48+07:00" }, "raw_text": "References I [1] Classes and Objects, http://www.artima.com/pins1ed/ classes-and-objects.html,19 062014. [2] Traits,http://www.artima.com/pinsled/traits.html, 19 06 2014. [3] Case Class and Pattern Matching, http://www.artima. com/ pinsled/case-classes-and-pattern-matching.html, 19 06 2014. [4] Abstract Members, http: //www.artima.com/pinsled/abstract-members.html 19 06 2014. [5] Compositions and Inheritance, http://www.artima. com/ pinsled/composition-and-inheritance.html,19 06 2014. [6] Packages and Imports, http://www.artima.com/pins1ed/ packages-and-imports.html, 19 062014. Dr. Nguyen Hua Phung Object-Oriented Programming 45/46" }, { "page_index": 147, "chapter_num": 4, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_043.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_4/slide_043.png", "page_index": 147, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:52+07:00" }, "raw_text": "References Il [7] Functional Objects, http://www.artima.com/pins1ed/ functional-objects.html,19 062014. [8] Scala Hierarchy, http : //www.artima.com/pinsled/scalas-hierarchy.html 19 062014. [9] Learning Scala part seven -Traits, http:// joelabrahamsson. com/learning-scala-part-seven-traits/,19 062014. [10] Object-Oriented Programming in Python 3, https://realpython.com/ python3-object-oriented-programming/, 01-10-2020 [11] Python - Object-Oriented, https ://realpython. com/ python3-object-oriented-programming/, 01-10-2020 [12] The Python 2.3 Method Resolution Order, https : //www.python.org/download/releases/2.3/mro/, 01-10-2020. Dr. Nguyen Hua Phung Object-Oriented Programming 46/46" }, { "page_index": 148, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_001.png", "page_index": 148, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:53+07:00" }, "raw_text": "Functional Programming Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam 10,2020 Dr. Nguyen Hua Phung Functional Programming 1/33" }, { "page_index": 149, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_002.png", "page_index": 149, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:54+07:00" }, "raw_text": "Outline FP Introduction Higher-order Functions Immutability Case Study: Python Dr. Nguyen Hua Phung Functional Programming 2/33" }, { "page_index": 150, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_003.png", "page_index": 150, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:56+07:00" }, "raw_text": "Functional Programming Function are values, i.e., a function can be Value Function Anonymous 3 X =>x + 1 Assigned to a variable X = 3 f = x => x + 1 Passed as input/output f(3) f(x => x + 1) parameter 3 + 4 f o g Created dynamically Dr. Nguyen Hua Phung Functional Programming 4/33" }, { "page_index": 151, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_004.png", "page_index": 151, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:20:59+07:00" }, "raw_text": "Fundamental Theory Imperative languages => Von Neumann Architecture o Efficiency o Functional languages => Lambda Calculus o A solid theoretical basis that is also closer to the user, but relatively unconcerned with the architecture of the machines on which programs will rur Dr. Nguyen Hua Phung Functional Programming 5/33" }, { "page_index": 152, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_005.png", "page_index": 152, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:01+07:00" }, "raw_text": "Mathematical Functions o A mathematical function is a mapping of members of one set, called the domain set, to another set, called the range set A lambda expression specifies the parameter(s) and an expression in the following form to express an anonymous function A(x) x * x * x like the function cube cube(x) = x * x * x o Lambda expressions are applied to parameter(s) by placing the parameter(s) after the expression ((x) x * x * x)(2) which evaluates to 8 Dr. Nguyen Hua Phung Functional Programming 6/33" }, { "page_index": 153, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_006.png", "page_index": 153, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:03+07:00" }, "raw_text": "Higher-order Functions o A higher-order function is one that either takes functions as parameters or yields a function as its result, or both o For example, o Function composition o Apply-to-all Forall/Exists Insert-left/Insert-right Functions as parameters Closures Dr. Nguyen Hua Phung Functional Programming 8/33" }, { "page_index": 154, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_007.png", "page_index": 154, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:06+07:00" }, "raw_text": "Function Composition A function that takes two functions as parameters and yields a function whose value is the first actual parameter function applied to the application of the second f o g = f : (g : x) For f(x) = x + 2; g(x) = x * x; f o g (x)= x * x + 2 Example in Scala, val (x:Double) => x + 2 val g= (x:Double) => x * x val h = f compose g h(3) val k = f andThen k(3) Dr. Nguyen Hua Phung Functional Programming 9/33" }, { "page_index": 155, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_008.png", "page_index": 155, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:09+07:00" }, "raw_text": "Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained by applying the given function to each element of a list of parameters af :< X1,X2, ...,Xn >=< f : X1, f : X2, ..., f : X2 > For h(x)=x*x => ah:(1,2,3) yields (1,4,9) Example in Scala, List(2,3,4) .map((x:Int) => x * x def inc (x:Int) = x + 1 List(4,5,6).map(inc) Dr. Nguyen Hua Phung Functional Programming 10/33" }, { "page_index": 156, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_009.png", "page_index": 156, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:11+07:00" }, "raw_text": "Forall/Exists A functional form that o takes a single predicate function as a parameter and yields a value obtained by applying the given function to each element of a list of parameters and take the and/or of the results Vf :< x1,X2,..,Xn >=Nf:Xj 3f :< X1,X2,i.,Xn >=Uf : Xj Example in Scala, def isEqualToThree(x:Int) = x == 3 List(2,3,4) .forall(isEqualToThree) // yield false List(2,3,4) .exists(isEqualToThree // yield true Dr. Nguyen Hua Phung Functional Programming 11/33" }, { "page_index": 157, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_010.png", "page_index": 157, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:12+07:00" }, "raw_text": "Filter A functional form that o takes a single predicate function as a parameter and yields a value that includes elements from the list parameter on which the given function returns true Bf :< X1,X2,.,Xn >=< xif : Xi= T > Dr. Nguyen Hua Phung Functional Programming 12/33" }, { "page_index": 158, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_011.png", "page_index": 158, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:14+07:00" }, "raw_text": "nsert Left / Insert Right /f :< Xo >,< X1,X2,...,Xn > f :< Xo >,< X1,X2,...,Xn > f f Xn X1 f f f X2 Xn-1 f X0 X1 Xn X0 Dr. Nguyen Hua Phung Functional Programming 13/33" }, { "page_index": 159, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_012.png", "page_index": 159, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:17+07:00" }, "raw_text": "nsert Left / Insert Right (cont'd) Example in Scala List(2,3,4) .foldLeft(0) ((a,b => a+b) // yield 9 List(2,3,4) .foldLeft(1) ((a,b) => a*b /7 j yield 24 List(2,3,4) .foldLeft(\"A\") ((a,b) => a + b)) // yield \"A234\" List(2,3,4) .foldRight(\"A\") ((a,b => a + b // yield \"234A\" Dr. Nguyen Hua Phung Functional Programming 14/33" }, { "page_index": 160, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_013.png", "page_index": 160, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:20+07:00" }, "raw_text": "Functions as Parameters In user-defined functions, functions can be passed as parameters. def apply(x:Int)(f:Int=>Int = f(x) val inc1 = (x:Int) => x + 1 val s sq = (x:Int) => x * x val fl = List(incl,sq fl.map(apply(3) //yield List(4,9) Dr. Nguyen Hua Phung Functional Programming 16/33" }, { "page_index": 161, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_014.png", "page_index": 161, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:22+07:00" }, "raw_text": "Closure [1] \"An object is data with functions. A closure is a function with data.\" - John D. Cook def power(exp:Double = (x:Double :) => math.pow(x,exp) val square = power(2) square(4 //yield 16.0 val cube = power(3) cube(3 //yield 27.0 Closure = function + binding of its free variables Dr. Nguyen Hua Phung Functional Programming 17/33" }, { "page_index": 162, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_015.png", "page_index": 162, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:24+07:00" }, "raw_text": "Currying functions [2 f:X1 x X x...x Xn -yY curry: f : X1 -? X2 -...-> Xn -> Y Example in Scala def add(x:Int, y:Int) = x + Y add(1,3) add(1 add(1) (3) def plus(x:Int) (y:Int) = x + Y plus(1) (3) val incl = plus(l) - inc1(3) val addCurried = (add ) .curried val plusUncurried = Function.uncurried(plus -) Read more on Partially Applied Functions [2] Dr. Nguyen Hua Phung Functional Programming 18/33" }, { "page_index": 163, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_016.png", "page_index": 163, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:26+07:00" }, "raw_text": "Immutability Immutable: Cannot change In Java, strings are immutable \"Hello\".toUpper0 doesn't change \"Hello\" but returns a new string \"HELLO\" In Scala, val is immutable val num = 12 num = 10 // wrong Pure functional programming: No mutations Don't mutate-always return the result as a new value Functions that don't mutate state are inherently parallelizable Dr. Nguyen Hua Phung Functional Programming 20/33" }, { "page_index": 164, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_017.png", "page_index": 164, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:30+07:00" }, "raw_text": "Example on Immutability abstract class IntStack def push(x: Int) : IntStack = new IntNonEmptyStack(x, this def isEmpty: Boolean def top: Int def pop: IntStack class StackEmpty extends IntStack def isEmpty = true def top = error(\"EmptyStack.top\") def l pop = error(\"EmptyStack.pop\") class IntNonEmptyStack(elem: Int, rest: IntStack) extends IntStack def isEmpty = false def top = elem def pop = rest Dr. Nguyen Hua Phung Functional Programming 21/33" }, { "page_index": 165, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_018.png", "page_index": 165, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:31+07:00" }, "raw_text": "Functional Programming Immutable Data Structures lambda function First-class functions High-order functions: map, filter, reduce Closure Decorator Dr. Nguyen Hua Phung Functional Programming 23/33" }, { "page_index": 166, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_019.png", "page_index": 166, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:33+07:00" }, "raw_text": "Functional Programming This is a style of programming that avoids side effects by performing computation o through the evaluation of pure functions : relying heavily on immutable data structures Benefits of functional programming: o Pure functions are easier to reason about Testing is easier Debugging is easier Programs are more bulletproof Parallel/Concurrent programming is easier Dr. Nguyen Hua Phung Functional Programming 24/33" }, { "page_index": 167, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_020.png", "page_index": 167, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:35+07:00" }, "raw_text": "mmutable Data Structures o Apply immutable data types in Python o Number (int,float,complex) Boolean (bool) String (str) Sequence (tuple, range) (1,'a',True) Set (frozenset) x = frozenset({1'a',True}) Mapping (collections.namedtuple) Student = collections.namedtuple('Student',['name','age'] x = Student('Vinh',14) x.name Apply immutable operations on mutable data types o + instead of extend0 [1,2,3] + [4,5] Dr. Nguyen Hua Phung Functional Programming 25/33" }, { "page_index": 168, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_021.png", "page_index": 168, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:38+07:00" }, "raw_text": "Lambda tunction : Syntax: lambda ((, For example, lambda a,b: a + b (lambda a,b: a + b) (3,4) => 7 x = lambda a,b: a + b x(3,4 => 7) Anonymous function Any number of parameters Body is just one expression Used in high-order functions Dr. Nguyen Hua Phung Functional Programming 26/33" }, { "page_index": 169, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_022.png", "page_index": 169, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:41+07:00" }, "raw_text": "First-class function o A function is treated as any other value, i.e. it is o assigned to a variable def foo(a,b) : pass x = foo x(3,4) passed into another function as a parameter def foo(f,x): return f(x) foo(lambda a: a ** 2, 4) => 16 o returned as a value def f(x) : def g(y) : return x * y return m = f(3) m(4 => 12 Dr. Nguyen Hua Phung Functional Programming 27/33" }, { "page_index": 170, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_023.png", "page_index": 170, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:44+07:00" }, "raw_text": "High-order functions: map, filter, reduce map(,): apply to each element of and return an iterator cels = [36.5, 37, 37.5, 38, 39] fahr = list(map(lambda c: (float(9 / 5 * c) + 32,cels) => [97.7, 98.6, 99.5, 100.4, 102.2]1ist(map(1am x,y: : x + y,[1,2,3],[4,5,6,7]) => [5,7,9] filter(,) return an iterator that contains elements in for which returns True list(filter(lambda c: c % 2 == 1,[0,1,2,3,4,5 [1,3,5] reduce(,G)?): if is [s1,s2,s3], reduce return function(function(s1,s2),s3) or function(function(function(,s1),s2),ss from functools import reduce Dr. Nguyen Hua Phung Functional Programming 28/33" }, { "page_index": 171, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_024.png", "page_index": 171, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:45+07:00" }, "raw_text": "Closure o Closure is a function object together with an environment (binding ot its free data) def power(y) : def inner(x) : return x ** y return inner square= power(2 square(5 => 25 Dr. Nguyen Hua Phung Functional Programming 29/33" }, { "page_index": 172, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_025.png", "page_index": 172, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:47+07:00" }, "raw_text": "Decorator o Decorator allows to modify the behavior of function or class without permanently modifying it. @log decorator def foo(x,y) : def foo(x,y) : return x*y return x*y foo = log_decorator(foo) print(foo(3,4) => 12 print(foo(3,4)) deflog_decorator(func) : def inner(*arg) : print(func._ name_ +\" is running\") return func(*arg) return inner Dr. Nguyen Hua Phung Functional Programming 30/33" }, { "page_index": 173, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_026.png", "page_index": 173, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:50+07:00" }, "raw_text": "Summary Functional programming languages use function application, conditional expressions, recursion, and functional forms to control program execution instead of imperative features such as variables and assignments Purely functional languages have advantages over imperative alternatives, but their lower efficiency on existing machine architectures has prevented them from enjoying widespread use Dr. Nguyen Hua Phung Functional Programming 31/33" }, { "page_index": 174, "chapter_num": 5, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_5/slide_027.png", "page_index": 174, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:52+07:00" }, "raw_text": "References I [1] Methods and Closures, http://www.artima.com/pins1ed/ functions-and-closures.html,19 062014. [2] Function Currying in Scala, http://www.codecommit.com/ blog/scala/function-currying-in-scala, 19 062014. [3] Case classes and pattern matching. http://www.artima.com/pinsled/ case-classes-and-pattern-matching.html, 19 062014. [4] Control Abstraction, http://www.artima.com/pins1ed/ control-abstraction.html,19 062014. Dr. Nguyen Hua Phung Functional Programming 32/33" }, { "page_index": 175, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_001.png", "page_index": 175, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:53+07:00" }, "raw_text": "Abstract Syntax Tree Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn HCMC University of Technology, Viet Nam October 23, 2020 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 1/26" }, { "page_index": 176, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_002.png", "page_index": 176, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:21:56+07:00" }, "raw_text": "Abstract Syntax Tree (AST) Definition o tree representation of the abtract syntax structure of source code. o differ from concrete syntax tree (parse tree) by some details ignored o help subsequence phases not depend on parse process Parse Tree IF THEN ELSE AST Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Abstract Syntax Tree 3/26" }, { "page_index": 177, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_003.png", "page_index": 177, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:00+07:00" }, "raw_text": "Example exp exp + term term term term * factfact fact - (exp)lIDN 4 * (5 + 3) 4 5 3 N(4) + N(5) N(3) Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 4/26" }, { "page_index": 178, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_004.png", "page_index": 178, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:03+07:00" }, "raw_text": "AST for an expression in Scala Expression AST trait Exp case class BinExp(op:String,e1:Exp,e2:Exp) extends Exp case class UnaExp(op:String,e:Exp) extends Exp case class Lit(i:Int) extends Exp 4 * (5 + 3) BinExp e1 e2 Lit BinExp e1 e2 4 + 4 Lit + Lit 3 5 3 5 BinExp(\"*\",Lit(4),BinExp(\"+\",Lit(5),Lit(3))) Dr. Nguyen Hua Phung nhphung@hcmut Abstract Syntax Tree 5/26" }, { "page_index": 179, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_005.png", "page_index": 179, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:06+07:00" }, "raw_text": "Generated Classes by ANTLR A grammar => a class A nonterminal => an inner class grammar MC; class MCParser { prog 1 : stmt+ : class ProgContext stmt : assign l ifstmt : assign : ID ASSIGN exp SEMI ; class StmtContext ifstmt: IF exp THEN stmt class AssignContext ELSE stmt ; class IfstmtContext exp class ExpContext : term (ADDOP term)*; class TermContext term : ID 1 INTLIT } l LP exp RP ; Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Abstract Syntax Tree 8/26" }, { "page_index": 180, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_006.png", "page_index": 180, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:10+07:00" }, "raw_text": "Example a=a+4 : ProgContext StmtContext grammar MC; prog : stmt+ : stmt : assign 1 ifstmt ; AssignContext assign : ID ASSIGN exp SEMI ; ifstmt: IF exp THEN stmt ELSE stmt ; ID ASSlGN ExpContext SEMI exp : term (ADDOP term)+ term : ID I INTLIT 1 LP exp RP ; TermContext ADDOP TermContext ID INTLIT Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 9/26" }, { "page_index": 181, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_007.png", "page_index": 181, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:12+07:00" }, "raw_text": "Access Children on Parse Tree Each symbol on RHS => one or two methods in the inner class class AssignContext { TerminalNode IDO {...} assign : ID ASSIGN exp SEMI ; TerminaINode ASSIGNO {:::} ExpContext exp0 {...} TerminalNode SEMI { . : : class StmtContext { stmt: assign l ifstmt : AssignContext assignO {. IfsmtContext ifstmtO {.::} Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 10/26" }, { "page_index": 182, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_008.png", "page_index": 182, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:14+07:00" }, "raw_text": "Multiple Appearance of Symbol in RHS Same symbol appears many times in RHS => 2 methods class IfstmtContext { List stmtO) ifstmt : IF exp THEN stmt StmtContext stmt(int i {...} ELSE stmt ; ExpContext exp( {...} TerminaINode IF O{...} class ProgContext { prog : stmt+ : List stmtO {...} StmtContext stmt(int i) {...} Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Abstract Syntax Tree 12/26" }, { "page_index": 183, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_009.png", "page_index": 183, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:15+07:00" }, "raw_text": "Some useful methods RuleContext getChild(int i): ith child if (assign(!=null) stmt : assign //do something on assign( else ifstmt ; //do same thing on ifstmt( //do something on getChild(0) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 14/26" }, { "page_index": 184, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_010.png", "page_index": 184, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:17+07:00" }, "raw_text": "Some useful methods int getChildCountO: number of children if (getChildCount( == 3 term : ID //do something on exp( INTLIT else LP exp RP; //do something on getChild(0 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 15/26" }, { "page_index": 185, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_011.png", "page_index": 185, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:19+07:00" }, "raw_text": "Visitor Generated by ANTLR Use option -visitor Method accept generated in each inner class +Visitor.java and +BaseVisitor.java generated grammar MC; => MCVisitor.java;MCBaseVisitor.java Each nonterminal symbol a => visitA(ctx:AContext) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 16/26" }, { "page_index": 186, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_012.png", "page_index": 186, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:22+07:00" }, "raw_text": "Example: MCVisitor interface MCVisitor extends ParseTreeVisitor T visitProg(MCParser.ProgContext ctx); T visitStmt (MCParser. StmtContext ctx) ; visitAssign(MCParser.AssignContext ctx); visitIfstmt (MCParser.IfstmtContext ctx) ; visitExp(MCParser.ExpContext ctx) : T visitTerm (MCParser.TermContext ctx ) ; 1 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 17/26" }, { "page_index": 187, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_013.png", "page_index": 187, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:24+07:00" }, "raw_text": "Example: In2Pos in Scala /* term: 1D 1 1NTL1T 1 LP exp RP*/ override def visitTerm(ctx :TermContext) = if (ctx.getChildCount( == 3) ctx.expO.accept(this) else ctx.getChild(0).getText /*exp: term (ADDOP term)* */ override def visitExp(ctx:ExpContext) = { val 1en = ctx.ADDOP.size(O var res = ctx.term(o).accept(this) for (i <- 1 to len) res = res + \" + ctx.term(i).accept(this) + . ctx.ADDOP(i -1).getText res Dr. Nguyen Hua Phung nhphung@hcmut .edu.vn Abstract Syntax Tree 18/26" }, { "page_index": 188, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_014.png", "page_index": 188, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:27+07:00" }, "raw_text": "Naming Right Hand Size To distinguish RHS, naming all RHS of a nonterminal exp: ID #ident visitldent(ctx:ldentContext) INTLIT #Iit visitLit(ctx:LitContext) LP exp RP #pexp visitPexp(ctx :PexpContext) exp ADD exp #addexp visitAddexp(ctx :AddexpContext) exp MUL exp #mulexp visitMulexp(ctx :MulExpContext) There is no visitExp anymore Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 19/26" }, { "page_index": 189, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_015.png", "page_index": 189, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:30+07:00" }, "raw_text": "AST for MC trait AST case class Prog(sl:List[Stmt]) extends AST trait Stmt extends AST case class Assign(id:String,e:Exp) extends Stmt case class IfStmt(e:Exp,s1 :Stmt,s2:Stmt) extends Stmt trait Exp extends AST case class BinOp(op:String,e1:Exp,e2:Exp) extends Exp case class ld(id:String) extends Exp case class Intlit(lit:Int) extends Exp Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 20/26" }, { "page_index": 190, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_016.png", "page_index": 190, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:31+07:00" }, "raw_text": "AST Generation Visitor /* term: 1D 1 1NTL1T 1 LP exp RP*/ override def visitTerm(ctx :TermContext) = if (ctx.getChildCount( == 3) ctx.expO.accept(this) else if (ctx.lD != null ld(ctx.ID.getText) else IntIit (ctx.INTLIT.getText.tolnt) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 21/26" }, { "page_index": 191, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_017.png", "page_index": 191, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:34+07:00" }, "raw_text": "AST Generation Visitor (cont) /* exp: term (ADDOP term)* */ /* case class BinOp(op:String,e1:Exp,e2:Exp extends Exp override def visitExp(ctx:ExpContext) = { val len = ctx.ADDOP.size() var res = c ctx.term(o).accept(this) for (i <- 1 to Ien) res = BinOp( ctx.ADDOP(i -1).getText, res.aslnstanceOf[Exp] ctx.term(i).accept(this).aslnstanceOf[Exp] res 3 + 4 - 5 => res = IntLit(3) res = BinOp(\"+\",IntLit(3),IntLit(4)) res = BinOp(\"-\",BinOp(\"+\",IntLit(3),IntLit(4)),IntLit(5)) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 22/26" }, { "page_index": 192, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_018.png", "page_index": 192, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:36+07:00" }, "raw_text": "AST Generation Visitor in Python /* term: 1D l 1NTL1T 1 LP exp RP*/ def visitTerm(self,ctx): if ctx.getChildCountO == 3: return ctx.expQ. accept(self) elif ctx.ID(): return Id(ctx.IDO.getText()) else : return IntLit(int(ctx.INTLITO.getTextO)) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 23/26" }, { "page_index": 193, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_019.png", "page_index": 193, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:38+07:00" }, "raw_text": "AST Generation Visitor in Python(cont /*exp: term (ADDOP term)* */ /* class BinOp(Exp): #op:String,e1:Exp,e2:Exp */ def visitExp(self,ctx): addsize = len(ctx.ADDOPO) res = ctx.term(o).accept(self) for i in range(1,addsize+1): res = BinOp( ctx.ADDOP(i-1).getText( res, ctx.term(i).accept(self)) return res Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 24/26" }, { "page_index": 194, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_020.png", "page_index": 194, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:41+07:00" }, "raw_text": "AST Generation Visitor in Python(cont) /*exp: term (ADDOP term)* */ /* class BinOp(Exp): #op:String,e1:Exp,e2:Exp */ /* 3 + 4 - 5 */ def visitExp(self,ctx): return reduce(lambda acc, ele : BinOp(ele [0].getText(), acc , ele[1].accept(self)) , zip(ctx.ADDOPO,ctx.termO[1:], # [(+,4),(-, ctx.term(0).accept(self)) Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 25/26" }, { "page_index": 195, "chapter_num": 6, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_6/slide_021.png", "page_index": 195, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:42+07:00" }, "raw_text": "Summary AST vs. Parse tree AST representation in Scala how to build AST in Scala Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Abstract Syntax Tree 26/26" }, { "page_index": 196, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_001.png", "page_index": 196, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:44+07:00" }, "raw_text": "Name, Binding and Scope Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn HCMC University of Technology, Viet Nam November 7, 2020 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 1/31" }, { "page_index": 197, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_002.png", "page_index": 197, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:46+07:00" }, "raw_text": "Name o Name - character string used to represent something else o identifiers, operators (+, &, *). Use symbol instead of address to refer an entity Abstraction Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 3/31" }, { "page_index": 198, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_003.png", "page_index": 198, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:49+07:00" }, "raw_text": "Binding Definition Binding - the operation of associating two things Binding time - the moment when the binding is performed Some issues Early binding vs. Late binding Static binding vs. Dynamic binding Polymorphism - A name is bound to more than one entity Alias - Many names are bound to one entity Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 4/31" }, { "page_index": 199, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_004.png", "page_index": 199, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:51+07:00" }, "raw_text": "Binding Time Language design time Language implementation time Programming time Compilation time Linking time Load time Runtime Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 5/31" }, { "page_index": 200, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_005.png", "page_index": 200, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:53+07:00" }, "raw_text": "object Lifetime Object - any entity in the program. Obiect lifetime - the period between the obiect creation and destruction. Binding lifetime p Dangling reference p = new int; q = p; delete p; q *q; Leak memory - Garbage p = new int; p = null; Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 7/31" }, { "page_index": 201, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_006.png", "page_index": 201, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:55+07:00" }, "raw_text": "Object Allocation Static Static Stack Dynamic Stack Explicit Heap Dynamic o Implicit Heap Dynamic Heap Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 8/31" }, { "page_index": 202, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_007.png", "page_index": 202, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:22:57+07:00" }, "raw_text": "Scope Definition Scope of a binding is the textual region of the program in which the binding is effective Static vs. Dynamic Static scope, or lexical scope, is determined during compilation o Current binding - in the block most closely surround o Global scope o Local static scope Dynamic scope is determined at runtime. Current binding - the most recently execution but not destroyed Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 11/31" }, { "page_index": 203, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_008.png", "page_index": 203, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:00+07:00" }, "raw_text": "Blocks Definition A block is a textual region, which can contain declarations to that region Example, procedure foo () 1 var x:integer ; int x; begin x = 1; x := 1; } end ; Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 12/31" }, { "page_index": 204, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_009.png", "page_index": 204, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:02+07:00" }, "raw_text": "Staic Scope Rules for Blocks o A reference to an identifier is always bound to its most local declaration o A declaration is invisible outside the block in which it appears Declarations in enclosing blocks are visible in inner blocks, unless they have been re-declared Blocks may be named and its name declaration is considered as a local declaration of outer block Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 13/31" }, { "page_index": 205, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_010.png", "page_index": 205, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:05+07:00" }, "raw_text": "Example on Static scope var A, B, C: real; //1 procedure Sub1 (A: real);//2 var D: real: procedure Sub2 (C: real): Variable Scope var D: real; A:real //1 Main begin B:real //1 Main, Sub1, C:= C+B: : Sub2 end; C:real //1 Main, Sub1 begin A:real //2 Sub1,Sub2 Sub2(B); .. end; begin Sub1(A); . . end. Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 14/31" }, { "page_index": 206, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_011.png", "page_index": 206, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:07+07:00" }, "raw_text": "Example on Dynamic Scope procedure Big is X : Real; procedure Sub1 is X : Integer; X in Sub2 ? begin - of Sub1 Calling chain: Big -> Sub1 -> Sub2 end; - of Sub1 X => X:Integer in Sub1 procedure Sub2 is Calling chain: begin - of Sub2 Big -> Sub2 .X.. X = X:Real in Big end; - of Sub2 begin - of Big end; - of Big Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 15/31" }, { "page_index": 207, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_012.png", "page_index": 207, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:10+07:00" }, "raw_text": "Referencing Environment o The referencing environment of a statement is the collection of all names that are visible to the statement o In a static-scoped language, it is the local names plus all of the visible names in all of the enclosing scopes o In a dynamic-scoped language, the referencing environment is the local bindings plus all visible bindings in all active subprograms Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 16/31" }, { "page_index": 208, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_013.png", "page_index": 208, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:12+07:00" }, "raw_text": "Example on Static-scoped Language var A, B, C: real; //1 procedure Sub1 (A: real);//2 var D: real: procedure Sub2 (C: real); Function Referencing var D: real; Environment begin Main A,B,C,Sub1 C:= C+B; . Sub1 A, B, C, D, end; Sub1,Sub2 begin Sub2(B); .. Sub2 A, B,C, D, end; Sub1,Sub2 begin Sub1(A); . . end. Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 17/31" }, { "page_index": 209, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_014.png", "page_index": 209, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:16+07:00" }, "raw_text": "Example on Dynamic-scoped Language main > sub2 y s sub2 > sub1 void sub1{ c 01 b 03 b 05 a 07 int a, b; d 02 c 04 c 06 b 08 } /* end of sub1 */ void sub20 { int b, c; Frame Referencing Environment sub1: main c->o1,d->o2 } /* end of sub2 */ sub2 b-> o3,c-> o4, void main( { d->o2 int c, d; sub2 b->o5,c->o6, d->o2 sub20; sub1 a->o7,b-> o8. } /* end of main */ c->o6,d->o2 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 18/31" }, { "page_index": 210, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_015.png", "page_index": 210, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:18+07:00" }, "raw_text": "Functions def () : nested function pass-by-value (pointer) matched by position and by name default value arbitrary parameters arbitrary keyword parameters return statement Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 20/31" }, { "page_index": 211, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_016.png", "page_index": 211, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:20+07:00" }, "raw_text": "Nested Functions def outer(x) : y = x + 1 def inner(z): return z + 1 return inner(y) print(outer(3) =>5 print(inner(2)) =>wrong o inner function is visible inside outer but invisible outside outer Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 21/31" }, { "page_index": 212, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_017.png", "page_index": 212, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:22+07:00" }, "raw_text": "Match by position and by name def foo(param1, param2 = 0): print(param1, param2 print(foo(1,2)) =>12 print(foo(param2 = 2,param1 = 1)) =>12 print(foo(1)) =>10 Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 22/31" }, { "page_index": 213, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_018.png", "page_index": 213, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:23+07:00" }, "raw_text": "Arbitrary Arguments, *args def my_func(*kids): print(\"My third child is\" + kids[2] my_func('Tuong', 'Ca', 'Mam', 'Muoi' o Allow arbitrary number of arguments Access the parameter as a tuple o Define after normal parameters Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 23/31" }, { "page_index": 214, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_019.png", "page_index": 214, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:25+07:00" }, "raw_text": "Arbitrary keyword Arguments, **kwargs def my_func(**rec): for x,y in rec.itemsQ: print(x,y) my_func(ho='nguyen',ten='thi ha', namsinh=1996,mssv='0123456') o Allow arbitrary number of keyword arguments Access the parameter as a dictionary o Define after normal and arbitrary parameters Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 24/31" }, { "page_index": 215, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_020.png", "page_index": 215, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:28+07:00" }, "raw_text": "Return Statement Syntax: return ( (, )*)? Example: def my_func(x): x = 2 return x,x+2 a,b = my_func(0) print(a,b) =>24 Stop executing of a function call and return the result If no expression after return, None is returned If many expressions after return, a tup/e is returned Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 25/31" }, { "page_index": 216, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_021.png", "page_index": 216, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:30+07:00" }, "raw_text": "Scope o Read: Block rule, where a function is a block Local Nonlocal J Global o Built-in or imported environments Write: global, nonlocal Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 26/31" }, { "page_index": 217, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_022.png", "page_index": 217, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:33+07:00" }, "raw_text": "Scope Example from functools import * => imported env. x = 3 => global def f O : y = 4 => nonlocal of g def g(): t = 2 => local of g print(z) declaration of z is looked firstly in local environment W and then in nonlocal environments that enclose the local and then in global environment o and lastly in imported environments Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 27/31" }, { "page_index": 218, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_023.png", "page_index": 218, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:36+07:00" }, "raw_text": "global Example x,y = 1 3,4 1 => x,y: global def f O: 2 3 x = 2 => x: local of f return x + y => x: local of f;y global 4 5 def gO) : global x 6 x = 2 => x: global return 2 + x 8 f () 10 print(x) => 3 g() 11 print(x) => 2 12 firstly assigning to a variable makes the declaration of the variable in the current environment o to assign to a global variable in a function, the declaration of global is required Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 28/31" }, { "page_index": 219, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_024.png", "page_index": 219, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:40+07:00" }, "raw_text": "nonlocal Example x,y = 3,4 => x,y: global def f O: 2 3 x,z = 2,5 => x,z: local of f def g(): 4 5 nonlocal x x = 2 * y 6 => x: nonlocal=>local of f;y:global 7 return z + x => x,z:nonlocal=>local of f; 8 print(g()) => 13 print(x) => 8 9 f () 10 print(x) => 3 11 o like global but for nonlocal variables Dr.Nguyen Hua Phung nhphung@hcmut.edu.vn Name,Binding and Scope 29/31" }, { "page_index": 220, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_025.png", "page_index": 220, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:41+07:00" }, "raw_text": "Summary [1] Name Binding Scope Referencing Environment Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 30/31" }, { "page_index": 221, "chapter_num": 7, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_7/slide_026.png", "page_index": 221, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:42+07:00" }, "raw_text": "References l , Maurizio Gabbrielli and Simone Martini, Programming Languages: Principles and Paradigms, Chapter 4, Springer, 2010. Dr. Nguyen Hua Phung nhphung@hcmut.edu.vn Name, Binding and Scope 31/31" }, { "page_index": 222, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_001.png", "page_index": 222, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:43+07:00" }, "raw_text": "Data Types Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam November 13,2020 Dr. Nguyen Hua Phung Data Types 1/89" }, { "page_index": 223, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_002.png", "page_index": 223, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:45+07:00" }, "raw_text": "Outline Scalar Types Built-in Types User-Defined Ordinal Types Composite Types Array Types String Types Record Types Union Types Set Types Pointer and Reference Types Recursive Type Type Checking Case Study: Python Dr. Nguyen Hua Phung Data Types 2/89" }, { "page_index": 224, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_003.png", "page_index": 224, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:47+07:00" }, "raw_text": "ntroduction A data type is o a homogeneous collection of values and o a set of operations which manipulate these values o Uses of type system: . Conceptual organization Error detection Implementation Dr. Nguyen Hua Phung Data Types 3/89" }, { "page_index": 225, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_004.png", "page_index": 225, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:50+07:00" }, "raw_text": "Iype System A type system consists of: The set of predefined types The mechanisms to define a new type The mechanisms for the control of types: o Type equivalence Type compatibility Type inference The specification which type constraints are statically or dynamically checked Dr. Nguyen Hua Phung Data Types 4/89" }, { "page_index": 226, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_005.png", "page_index": 226, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:51+07:00" }, "raw_text": "Scalar Types Scalar Types are o atomic used to compose another types sometimes supported directly by hardware booleans, characters, integers, floating-point, fixed-point, complex, void, enumerations, intervals,.. >Skip Scalar Types Dr. Nguyen Hua Phung Data Types 6/89" }, { "page_index": 227, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_006.png", "page_index": 227, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:53+07:00" }, "raw_text": "Integer Languages may support several sizes of integer o Java's signed integer sizes: byte, short, int, long Some languages include unsigned integers Supported directly by hardware: a string of bits To represent negative numbers: two's complement Dr. Nguyen Hua Phung Data Types 7/89" }, { "page_index": 228, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_007.png", "page_index": 228, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:55+07:00" }, "raw_text": "-loating-Point Model real numbers, but only as approximations Languages for scientific use support at least two floating-point types (e.g., float and double) Precision and range lEEE Floating-Point Standard 754 Dr. Nguyen Hua Phung Data Types 8/89" }, { "page_index": 229, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_008.png", "page_index": 229, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:56+07:00" }, "raw_text": "IEEE-754 Sign bit 8 bits 23 bits S Exponent Fraction Single precision 11 bits 52 bits s Exponent Mantissa Double precision Dr. Nguyen Hua Phung Data Types 9/89" }, { "page_index": 230, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_009.png", "page_index": 230, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:23:59+07:00" }, "raw_text": "Decimal o For business applications (money o Essential to COBOL o C#offers a decimal data type Store a fixed number of decimal digits Advantage: accuracy Disadvantage: limited range, wastes memory Dr. Nguyen Hua Phung Data Types 10/89" }, { "page_index": 231, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_010.png", "page_index": 231, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:00+07:00" }, "raw_text": "Boolean Simplest of all Range of values: two elements, one for \"true\" and one for \"false o Could be implemented as bits, but often as bytes Dr. Nguyen Hua Phung Data Types 11/89" }, { "page_index": 232, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_011.png", "page_index": 232, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:02+07:00" }, "raw_text": "Character Stored as numeric codings Most commonly used coding: ASCll o An alternative, 16-bit coding: Unicode o Includes characters from most natural languages Originally used in Java C# and JavaScript also support Unicode Dr. Nguyen Hua Phung Data Types 12/89" }, { "page_index": 233, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_012.png", "page_index": 233, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:03+07:00" }, "raw_text": "User-Defined Ordinal Types An ordinal type is one in which the range of possible values can be easily associated with the set of positive integers Examples of primitive ordinal types in Java integer char boolean Dr. Nguyen Hua Phung Data Types 13/89" }, { "page_index": 234, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_013.png", "page_index": 234, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:05+07:00" }, "raw_text": "Enumeration Types All possible values, which are named constants, are provided in the definition o C# example enum days {Mon, Tue, Wed, Thu, Fri, Sat, Sun}; days myDay = Mon, yourDay = Tue; o Design issues: Is an enumeration constant allowed to appear in more than one type definition? Are enumeration values coerced to integer? Are any other types coerced to an enumeration type? Dr. Nguyen Hua Phung Data Types 14/89" }, { "page_index": 235, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_014.png", "page_index": 235, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:08+07:00" }, "raw_text": "Enumeration Type (2) Readability . no need to code a color as a number Reliability 1 operations (don't allow colors to be added) o No enumeration variable can be assigned a value outside its defined range Better support for enumeration than C++: enumeration type variables are not coerced into integer types Implemented as integers Dr. Nguyen Hua Phung Data Types 15/89" }, { "page_index": 236, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_015.png", "page_index": 236, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:10+07:00" }, "raw_text": "Subrange Type an ordered contiguous subsequence of an ordinal type type pos = 0 .. MAXINT: Subrange types behave as their parent types; can be used as for variables and array indices type sv = array[1 .. 50] of string, Subrange types are the parent types with code inserted (by the compiler) to restrict assignments to subrange variables Dr. Nguyen Hua Phung Data Types 16/89" }, { "page_index": 237, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_016.png", "page_index": 237, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:12+07:00" }, "raw_text": "Composite Types An object in composite type contains many components which can be accessed individually component's type may be the same (homogeneous or different (heterogeneous) the number of components may be fixed or changed there may be operations on structured-type object or its components there may be component insertion/removal operations there may be creation/destruction operations Dr. Nguyen Hua Phung Data Types 18/89" }, { "page_index": 238, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_017.png", "page_index": 238, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:15+07:00" }, "raw_text": "Array Types Collection of homogeneous data elements Each element is identified by its position relative to the first element and referenced using subscript expression array_name (index expression list) -> an element o What type are legal for subscripts? Pascal, Ada: any ordinal type (integer, boolean, char, enumeration) o Others: subrange of integers Are subscripting expressions range checked? Most contemporary languages do not specify range checking but Java, ML, C# o Unusual case: Perl >Skip Array Type Dr. Nguyen Hua Phung Data Types 19/89" }, { "page_index": 239, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_018.png", "page_index": 239, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:17+07:00" }, "raw_text": "Subscript Binding and Array Categories Static static int x[10]; Fixed Stack-dynamic int x[10]; //inside a function Stack-dynamic cin >n; int x[n]; o Fixed Heap-dynamic int[] x = new int[10]; Heap-dynamic cin >n; int[] x = new int[n], Dr. Nguyen Hua Phung Data Types 20/89" }, { "page_index": 240, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_019.png", "page_index": 240, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:20+07:00" }, "raw_text": "Array lnitialization Some language allow initialization at the time of storage allocation o C, C++, Java, C# example int list [] ={4, 5, 7, 83} Character strings in C and C++ char name [ = \"freddie\": Arrays of strings in C and C++ char *names [] = {\"Bob\" \"Jake\", \"Joe\"}, Java initialization of String objects String[] names = {\"Bob\", \"Jake\", \"Joe\"}, Dr. Nguyen Hua Phung Data Types 21/89" }, { "page_index": 241, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_020.png", "page_index": 241, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:21+07:00" }, "raw_text": "Rectangular and Jagged Arrays o C, C++, Java, C#: jagged arrays myArray[3][7] Fortran, Ada, C#: rectangular array myArray[3,7] rectangular jagged Dr. Nguyen Hua Phung Data Types 22/89" }, { "page_index": 242, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_021.png", "page_index": 242, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:23+07:00" }, "raw_text": "Slices A slice is some substructure of an array; nothing more than a referencing mechanism o Slices are only useful in languages that have array operations E.g. Python vector =/2, 4, 6, 8, 10, 12, 14, 16 mat = [[1, 2, 3],[4, 5, 6],[7, 8, 9]] vector[3:6], mat[1], mat[0][0:2] Dr. Nguyen Hua Phung Data Types 23/89" }, { "page_index": 243, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_022.png", "page_index": 243, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:25+07:00" }, "raw_text": "Implementation of Arrays o Access function maps subscript expressions to an address in the array Single-dimensioned: list of adjacent memory cells Access function for single-dimensioned arrays: address(list[k]) = address(list[lower bound]) + ((k-lower_bound) * element_size) Dr. Nguyen Hua Phung Data Types 24/89" }, { "page_index": 244, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_023.png", "page_index": 244, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:27+07:00" }, "raw_text": "Accessing Two-dimensional Arrays a[0,0] a[0,0] a[0,1] a[1,0] a[0,2] a[2,0] a[1,0] a[0,1] a[1,1] a[1,1] a[1,2] a[2,1] Row-major order Column-major order used in most languages used in Fortran Dr. Nguyen Hua Phung Data Types 25/89" }, { "page_index": 245, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_024.png", "page_index": 245, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:29+07:00" }, "raw_text": "Accessing Two-dimensional Arrays Row-major order : Location (a[i,j]) = a + (((i - row_Ib) * n) + (j - col_Ib)) * E where a is address of a[row_lb,col_lb] and E is element size 1 2 ...j-1 j ... n 1 2 ... i-1 i ... m Dr. Nguyen Hua Phung Data Types 26/89" }, { "page_index": 246, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_025.png", "page_index": 246, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:32+07:00" }, "raw_text": "Compile-time Descriptors Multidimensional array Element type Index type Array Number of dimensions Element type Index range 1 Index type Index lower bound ... Index upper bound Index range n Address Address Single dimensional array Multi-dimensional array Dr. Nguyen Hua Phung Data Types 27/89" }, { "page_index": 247, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_026.png", "page_index": 247, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:34+07:00" }, "raw_text": "Associative Arrays An associative array is an unordered collection of data elements that are indexed by an equal number of values called keys For example, dt = [(\"name\",\"John\");(\"age\",\"28\");(\"address\",\"1 John st.\")] dt[\"name\"] = \"John\" dt[\"address\"] => \"1 John st.\" o User defined keys must be stored Similar to Map in Scala Design issues: What is the form of references to elements Dr. Nguyen Hua Phung Data Types 28/89" }, { "page_index": 248, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_027.png", "page_index": 248, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:36+07:00" }, "raw_text": "String Types Values are sequences of characters Design issues: Is it a primitive type or just a special kind of array? . Should the length of strings be static or dynamic? Typical operations Assignment Comparison (=, >, etc.) Concatenation Substring reference Pattern matching (regular expression) Skip String Type Dr. Nguyen Hua Phung Data Types 29/89" }, { "page_index": 249, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_028.png", "page_index": 249, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:39+07:00" }, "raw_text": "String Length Options Static: String length is fixed at compiling time Python, Java String class o compile-time descriptor Limited Dynamic: String length may be changed but less than a limit o C,C++ o run-time descriptor Dynamic: String length may be changed without any limit o Perl, JavaScript run-time descriptor; linked list Ada supports all three string length options Dr. Nguyen Hua Phung Data Types 30/89" }, { "page_index": 250, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_029.png", "page_index": 250, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:41+07:00" }, "raw_text": "Descriptor Limited dynamic string Static string Maximum length String length Current length Address Address Compile-time descriptor Run-time descriptor for static length strings for limited dynamic length strings Dr. Nguyen Hua Phung Data Types 31/89" }, { "page_index": 251, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_030.png", "page_index": 251, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:43+07:00" }, "raw_text": "Record Types o A record: o heterogeneous aggregate of data elements o individual elements are identified by names o Popular in most languages, OO languages use objects as records Design issues: o What is the syntactic form of references to the field? o Are elliptical references allowed Skip Record Type Dr. Nguyen Hua Phung Data Types 32/89" }, { "page_index": 252, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_031.png", "page_index": 252, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:45+07:00" }, "raw_text": "Definition of Records in Ada Record structures are indicated in an orthogonal way type Emp_Name_Type is record First: String (1..20), Mid: String (1..10); Last: String (1..20); end record; type Emp_Rec_Type is record Emp Name: Emp Name_Type, Hourly_Rate: Float; end record; Emp_Rec: Emp_Rec_Type; Dr. Nguyen Hua Phung Data Types 33/89" }, { "page_index": 253, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_032.png", "page_index": 253, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:47+07:00" }, "raw_text": "References to Records Notation: o Dot-notation: Emp Rec.Emp Name.Mia Keyword-based: Mid OF Emp_Name OF Emp_Rec o Format: Fully qualified references: include all record names Elliptical references: may leave out some record names as long as reference is unambiguous Mid, Mid OF Emp Name, Mid OF Emp_Rec Dr. Nguyen Hua Phung Data Types 34/89" }, { "page_index": 254, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_033.png", "page_index": 254, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:50+07:00" }, "raw_text": "Operations in Records Assignment is very common if the types are identical Ada allows record comparison Ada records can be initialized with aggregate literals COBOL provides MOVE CORRESPONDING Copies fields which have the same name Dr. Nguyen Hua Phung Data Types 35/89" }, { "page_index": 255, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_034.png", "page_index": 255, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:52+07:00" }, "raw_text": "Evaluation Straight forward and safe design Comparison of arrays and records Arrays Records homogenous heterogeneous elements are pro- elements are pro- cessed in the same cessed in different way way dynamic subscripting static subscripting Dr. Nguyen Hua Phung Data Types 36/89" }, { "page_index": 256, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_035.png", "page_index": 256, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:54+07:00" }, "raw_text": "mplementation of Record Type Record Name Type Field 1 Offset .. ... Name Type Field n Offset Address Dr. Nguyen Hua Phung Data Types 37/89" }, { "page_index": 257, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_036.png", "page_index": 257, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:56+07:00" }, "raw_text": "Data Alignment b-byte aligned A b-byte aligned object has an address that is a multiple of b bytes. Example A char (one byte) will be 1-byte aligned A short (two bytes) will be 2-byte aligned A int (four bytes) will be 4-byte aligned. A long (four bytes) will be 4-byte aligned. A float (four bytes) will be 4-byte aligned. Dr. Nguyen Hua Phung Data Types 38/89" }, { "page_index": 258, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_037.png", "page_index": 258, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:24:58+07:00" }, "raw_text": "Data structure Padding Padding when a structure member is followed by a member with a larger alignment requirement, or at the end of the structure to make the structure size be multiple of the biggest member size. struct MyStruct { char data1 : int data2; char data3; short data4; char data5; }; What is the size of the above struct? Dr. Nguyen Hua Phung Data Types 39/89" }, { "page_index": 259, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_038.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_038.png", "page_index": 259, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:01+07:00" }, "raw_text": "Union Types A union is a type whose variables are allowed to store different type values at different times during execution type Shape is (Circle, Triangle, Rectangle); type Colors is (Red, Green, Blue); type Figure (Form: Shape) is record Filled: Boolean; Color: Colors; case Form is when Circle => Diameter: Float; when Triangle => Leftside, Rightside: Integer, Angle: Float; when Rectangle => Side1, Side2: Integer, end case; end record: Skip Union Type Dr. Nguyen Hua Phung Data Types 40/89" }, { "page_index": 260, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_039.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_039.png", "page_index": 260, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:02+07:00" }, "raw_text": "Ada Union Type Illustrated rectangle: side1, side2 circle: diameter triangle: leftside, rightside, angle Discriminant(form) color filled Dr. Nguyen Hua Phung Data Types 41/89" }, { "page_index": 261, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_040.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_040.png", "page_index": 261, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:04+07:00" }, "raw_text": "Design issues Should type checking be required? Discriminated vs. Free Union Fortran, C, and C++ provide union constructs in which there is no language support for type checking the union in these languages is called free union Type checking of unions reguire that each union include a type indicator called a discriminant o Supported by Ada Should unions be embedded in records? Dr. Nguyen Hua Phung Data Types 42/89" }, { "page_index": 262, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_041.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_041.png", "page_index": 262, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:05+07:00" }, "raw_text": "Example union { x.bt[0] x.bt[1] int data; char bt[2] 12 7A } x; x.data = 0x7A12: x.data cout << x.bt[0] << endl;//18 cout << x.bt[1] << endl;//122 Dr. Nguyen Hua Phung Data Types 43/89" }, { "page_index": 263, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_042.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_042.png", "page_index": 263, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:07+07:00" }, "raw_text": "Evaluation ot Unions o Potentially unsafe construct in some languages o Do not allow type checking Java and C# do not support unions Reflective of growing concerns for safety in programming language Dr. Nguyen Hua Phung Data Types 44/89" }, { "page_index": 264, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_043.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_043.png", "page_index": 264, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:09+07:00" }, "raw_text": "Set Types x: set of 1..10; y: set of char; represent the concept of set has operators: membership, union, intersection. different,... implemented by bit chain or hash table. Dr. Nguyen Hua Phung Data Types 45/89" }, { "page_index": 265, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_044.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_044.png", "page_index": 265, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:12+07:00" }, "raw_text": "Pointer Types int *ptr; A pointer type variable has a range of values that consists of memory addresses and a special value nil Provide the power of indirect addressing o Provide a way to manage dynamic memory A pointer can be used to access a location in the area where storage is dynamically created (usually called a heap) Skip Pointer Type Dr. Nguyen Hua Phung Data Types 46/89" }, { "page_index": 266, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_045.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_045.png", "page_index": 266, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:14+07:00" }, "raw_text": "Pointer Operations Two fundamental operations: assignment and dereferencing Assignment is used to set a pointer variable's value to some useful address int *p,*q; p= q Dereferencing yields the value stored at the location represented by the pointer's value o Dereferencing can be explicit or implicit C++ uses an explicit operation via j = *ptr sets j to the value located at ptr Dr. Nguyen Hua Phung Data Types 47/89" }, { "page_index": 267, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_046.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_046.png", "page_index": 267, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:16+07:00" }, "raw_text": "Pointer Dereferencing lllustrated 7080 An anonymous 206 dynamic variable ptr 7080 206 The dereferencing operation j = *ptr Dr. Nguyen Hua Phung Data Types 48/89" }, { "page_index": 268, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_047.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_047.png", "page_index": 268, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:17+07:00" }, "raw_text": "Problems with Pointers Dangling pointers (dangerous) o A pointer points to a heap-dynamic variable that has been de-allocated Lost heap-dynamic variable o An allocated heap-dynamic variable that is no longer accessible to the user program (often called garbage) Dr. Nguyen Hua Phung Data Types 49/89" }, { "page_index": 269, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_048.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_048.png", "page_index": 269, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:20+07:00" }, "raw_text": "Pointers in C and C++ int *ptr ; int count, init : ptr = &init ; count = *ptr : Extremely flexible but must be used with care Pointers can point at any variable regardless of when it was allocated o Used for dynamic storage management and addressing Dr. Nguyen Hua Phung Data Types 50/89" }, { "page_index": 270, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_049.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_049.png", "page_index": 270, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:22+07:00" }, "raw_text": "Pointers in C and C++ Pointer arithmetic is possible int Iist [10l int *ptr ; ptr = Iist : *(ptr + 1) *(ptr + index) ptr [index] Explicit dereferencing and address-of operators Domain type need not be fixed (void *) void * can point to any type and can be type checked (cannot be de-referenced) Dr. Nguyen Hua Phung Data Types 51/89" }, { "page_index": 271, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_050.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_050.png", "page_index": 271, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:23+07:00" }, "raw_text": "Pointer Operations o Pointer points to a record in C/C++ Explicit: (*p).name Implicit: p -> name Management of heap use explicit allocation o C: function malloc o C++: new and delete operators Dr. Nguyen Hua Phung Data Types 52/89" }, { "page_index": 272, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_051.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_051.png", "page_index": 272, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:25+07:00" }, "raw_text": "Design lssues of Pointers What are the scope of and lifetime of a pointer variable? What is the lifetime of a heap-dynamic variable? Are pointers restricted as to the type of value to which they can point? Are pointers used for dynamic storage management indirect addressing, or both? Should the language support pointer types, reference types, or both? Dr. Nguyen Hua Phung Data Types 53/89" }, { "page_index": 273, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_052.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_052.png", "page_index": 273, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:28+07:00" }, "raw_text": "Reference Types int A; int &rA = A; A = 1; cout << rA << endI; rA++; cout << A << endI Pointers refer to an address, references refer to object or value o C++ includes a special kind of pointer type called a reference type that is used primarily for formal parameters o Java extends C++'s reference variables and allows them to replace pointers entirely C# includes both the references of Java and the pointers of C++ Dr. Nguyen Hua Phung Data Types 54/89" }, { "page_index": 274, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_053.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_053.png", "page_index": 274, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:31+07:00" }, "raw_text": "References vs. Pointers in C++ Reference Type Pointer int A; int A; int& rA = A; int* pA = &A; rA=> A *pA => A N/A pA++ cannot reseated pA =&B cannot be null pA = null cannot be uninitialized int* pA Dr. Nguyen Hua Phung Data Types 55/89" }, { "page_index": 275, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_054.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_054.png", "page_index": 275, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:32+07:00" }, "raw_text": "Evaluation of Pointers Dangling pointers and garbage are big problems o Pointers are like goto's-they widen the range of cells that can be accessed by a variable Essential in some kinds of programming applications. e.g. device drivers Using references provide some of the flexibility and capabilities of pointers, without the hazards Dr. Nguyen Hua Phung Data Types 56/89" }, { "page_index": 276, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_055.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_055.png", "page_index": 276, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:33+07:00" }, "raw_text": "Representations of Pointers Most computers use single values Intel microprocessors use segment and offset Dr. Nguyen Hua Phung Data Types 57/89" }, { "page_index": 277, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_056.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_056.png", "page_index": 277, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:36+07:00" }, "raw_text": "Dangling Pointer Problem Tombstone: extra heap cell that is a pointer to the heap-dynamic variable The actual pointer variable points only at tombstones o When heap-dynamic variable de-allocated, tombstone remains but set to nil o Costly in time and space Locks-and-keys: Pointer values are represented as (key, address) pairs o Heap-dynamic variables are represented as variable plus cell for integer lock value When heap-dynamic variable allocated, lock value is created and placed in lock cell and key cell of pointer Dr. Nguyen Hua Phung Data Types 58/89" }, { "page_index": 278, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_057.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_057.png", "page_index": 278, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:37+07:00" }, "raw_text": "Blank Dr. Nguyen Hua Phung Data Types 59/89" }, { "page_index": 279, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_058.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_058.png", "page_index": 279, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:40+07:00" }, "raw_text": "Recursive Type A value of a recursive type can contain a (reference to) value of the same type. type int_list = {int val; int list next;} {3,{43,{-1,{6,null}}}} type char_tree = {char val ; char tree left : char_tree right;} {A,{B,{C,null,null},{D,{E,null,null},null}}, {F,null,null}} Dr. Nguyen Hua Phung Data Types 60/89" }, { "page_index": 280, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_059.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_059.png", "page_index": 280, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:42+07:00" }, "raw_text": "Example on Ocaml type char_btree Tree of char * char_btree * char_btree l Null Tree('A',Tree'B',Tree('C',Null ,Null) Tree('D', Tree('E',Null,Null) Null)), Tree('F\",Null,Null)) type 'a btree = Tree of 'a * 'a btree * 'a btree l Null Tree(4,Tree(3,Null,Null),Tree(6,Null,Null)) Dr. Nguyen Hua Phung Data Types 61/89" }, { "page_index": 281, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_060.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_060.png", "page_index": 281, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:44+07:00" }, "raw_text": "Iype Expression: Motivation Example x : array [1..10l of record a : array [5..10] of integer ; b: l record c : real : d: array[1..3] of real; end ; d: string [3]: end ; Dr. Nguyen Hua Phung Data Types 63/89" }, { "page_index": 282, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_061.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_061.png", "page_index": 282, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:46+07:00" }, "raw_text": "Type Expressions A basic type is a type expression. boolean, char, integer, float, void, subrange A type name is a type expression. A type constructor applied to type expressions is a type expression. Including: Arrays: array(I,T) where I: index type, T:element type Products:T1 x T2 o Records: record((name1 x T1) x (name2 x T2 X... Pointers: pointer(T) o Functions: T1 -> T2 A type variable is a type expression Dr. Nguyen Hua Phung Data Types 64/89" }, { "page_index": 283, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_062.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_062.png", "page_index": 283, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:48+07:00" }, "raw_text": "Example int => int typedef int siso; = siso int t[101; => array(0..9,int int foo(int a,float b) = (int x float) -? int struct int a;int b => record((a x int) x (b x int) int *p => pointer(int) template struct vd T a; T b[3]; => record((a x T) x (b x array(0..2,T))) Dr. Nguyen Hua Phung Data Types 65/89" }, { "page_index": 284, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_063.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_063.png", "page_index": 284, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:50+07:00" }, "raw_text": "Type Checking Definition Type checking is the activity of ensuring that a program respects the rules imposed by the type system o Static type checking is performed in compiling time. It is often applied for static type binding languages. o Dynamic type checking is performed in running time. It is often applied for dynamic type binding languages Some features in static type binding language that cannot be type checked during compiling time Dr. Nguyen Hua Phung Data Types 67/89" }, { "page_index": 285, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_064.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_064.png", "page_index": 285, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:53+07:00" }, "raw_text": "Iype Interence Definition Type inference is the ability of a compiler to deduce type information of program unit. Example on Scala def add(x:Int) = x + 1 Return type of function add is inferred to be Int Mechanism o Assign type (built-in or variable type)to leaf nodes in AST. o Generate type constraints in each internal node in AST. Resolve these type constraints Dr. Nguyen Hua Phung Data Types 68/89" }, { "page_index": 286, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_065.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_065.png", "page_index": 286, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:55+07:00" }, "raw_text": "lype Equivalence o an operand of one type can be substituted for one of the other type without coercion Two approaches: Equivalence by name: same type name type Celsius = Float ; type Fahrenheit = Float : o Structural equivalence: same structure type A = record type B = record field1 : integer ; field1 : integer : field2 : real: field2 : real : end end Dr. Nguyen Hua Phung Data Types 70/89" }, { "page_index": 287, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_066.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_066.png", "page_index": 287, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:25:58+07:00" }, "raw_text": "Static Type Checking for Structural Eguivalence function sequiv(Type s,Type t):boolean begin if (s and t are the same basic type) then return true : else if (s = array(s1,s2) and t = array(t1,t2) then return sequiv(s1,t1) and sequiv(s2,t2); else if (s = s1 x s2 and t = t1 x t2) then return sequiv(s1,t1) and sequiv(s2,t2); else if (s = pointer(s1) and t = pointer(t1)) then return sequiv(s1,t1); else if (s = s1 -> s2 and t = t1 -> t2) then return sequiv(s1,t1) ; else return false ; Dr. Nguyen Hua Phung Data Types 71/89" }, { "page_index": 288, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_067.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_067.png", "page_index": 288, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:01+07:00" }, "raw_text": "Type Compatibility Definition Type T is compatible with type S if a value of type T is permitted in any context where a value of type S is admissible Example, int and float A type T is compatible with type S when: o T is equivalence to S Values of T form a subset of values of S All operations on S are permitted on T Values of T correspond in a canonical fashion to values of S. (int and float) Values of T can transform to some values of S Dr. Nguyen Hua Phung Data Types 72/89" }, { "page_index": 289, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_068.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_068.png", "page_index": 289, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:02+07:00" }, "raw_text": "Iype Conversion Definition Type conversion is conversing a value of this type to a value of another type Implicit conversion - coercion o Explicit conversion - cast Dr. Nguyen Hua Phung Data Types 73/89" }, { "page_index": 290, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_069.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_069.png", "page_index": 290, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:04+07:00" }, "raw_text": "Polymorphism Definition Monomorphic: any language object has a unique type Polymorphic: the same object can have more thar one type Example, +: int x int -> int or float x float -> float Kind of Polymorphism o Ad hoc polymorphism - Overloading Universal Polymorphism Parametric polymorphism (swap(T& x,T& y)) Subtyping polymorphism (in OOP) Dr. Nguyen Hua Phung Data Types 74/89" }, { "page_index": 291, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_070.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_070.png", "page_index": 291, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:06+07:00" }, "raw_text": "Example of Parametric Polymorphism template void swap (T& x, T& y){ T tmp = x; x = y; y = tmp; int a = 5, b = 3; swap(a,b); cout << a << \"..\" << b << endI; Dr. Nguyen Hua Phung Data Types 75/89" }, { "page_index": 292, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_071.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_071.png", "page_index": 292, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:10+07:00" }, "raw_text": "Example of Subtyping Polymorphism class Polygon public : virtual float getArea( = 0; class Rectangle : public Polygon public : float getArea() return height * width ; private : float height,width ; class Triangle : public Polygon public : float getArea() fIoat p = (a + b + c) / 2; return sqrt(p*(p-a)*(p-b)*(p-c)); private : float a,b,c; Shape *s; s = (...) ? new Rectangle(3,4 : new Triangle(3,4,5): s->getArea O ; Dr. Nguyen Hua Phung Data Types 76/89" }, { "page_index": 293, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_072.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_072.png", "page_index": 293, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:11+07:00" }, "raw_text": "Built-in Data Types o Scalar Data Types o Number: int (normal, octal-0o, hexa-0x, bin-0b), float Boolean: bool o Composite Data Types Number: complex (yj) => real(), imag() String: str Sequence: list, tuple, range Mapping: dict Set: set, frozenset Dr. Nguyen Hua Phung Data Types 80/89" }, { "page_index": 294, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_073.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_073.png", "page_index": 294, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:13+07:00" }, "raw_text": "mmutable vs. Mutable Data Type Immutable Data Types: cannot modify their contents o Number (int,float,complex) Boolean (bool) String (str) Sequence (tuple, range) Set (frozenset) Mutable Data Types: able to modify their contents Sequence (list) Mapping (dict) Set (set) Dr. Nguyen Hua Phung Data Types 81/89" }, { "page_index": 295, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_074.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_074.png", "page_index": 295, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:16+07:00" }, "raw_text": "Python Lists o Like array but more flexible o Lists are ordered [1,2,3] == [1,3,2] => False o Lists can contain any arbitrary objects x = [1,'a',2.3,[4,[6],5]] o List elements can be accessed by index x[0] => 1 x[1:3] => ['a', 2.3] x[3][1][0] => 6 Lists are mutable and dynamic. x[0] = 2 => x -> 2,a',2.3,[4,[61,5]'c'] x[1:4] = [4,5,6] => x ->[2,4,5,6,c'] x.append(12) => x -> [2,4,5,6,c',12] del x[0] => x -> [4,5,6,c',12] Dr. Nguyen Hua Phung Data Types 82/89" }, { "page_index": 296, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_075.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_075.png", "page_index": 296, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:18+07:00" }, "raw_text": "List Comprehension o Motivation: create a list from another list lst1=[[1,2,3],[4,5],[6,7,8,9]] Ist = [] lst2 = [] for ele in for ele in Ist1 : lst.append( st2.append(sum(ele) o Syntax Ist = [ for ele in (if [6,9,30] Mapping with filtering lst2 = [sum(ele) for ele in lst1 if len(ele) > 2] => [6,30] Nested lst2 = [ele for row in lst1 for ele in row] =>[1,2,3,4,5,6,7,8,9] Dr. Nguyen Hua Phung Data Types 83/89" }, { "page_index": 297, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_076.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_076.png", "page_index": 297, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:21+07:00" }, "raw_text": "Indexing and Slicing x = [1,2,a','c',4.3] o Indexing: return an element Start from 0 x[0] => 1 Accept negative, where -1 is the last element x[-1] => 4.3 Slicing: return a list [start? : last? (: step)?] o x[1:3] =>[2'a'] x[1:] => [2,a',c',4.3] x[:-1] => [1,2'a',c'] x[:] => [1,2,a',c',4.3] x[1:4:2] =>[2'c'] x[::2] => [1,a',4.3] o x[::-1] => [4.3,c',a',2,1] Dr. Nguyen Hua Phung Data Types 84/89" }, { "page_index": 298, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_077.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_077.png", "page_index": 298, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:24+07:00" }, "raw_text": "Python Tuples and Ranges o Tuples are like Lists except for two following properties: o Enclosed by instead of [] o immutable o Ranges are immutable sequences of integers . generated by range(start?,stop,step?) list(range(5) =>[0,1,2,3,4] list(range(1,5) =>[1,2,3,4] list(range(1,5,2)) =>[1,3] accessed by index range(1,5)[3] => 4 o used in for loop for x in range(1,5,2): print(x) Dr. Nguyen Hua Phung Data Types 85/89" }, { "page_index": 299, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_078.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_078.png", "page_index": 299, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:26+07:00" }, "raw_text": "Python Dictionaries is mapping from from keys to values like struct but: o keys => any hashable type, values => any type x = ['fname': 'Teo', 'age': 5o, 3: {2.78: 'float ',True:'bool'}} access by key enclosed in [] mutable and dynamic x['fname'] = 'Ty' ' => replace 'Teo' by 'Ty x[3][True] => 'bool' x[4] = 'four => add new component del x[3] => remove component 3 x ->{'fname':'Ty''age':50,4:'four'} Operators and Built-in functions: read https://realpython.com/python-dicts/ Dr. Nguyen Hua Phung Data Types 86/89" }, { "page_index": 300, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_079.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_079.png", "page_index": 300, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:30+07:00" }, "raw_text": "Sets and Frozenset Sets are o unordered with unique elements {1,2,3} =={1,3,2} => True {1,2,3} =={1,2,2,3,1} } =>True - heterogeneous type x = {1,'abc',True} o dynamic but elements of sets are immutable x.add(4) =>{1'abc',True,4} x.remove('abc') =>{1,True,4} o Operators and Methods: read https://realpython.com/python-sets/ o Frozen sets are like sets except they are immutable x = frozenset({1,'abc',True} Dr. Nguyen Hua Phung Data Types 87/89" }, { "page_index": 301, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_080.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_080.png", "page_index": 301, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:31+07:00" }, "raw_text": "Summary [1] Type system is mainly used to error detection Primitive type Structure type Type checking Dr. Nguyen Hua Phung Data Types 88/89" }, { "page_index": 302, "chapter_num": 8, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_081.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_8/slide_081.png", "page_index": 302, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:33+07:00" }, "raw_text": "References Maurizio Gabbrielli and Simone Martini, Programming Languages: Principles and Paradigms, Chapter 8, Springer. 2010. Dr. Nguyen Hua Phung Data Types 89/89" }, { "page_index": 303, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_001.png", "page_index": 303, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:34+07:00" }, "raw_text": "JVM and Jasmin Dr. Nguyen Hua Phung Faculty of CSE HCMUT" }, { "page_index": 304, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_002.png", "page_index": 304, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:37+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 2" }, { "page_index": 305, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_003.png", "page_index": 305, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:40+07:00" }, "raw_text": "Our Compiler source code Scanner 1 Sequence of tokens Parser AST Semantic analyzer Symbol AST table Code generation Jasmin code (*.j) Java Bytecode Assembler Java Byte code (*.class) Java Virtual Machine CSE - HCMUT JVM and Jasmin 3" }, { "page_index": 306, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_004.png", "page_index": 306, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:46+07:00" }, "raw_text": "Programming Java Environment compile-time environment run-time environment Your program 's source fles Your program 's class fles A.java B.java C.java A.class B.class C.class Your class fles Java Java move Virtual compiler locally Vachine or though a network A.class B.class C.class Object.class String. class Your program 's class fles Java APl's classfles From [1] CSE - HCMUT JVM and Jasmin 4" }, { "page_index": 307, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_005.png", "page_index": 307, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:48+07:00" }, "raw_text": "source programs Java programs Our Compiler Java Compiler Java Byte Code Assembler Java virtual machine CSE - HCMUT JVM and Jasmin 5" }, { "page_index": 308, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_006.png", "page_index": 308, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:52+07:00" }, "raw_text": "Why Jasmin ? Jasmin is a Java assembler - adopts a one-to-one mapping - operation codes are represented by mnemonic - Example: .line 4 public class VD{ iconst 0 public void main(String[] args) t istore 2 .line 5 int a,b; iload 2 b = 0; iconst 2 imul a = b* 2 + 40; bipush 40 iadd istore 1 CSE - HCMUT JVM and Jasmin 6" }, { "page_index": 309, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_007.png", "page_index": 309, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:26:57+07:00" }, "raw_text": "Java Byte Code ca fe ba be 00 00 00 31 00 1b 0a 00 05 00 0e 09 00 0f 00 10 0a 00 11 00 12 07 00 13 07 00 14 01 00 06 3c 69 6e 69 74 3e 01 00 03 28 29 56 01 00 04 43 6f 64 65 01 00 0f4c 69 6e 65 4e 75 6d 62 65 72 54 61 62 6c 65 01 00 04 6d 61 69 6e 01 00 16 28 5b 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b 29 56 01 00 0a 53 6f 75 72 63 65 46 69 6c 65 01 00 07 56 44 2e 6a 61 76 61 0c 00 06 00 07 07 00 15 0c 00 16 00 17 07 00 18 0c 00 19 00 1a 01 00 02 56 44 01 00 10 6a 61 76 61 2f 6c 61 6e 67 2f 4f 62 6a 65 63 74 01 00 10 6a 61 76 61 2f 6c 61 6e 67 2f 53 79 73 74 65 6d 01 00 03 6f 75 74 01 00 15 4c 6a 61 76 61 2f 69 6f 2f 50 72 69 6e 74 53 74 72 65 61 6d 3b 01 00 13 6a 61 76 61 2f 69 6f 2f 50 72 69 6e 74 53 74 72 65 61 6d 01 00 07 70 72 69 6e 74 6c 6e 01 00 04 28 49 29 56 00 21 00 04 00 05 00 00 00 00 00 02 00 01 00 06 00 07 00 01 00 08 00 00 00 1d 00 01 00 01 00 00 00 05 2a b7 00 01 b1 00 00 00 01 00 09 00 00 00 06 00 01 00 00 00 01 00 09 00 0a 00 0b 00 01 00 08 00 00 00 35 00 02 00 03 00 00 00 11 03 3d 1c 05 68 10 28 60 3c b2 00 02 1b b6 00 03 61 00 00 00 01 0009 00 00 00 12 00 04 00 00 00 04 00 02 00 05 00 09 00 06 00 10 00 07 00 01 00 0c 00 00 00 02 00 0d CSE - HCMUT JVM and Jasmin 7" }, { "page_index": 310, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_008.png", "page_index": 310, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:00+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 8" }, { "page_index": 311, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_009.png", "page_index": 311, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:03+07:00" }, "raw_text": "Virtual Machine Java BKIT programs Java programs compiling compiling Java bytecode running running Java Virtual Jaya Virtual Jaya Virtual Machine for Machine for Machine for Linux Windows your television Linux Windows Your Television CSE - HCMUT JVM and Jasmin 9" }, { "page_index": 312, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_010.png", "page_index": 312, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:06+07:00" }, "raw_text": "JVM = stack-based machine A stack for each method The stack is used to store operands and results of an expression. It is also used to pass argument and receive returned value. Code generation for a stack-based machine is easier than that for a register-based one. CSE - HCMUT JVM and Jasmin 10" }, { "page_index": 313, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_011.png", "page_index": 313, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:10+07:00" }, "raw_text": "Internal Architecture of JVM class class.files loader subsystem native method Java pc heap method area stacks registers stacks runtime data areas native native methoa execution methoa interface engine libraries From [1] CSE - HCMUT JVM and Jasmin 11" }, { "page_index": 314, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_012.png", "page_index": 314, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:14+07:00" }, "raw_text": "a and Heap Method Area class object class object data object data class object object data object class class data object class data object data object method area heap From [1] 12 CSE - HCMUT JVM and Jasmin" }, { "page_index": 315, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_013.png", "page_index": 315, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:18+07:00" }, "raw_text": "Java Stacks thread 1 thread 2 thread 3 thread 1 stack stack stack frame frame frame thread 3 + + stack stack stack thread 2 frame frame frame stack stack frame frame thread 3 stack frame native method pc registers Java stacks stacks From [1] CSE - HCMUT JVM and Jasmin 13" }, { "page_index": 316, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_014.png", "page_index": 316, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:21+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 14" }, { "page_index": 317, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_015.png", "page_index": 317, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:26+07:00" }, "raw_text": "Data Types Type Range Description boolean {0,1} z byte -27 to 27 - 1, inclusive B short -215 to 215 - 1, inclusive s int -231 to 231 - 1, inclusive 1 long -263 to 263 - 1, inclusive L char 16 bit usigned Unicode (0 to 216 -1) C float 32-bit lEEE 754 single-precision float F double 64-bit lEEE 754 double-precision float D returnAddress address of an opcode within the same method class reference Lclass-name; interface reference Linter-name; array reference [l..[component- type void V CSE - HCMUT JVM and Jasmin 15" }, { "page_index": 318, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_016.png", "page_index": 318, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:30+07:00" }, "raw_text": "Example Java language type JVM description Object Ljava/lang/Object String Ljava/lang/String String [] [Ljava/lang/String int [] float [] [] [[F void main(String [] args) ([Ljava/lang/String;)V int gcd(int a,int b) (II)I char foo(float a,Object b) (FLjava/lang/Object;)C CSE - HCMUT JVM and Jasmin 16" }, { "page_index": 319, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_017.png", "page_index": 319, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:34+07:00" }, "raw_text": "Example (cont'd) public class GetType { public static void main(String [] args) { Object a = new ObjectO int [] b = new int[10] float[l[] c = new float[2][3] String d = \"csds\"; System.out.println(\"The class name of a is \"+ a.getClassO) System.out.println(\"The class name of b is \" + b.getClassO): System.out.println(\"The class name of c is \" + c.getClassO) System.out.println(\"The class name of d is \" + d.getClassO): CSE - HCMUT JVM and Jasmin 17" }, { "page_index": 320, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_018.png", "page_index": 320, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:38+07:00" }, "raw_text": "Example (cont'd) boolean, byte, char and short are implemented as int public class IntTypes { method public static public static void main([Ljava/lang/String;)V main(String argv[]) { .line 3 boolean z = true; iconst 1 istore 1 byte b = 1; .line 4 short s = 2; iconst 1 char c = 'a'; istore 2 .line 5 iconst 2 istore 3 .line 6 bipush 97 istore 4 Label0: .line 8 return end method CSE - HCMUT JVM and Jasmin 18" }, { "page_index": 321, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_019.png", "page_index": 321, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:41+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 19" }, { "page_index": 322, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_020.png", "page_index": 322, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:45+07:00" }, "raw_text": "Operand Stack Accessed by pushing and popping values - storing operands and receiving the operations' results - passing arguments and receiving method results Integral expression: a = b * 2 + 40; Jasmin code iload 2 // load variable 2 onto op stack iconst 2 // push constant 2 onto op stack imul // pop 2 values on top of stack, multiple them and push the result onto stack bipush 4. // push 40 onto stack iadd // pop 2 values on top of stack, calculate and push the result onto stack istore 1 // pop the value on top of stack and assign it to variable 1 CSE - HCMUT JVM and Jasmin 20" }, { "page_index": 323, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_021.png", "page_index": 323, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:47+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 21" }, { "page_index": 324, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_022.png", "page_index": 324, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:52+07:00" }, "raw_text": "Local Variable Array 1. A new local variable array is created each time a method is called 2. Local variables addressed by indexing, starting from 0 3. Instance methods: slot 0 given to this Parameters (if any) given consecutive indices, starting from 1 The indices allocated to the other variables in any order 4. Class methods: Parameters (if any) given consecutive indices, starting from 0 The indices allocated to the other variables in any order 5. One slot can hold a value of boolean, byte, char, short. int, float,reference and returnAdrress 6. One pair of slots can hold a value of long and double From [2] CSE - HCMUT JVM and Jasmin 22" }, { "page_index": 325, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_023.png", "page_index": 325, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:27:56+07:00" }, "raw_text": "Example 1 public static void foo( { .line 7 iconst 1 int a,b,c; istore 0 ll a a= 1; .line 8 b = 2; iconst 2 istore 1 ll b c=(a+b)*3; .line 9 iload 0 iload 1 iadd iconst 3 imul istore 2 ll c CSE - HCMUT JVM and Jasmin 23" }, { "page_index": 326, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_024.png", "page_index": 326, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:00+07:00" }, "raw_text": "Example 2 public void foo0 { .var 0 is this LVD2: from Label0 to Label1 int a,b,c; .line 7 a = 1; iconst 1 istore 1 ll a b = 2; .line 8 c=(a+b)*3; iconst 2 istore 2 ll b .line 9 iload 1 iload 2 iadd iconst 3 imul istore 3 ll c CSE - HCMUT JVM and Jasmin 24" }, { "page_index": 327, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_025.png", "page_index": 327, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:03+07:00" }, "raw_text": "Example 3 .line 6 iconst 1 public void foo{ istore 1 ll a int a = 1; .line 7 ldc2 w 2 long b = 2; Istore 2 l/ 2,3 for b int c = 3; .line 8 long d = (a + b) * c; iconst 3 istore 4 ll c .line 9 iload 1 i2l // conversion lload 2 ladd iload 4 i2l // conversion Imul Istore 5 l/ 5,6 for d CSE - HCMUT JVM and Jasmin 25" }, { "page_index": 328, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_026.png", "page_index": 328, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:06+07:00" }, "raw_text": "Outline Our compiler Java Virtual Machine - Data types Operand stack - Local variable array - Instructions CSE - HCMUT JVM and Jasmin 26" }, { "page_index": 329, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_027.png", "page_index": 329, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:10+07:00" }, "raw_text": "Jasmin Instructions 1. Arithmetic Instructions 2. Load and store instructions 3.0 Control transfer instructions 4. Type conversion instructions 5.0 Operand stack management instructions Object creation and manipulation 7. Method invocation instructions 8. Throwing instructions (not used) 9. Implementing finally (not used) 10. Synchronisation (not used) JVM and Jasmin 27 CSE - HCMUT" }, { "page_index": 330, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_028.png", "page_index": 330, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:13+07:00" }, "raw_text": "Arithmetic Instructions Add: iadd, ladd, fadd, dadd. Subtract: isub, Isub, fsub, dsub Multiply: imul, Imul, fmul, dmul. Divide: idiv, Idiv, fdiv, ddiv. Remainder: irem, Irem, frem, drem Negate: ineg, Ineg, fneg, dneg. Shift: ishl, ishr, iushr, Ishl, Ishr, lushr. Bitwise OR: ior, lor. Bitwise AND: iand, land. Bitwise exclusive OR: ixor, Ixor Local yariable increment: iinc. Comparison: dcmpg, dcmpl, fcmpg, fcmpl, Icmp From ($3.11.3,[3] CSE - HCMUT JVM and Jasmin 28" }, { "page_index": 331, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_029.png", "page_index": 331, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:17+07:00" }, "raw_text": "Load and Store Load a local variable onto the operand stack: iload, iload , => n:0..3, used for int, boolean, byte, char or short Iload, lload , => n:0..3, used for long fload, fload , => n:0..3, used for float dload, dload , => n:0..3, used for double aload, aload , => n:0..3, used for a reference Taload. > T:b,s,i,I,f,d,c,a Store a value from the operand stack into a local variable: istore, istore n:0..3, used for int, boolean, byte, char or short Istore, Istore n:0..3, used for long fstore, fstore n:0..3, used for float dstore, dstore n:0..3, used for double astore, astore n:0..3, used for a reference and returnAddress Tastore. > T:b,s,i,I,f,d,c,a From ($11.3.2,[3] CSE - HCMUT JVM and Jasmin 29" }, { "page_index": 332, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_030.png", "page_index": 332, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:22+07:00" }, "raw_text": "Load and Store (cont'd) Load a constant onto the operand stack: bipush, => for an integer constant from -27 to 27 - 1 sipush, -> for an integer constant from -215 to 215 - 1 Idc, -> for a constant that is an integer, float or a quoted string ldc w, ldc2 w, > for a constant that is a long or a double aconst null, => for a null iconst m1 => for -1 iconst -> for 0, ...,5 Iconst - > for 0,1 fconst > for 0.0.1.0 and 2.0 dconst . =>for 0.0,1.0 From ($11.3.2,[3] CSE - HCMUT JVM and Jasmin 30" }, { "page_index": 333, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_031.png", "page_index": 333, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:25+07:00" }, "raw_text": "Example 4 .line 6 .line 10 int a = 1 : iconst 1 iload 1 istore 1 iload 2 int b = 100: .line 7 imul int c = 1000; bipush 100 iload 3 istore 2 iadd int d = 40000: .line 8 iload 4 sipush 1000 isub int e=a* b + c- d istore 3 istore 5 .line 9 ldc 40000 istore 4 CSE - HCMUT JVM and Jasmin 31" }, { "page_index": 334, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_032.png", "page_index": 334, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:29+07:00" }, "raw_text": "Example 5 float a = 1.0F : .line 6 .line 10 fconst 1 fload 1 float b = 2.0F; fstore 1 fload 2 .line 7 fmul float c = 3.0F: fconst 2 fload 3 float d = 4.0F: fstore 2 fadd .line 8 fload 4 float e = a * b + c - d. ldc 3.0 fsub fstore 3 fstore 5 .line 9 ldc 4.0 fstore 4 CSE - HCMUT JVM and Jasmin 32" }, { "page_index": 335, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_033.png", "page_index": 335, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:33+07:00" }, "raw_text": "Example 6 a[0] = 100; .line 8 aload 0 // push address of array referred by a b = a[1] iconst 0 // push 0 bipush 100 // push 100 iastore // a[0] = 100 .line 9 aload 0 // push address of array referred by a iconst 1 // push 1 iaload // pop a and 1, push a[1] istore 1 // store to b CSE - HCMUT JVM and Jasmin 33" }, { "page_index": 336, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_034.png", "page_index": 336, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:36+07:00" }, "raw_text": "Control Transfer Instructions Unconditional branch goto, goto_w, jsr, jsr w, ret. Conditional branch: ifeq, iflt, ifle, ifne, ifgt, ifge, = compare an integer to zero ifnull, ifnonnull, -> compare a reference to null if_icmpeq, if_icmpne, if_icmplt, if_icmpgt, if_icmple, if icmpge, > compare two integers if acmpeq, if_acmpne. > compare two references Compound conditional branch: tableswitch, lookupswitch. From ($3.11.7,[3] CSE - HCMUT JVM and Jasmin 34" }, { "page_index": 337, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_035.png", "page_index": 337, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:41+07:00" }, "raw_text": "Example 7 int a,b,c; .line 7 iload 0 // push a if (a> b) iload 1 l/ push b if icmple Label0 c = 1: .line 8 else iconst 1 istore 2 // c = 1 c = 2; goto Label1 Label0: .line 10 iconst 2 istore 2 // c = 2 Label1 : CSE - HCMUT JVM and Jasmin 35" }, { "page_index": 338, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_036.png", "page_index": 338, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:44+07:00" }, "raw_text": "Example 8 float a,b; int c .line 7 fload 0 l/ push a if (a > b) fload 1 l/ push b fcmpl // pop a,b, push 1 if a > b, 0 otherwise c = 1: ifle Label0 // goto Label0 if top <= 0 else line 8 iconst 1 c = 2; istore 2 goto Label1 Label0: .line 10 iconst 2 istore 2 Label1 : CSE - HCMUT JVM and Jasmin 36" }, { "page_index": 339, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_037.png", "page_index": 339, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:47+07:00" }, "raw_text": "fcmpg and fcmpl 1 if value 1 > value 2 value 2 value 1 if value 1 == value 2 0 If either is NaN, fcmpg pushes 1 and fcmpl pushes -1 if value 1 < value 2 CSE - HCMUT JVM and Jasmin 37" }, { "page_index": 340, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_038.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_038.png", "page_index": 340, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:50+07:00" }, "raw_text": "Type Conversion Instructions i2l, i2f, i2d, l2f, I2d, and f2d. Only i2f is used in MP compiler 1 .line 6 iconst 1 int b = 1: istore 0 .line 7 float a = b; iload 0 i2f fstore 1 CSE - HCMUT JVM and Jasmin 38" }, { "page_index": 341, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_039.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_039.png", "page_index": 341, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:54+07:00" }, "raw_text": "Operand Stack Management Instructions dup duplicate the stack top operand remove the stack top operand pop value value value value dup pop used when translating a = b = used when translating 1: others: pop2, dup2, swap,... CSE - HCMUT JVM and Jasmin 39" }, { "page_index": 342, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_040.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_040.png", "page_index": 342, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:28:57+07:00" }, "raw_text": "Example 10 .line 7 int a,b,c; iconst 1 dup a=b=c= 1: istore 2 dup istore 1 istore 0 int a,b,c; .line 7 iconst 1 (a = 2); iconst 2 1 + dup istore 0 iadd In MC, not in Java pop CSE - HCMUT JVM and Jasmin 40" }, { "page_index": 343, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_041.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_041.png", "page_index": 343, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:02+07:00" }, "raw_text": "Object Creation and Manipulation Create a new class instance: new. Create a new array: newarray, anewarray multianewarray. Access fields of classes (static fields, known as class variables) and fields of class instances (non-static fields known as instance variables): getfield, putfield, getstatic putstatic. Load an array component onto the operand stack: baload, caload, saload, iaload, laload, faload, daload aaload. Store a value from the operand stack as an array component: bastore, castore, sastore, iastore, lastore. fastore, dastore, aastore. CSE - HCMUT JVM and Jasmin 41" }, { "page_index": 344, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_042.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_042.png", "page_index": 344, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:05+07:00" }, "raw_text": "Example 11 BKOOL: .line 6 bipush 10 a:integer[10]; newarray int astore 0 a[0] = a[1] + 2; .line 7 aload 0 iconst 0 aload 0 iconst 1 iaload Java: iconst 2 int a[] = new int [10], iadd iastore a[0] = a[1] + 2; CSE - HCMUT JVM and Jasmin 42" }, { "page_index": 345, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_043.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_043.png", "page_index": 345, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:08+07:00" }, "raw_text": "Field Instructions getstatic pustatic getfield putfield E.g. getstatic java.lang.System.out Ljava/io/PrintStream field type class name field name CSE - HCMUT JVM and Jasmin 43" }, { "page_index": 346, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_044.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_044.png", "page_index": 346, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:13+07:00" }, "raw_text": "Example 12 new VD12 public class VD12 { dup static int a; invokespecial VD12/OV int b; astore 1 iconst 1 static VD12 c; putstatic VD12.a l VD12 d; aload 1 public static void getstatic VD12.a ! main(String[] arg) iconst 1 VD12 e; iadd e = new VD12O putfield VD12.b l aload 1 a= 1: new VD12 e.b = a+ 1: dup e.d = new VD12O invokespecial VD12/OV c = e.d; putfield VD12.d LVD12: aload 1 getfield VD12.d LVD12: putstatic VD12.c LVD12 CSE - HCMUT JVM and Jasmin 44" }, { "page_index": 347, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_045.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_045.png", "page_index": 347, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:16+07:00" }, "raw_text": "Method Invocation Instructions invokestatic invokevirtual invokespecial the constructor method - a private method a method in a super class invokeinterface invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V class name method name type desc CSE - HCMUT JVM and Jasmin 45" }, { "page_index": 348, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_046.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_046.png", "page_index": 348, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:20+07:00" }, "raw_text": "Method Invocation Instructions (cont'd) arg n arg n arg 2 arg 1 arg 1 result (if any) objref result (if any) invokestatic invokevirtual/invokespecial invokevirtual: based on the real type of objref invokestatic: based on the static class CSE - HCMUT JVM and Jasmin 46" }, { "page_index": 349, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_047.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_047.png", "page_index": 349, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:22+07:00" }, "raw_text": "Example 13 public class VD13 { public static void main(String[] arg) { goo(new VD13(); float foo(int a, float b) { return a + b, static void goo(VD13 x){ x.foo(1,2.3F); CSE - HCMUT JVM and Jasmin 47" }, { "page_index": 350, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_048.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_048.png", "page_index": 350, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:26+07:00" }, "raw_text": "Example 13 (cont'd) public static void main(String[] arg) { goo(new VD13O); .method public static main([Ljava/lang/String;)V .limit stack 2 limit locals 1 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 .line 3 new VD13 dup invokespecial VD13/OV invokestatic VD13/goo(LVD13;)V objref .line 4 objref return end method CSE - HCMUT JVM and Jasmin 48" }, { "page_index": 351, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_049.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_049.png", "page_index": 351, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:30+07:00" }, "raw_text": "Example 13 (cont'd) .method static goo(LVD13;)V static void goo(VD13 x) { .limit stack 3 x.foo(1,2.3F); Jimit locals 1 .var 0 is arg0 LVD13; from Label0 to Label1 .line 9 aload 0 2.3 iconst 1 ldc 2.3 1 invokevirtual VD13/foo(IF)F pop ob$ref Label1 : .line 10 return end method CSE - HCMUT JVM and Jasmin 49" }, { "page_index": 352, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_050.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_050.png", "page_index": 352, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:33+07:00" }, "raw_text": "Method Return All methods in Java are terminated by a return instruction - return void - ireturn int,short,char,boolean, byte - freturn float Ireturn long - dreturn double - areturn reference CSE - HCMUT JVM and Jasmin 50" }, { "page_index": 353, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_051.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_051.png", "page_index": 353, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:37+07:00" }, "raw_text": "Example 13 (cont'd) .method foo(IF)F float foo(int a, float b) { limit stack 2 return a + b; limit locals 3 .var 0 is this LVD13: from Label0 to Label1 .var 1 is arg0 I from Label0 to Label1 .var 2 is arg1 F from Label0 to Label1 Label0: iload 1 i2f fload 2 fadd b Label1: freturn a ab .end method CSE - HCMUT JVM and Jasmin 51" }, { "page_index": 354, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_052.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_052.png", "page_index": 354, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:41+07:00" }, "raw_text": "Jasmin Directives > .source > .class .super >.limit > .method > .field >.end > .var > .line CSE - HCMUT JVM and Jasmin 52" }, { "page_index": 355, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_053.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_053.png", "page_index": 355, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:44+07:00" }, "raw_text": "Example 14 public class VD14 { .source VD14.java int a; class public VD14 static int b; .super java/lang/Objec .field a I public static void .field static b main(String[] arg) { (new VD14O).foo(1,2.3F); float foo(int a, float b) { return a * b; CSE - HCMUT JVM and Jasmin 53" }, { "page_index": 356, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_054.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_054.png", "page_index": 356, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:48+07:00" }, "raw_text": "Example 14 (cont'd) public class VD14 f method public OV int a; .limit stack 1 limit locals 1 static int b; .var 0 is this LVD14; from Label0 to Label1 public static void Label0: main(String[] arg) { .line 1 new aload 0 VD14O).foo(1,2.3F); invokespecial java/lang/Object/OV Label1: return float foo(int a, float b) { end method return a * b; CSE - HCMUT JVM and Jasmin 54" }, { "page_index": 357, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_055.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_055.png", "page_index": 357, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:53+07:00" }, "raw_text": "Example 14 (cont'd) public class VD14 f .method public static main([Ljava/lang/String;)V int a; .limit stack 3 limit locals 1 static int b; .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 public static void Label0: main(String[] arg) { .line 5 new new VD14 VD14O).foo(1,2.3F); dup invokespecial VD14/(V iconst 1 ldc 2.3 float foo(int a, float b) { invokevirtual VD14/foo(lF)F return a * b; pop Label1 : .line 6 return .end method CSE - HCMUT JVM and Jasmin 55" }, { "page_index": 358, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_056.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_056.png", "page_index": 358, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:29:57+07:00" }, "raw_text": "Example 14 (cont'd) public class VD14 f .method foo(IF)F int a; limit stack 2 limit locals 3 static int b; .var 0 is this LVD14: from Label0 to Label1 .var 1 is arg0 I from Label0 to Label1 public static void .var 2 is arg1 F from Label0 to Label1 main(String[] arg) { (new Label0: VD14O).foo(1,2.3F); .line 8 iload 1 i2f fload 2 float foo(int a, float b) { fmul return a * b; Label1: freturn end method CSE - HCMUT JVM and Jasmin 56" }, { "page_index": 359, "chapter_num": 9, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_057.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_9/slide_057.png", "page_index": 359, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:01+07:00" }, "raw_text": "References [1] Bill Venner, Inside the Java Virtual Machine http://www.artima.com/insidejvm/ed2/ [2] J.Xue, Prog. Lang. and Compiler, http://www.cse.unsw.edu.au/cs3131 [3] Java Virtual Machine Specification, http://java.sun.com/docs/books/vmspec/ [4] Jasmin Home Page, http://jasmin.sourceforge.net/ CSE - HCMUT JVM and Jasmin 57" }, { "page_index": 360, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_001.png", "page_index": 360, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:02+07:00" }, "raw_text": "Code Generation Dr. Phung Nguyen Faculty of Computer Science and Engineering University of Technology HCMC Vietnam National University November 25, 2020 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 1/15" }, { "page_index": 361, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_002.png", "page_index": 361, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:04+07:00" }, "raw_text": "Outline Translation to a stack-based machine 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 2/15" }, { "page_index": 362, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_003.png", "page_index": 362, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:05+07:00" }, "raw_text": "Code Generation Design Machine-Independent Code Generation Frame Intermediate Code Generation Machine-Dependent Code Generation 590 Code Generation November 25.2020 3/15" }, { "page_index": 363, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_004.png", "page_index": 363, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:06+07:00" }, "raw_text": "Machine-Dependent Code Generation Generating specified machine code E.g.: emitLDC(20) -> \"Idc 20' Implemented in JasminCode Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 4/15" }, { "page_index": 364, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_005.png", "page_index": 364, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:08+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 5/15" }, { "page_index": 365, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_006.png", "page_index": 365, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:10+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine Select instructions Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 5/15" }, { "page_index": 366, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_007.png", "page_index": 366, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:11+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine xemitlLOAD Select instructions emitREADVAR Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 5/15" }, { "page_index": 367, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_008.png", "page_index": 367, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:14+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine xemitILOAD Select instructions emitREADVAR >emitFLOAD Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 5/15" }, { "page_index": 368, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_009.png", "page_index": 368, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:15+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine xemitILOAD Select instructions emitREADVAR >emitFLOAD Select data obiects Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 5/15" }, { "page_index": 369, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_010.png", "page_index": 369, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:17+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data obiects Code Generation November 25.2020 5/15" }, { "page_index": 370, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_011.png", "page_index": 370, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:19+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data obiects Code Generation November 25.2020 5/15" }, { "page_index": 371, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_012.png", "page_index": 371, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:21+07:00" }, "raw_text": "ntermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data obiects Simulate the execution of the machine Code Generation November 25.2020 5/15" }, { "page_index": 372, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_013.png", "page_index": 372, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:23+07:00" }, "raw_text": "Intermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data obiects Simulate the execution of the machine < emitICONST -> pushO Code Generation November 25.2020 5/15" }, { "page_index": 373, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_014.png", "page_index": 373, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:25+07:00" }, "raw_text": "Intermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data obiects Simulate the execution of the machine 4 emitICONST - pushO 4 emitISTORE -> popO Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 5/15" }, { "page_index": 374, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_015.png", "page_index": 374, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:27+07:00" }, "raw_text": "Intermediate Code Generation Depend on both language and machine zemitILOAD(index) Select instructions emitREADVAR(a >emitFLOAD(index Select data objects Simulate the execution of the machine 4 emitICONST - pushO 4 emitISTORE -> popO Implemented in class Emitter Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 5/15" }, { "page_index": 375, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_016.png", "page_index": 375, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:29+07:00" }, "raw_text": "Directives Generation APls emitVAR(self,index, varName, inType, fromLabel, toLabel .var 0 is this Lio; from Label0 to Label1 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 6/15" }, { "page_index": 376, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_017.png", "page_index": 376, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:31+07:00" }, "raw_text": "Directives Generation APls emitVAR(self,index, varName, inType, fromLabel, toLabel .var 0 is this Lio; from Label0 to Label1 emitATTRIBUTE(self, lexeme, inType, isFinal, value = None field public static writer Ljava/io/Writer; Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 6/15" }, { "page_index": 377, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_018.png", "page_index": 377, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:33+07:00" }, "raw_text": "Directives Generation APls emitVAR(self,index, varName, inType, fromLabel, toLabel) .var 0 is this Lio; from Label0 to Label1 emitATTRIBUTE(self, lexeme, inType, isFinal, value = None field public static writer Ljava/io/Writer; emitMETHOD(self, lexeme, inType, isStatic) method public foo(I)l Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 6/15" }, { "page_index": 378, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_019.png", "page_index": 378, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:35+07:00" }, "raw_text": "Directives Generation APIs emitVAR(self,index, varName, inType, fromLabel, toLabel .var 0 is this Lio; from Label0 to Label1 emitATTRIBUTE(self, lexeme, inType, isFinal, value = None field public static writer Ljava/io/Writer; emitMETHOD(self, lexeme, inType, isStatic) .method public foo(I)l emitENDMETHOD(self, frame .limit stack 1 .limit locals 1 .end method Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 6/15" }, { "page_index": 379, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_020.png", "page_index": 379, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:38+07:00" }, "raw_text": "Directives Generation APIs emitVAR(self,index, varName, inType, fromLabel, toLabel .var 0 is this Lio; from Label0 to Label1 emitATTRIBUTE(self, lexeme, inType, isFinal, value = None field public static writer Ljava/io/Writer; emitMETHOD(self, lexeme, inType, isStatic .method public foo(I)l emitENDMETHOD(self, frame .limit stack 1 .limit locals 1 .end method emitPROLOG(self, name, parent .source io.java class public io .super java/lang/Object 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 6/15" }, { "page_index": 380, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_021.png", "page_index": 380, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:41+07:00" }, "raw_text": "Directives Generation APIs emitVAR(self,index, varName, inType, fromLabel, toLabel .var 0 is this Lio; from Label0 to Label1 emitATTRIBUTE(self, lexeme, inType, isFinal, value = None field public static writer Ljava/io/Writer; emitMETHOD(self, lexeme, inType, isStatic .method public foo(I)l emitENDMETHOD(self, frame) .limit stack 1 .limit locals 1 .end method emitPROLOG(self, name, parent) source io.java .class public ic .super java/lang/Object emitEPILOG(self) 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 6/15" }, { "page_index": 381, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_022.png", "page_index": 381, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:43+07:00" }, "raw_text": "Type class IntType(Type) class FloatType(Type) class StringType(Type) class VoidType(Type) class BoolType(Type) class ClassType(Type): # cname:str class ArrayType(Type): # eleType:Type,dimen:List[int class MType(Type): # partype:List[Type],rettype:Type Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 7/15" }, { "page_index": 382, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_023.png", "page_index": 382, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:45+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 383, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_024.png", "page_index": 383, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:46+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, Iexeme, inType, frame) => imul, fmul, idiv, fdiv Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 384, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_025.png", "page_index": 384, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:48+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, lexeme, inType, frame) => imul, fmul, idiv, fdiv emitDlV(self, frame) => idiv Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 385, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_026.png", "page_index": 385, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:50+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, Iexeme, inType, frame) => imul, fmul, idiv, fdiv emitDlV(self, frame) => idiv emitMOD(self, frame) => irem Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 386, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_027.png", "page_index": 386, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:52+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, lexeme, inType, frame) => imul, fmul, idiv, fdiv emitDlV(self, frame) => idiv emitMOD(self, frame) => irem emitANDOP(self, frame) => iand Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 387, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_028.png", "page_index": 387, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:54+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, lexeme, inType, frame) => imul, fmul, idiv, fdiv emitDlV(self, frame) => idiv emitMOD(self, frame) => irem emitANDOP(self, frame) => iand emitOROP(self,frame) => ior Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 388, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_029.png", "page_index": 388, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:56+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, lexeme, inType, frame) => imul, fmul, idiv, fdiv emitDlV(self, frame) => idiv emitMOD(self, frame) => irem emitANDOP(self,frame) => iand emitOROP(self,frame) => ior emitREOP(self, op, inType, frame) => code for >, < >=, <=, Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 389, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_030.png", "page_index": 389, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:30:58+07:00" }, "raw_text": "Operation Generation APls emitADDOP(self, lexeme, inType, frame) => iadd, fadd, isub, fsub emitMULOP(self, lexeme, inType, frame) => imul, fmul, idiv, fdiv emitDIV(self, frame) => idiv emitMOD(self, frame) => irem emitANDOP(self, frame) => iand emitOROP(self, frame) => ior emitREOP(self, op, inType, frame) => code for >, < >=, <=, emitRELOP(self, op, inType, trueLabel, falseLabel, frame) => code for condition in if statement Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 8/15" }, { "page_index": 390, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_031.png", "page_index": 390, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:00+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 391, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_032.png", "page_index": 391, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:01+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 392, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_033.png", "page_index": 392, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:03+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifa]store Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 393, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_034.png", "page_index": 393, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:05+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifa]store emitASTORE(self, inType, frame) => ifaastore Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 394, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_035.png", "page_index": 394, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:07+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifastore emitASTORE(self, inType, frame) => [ifa]astore emitGETSTATIC(self, lexeme, inType, frame) => getstatic Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 395, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_036.png", "page_index": 395, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:10+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifastore emitASTORE(self, inType, frame) => [ifa]astore emitGETSTATIC(self, lexeme, inType, frame) => getstatic emitGETFIELD(self, lexeme, inType, frame) => getfield Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 396, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_037.png", "page_index": 396, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:12+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifastore emitASTORE(self, inType, frame) => [ifa]astore emitGETSTATIC(self, lexeme, inType, frame) => getstatic emitGETFIELD(self, lexeme, inType, frame) => getfield emitPUTSTATIC(self, lexeme, inType, frame) => putstatic Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 397, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_038.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_038.png", "page_index": 397, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:15+07:00" }, "raw_text": "Read/Write Variables APls emitREADVAR(self, name, inType, index, frame) => [ifalload emitALOAD(self, inType, frame)) => [ifa]aload emitWRITEVAR(self, name, inType, index, frame) => [ifastore emitASTORE(self, inType, frame) => [ifa]astore emitGETSTATIC(self, lexeme, inType, frame) => getstatic emitGETFIELD(self, lexeme, inType, frame) => getfield emitPUTSTATIC(self, lexeme, inType, frame) => putstatic emitPUTFIELD(self, lexeme, inType, frame) => putfield Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 9/15" }, { "page_index": 398, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_039.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_039.png", "page_index": 398, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:16+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 399, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_040.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_040.png", "page_index": 399, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:17+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 400, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_041.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_041.png", "page_index": 400, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:19+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 401, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_042.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_042.png", "page_index": 401, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:21+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input,frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 402, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_043.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_043.png", "page_index": 402, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:23+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 403, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_044.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_044.png", "page_index": 403, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:26+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType, frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 404, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_045.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_045.png", "page_index": 404, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:28+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) = iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) >invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 405, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_046.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_046.png", "page_index": 405, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:30+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) = iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle emitDUP(self,frame) => dup 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 406, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_047.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_047.png", "page_index": 406, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:33+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label,frame) => ifle emitDUP(self,frame) => dup emitPOP(self,frame) => pop 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 407, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_048.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_048.png", "page_index": 407, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:35+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) = iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle emitDUP(self,frame) => dup emitPOP(self,frame) => pop emitl2F(self, frame) => i2f 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 408, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_049.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_049.png", "page_index": 408, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:38+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle emitDUP(self,frame) => dup emitPOP(self,frame) => pop emitl2F(self, frame) => i2f emitRETURN(self, inType, frame) => return, ireturn 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 409, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_050.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_050.png", "page_index": 409, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:41+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType, frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle emitDUP(self,frame) => dup emitPOP(self,frame) => pop emitl2F(self, frame) => i2f emitRETURN(self, inType, frame) => return, ireturn emitLABEL(self, label, frame) => Label 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 410, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_051.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_051.png", "page_index": 410, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:43+07:00" }, "raw_text": "Other APls emitPUSHICONST(self, input, frame) => iconst, bipush, sipush, Idc emitPUSHFCONST(self, input, frame) => fconst, Idc emitINVOKESTATIC(self, lexeme, inType, frame) => invokestatic emitINVOKESPECIAL(self, frame, lexeme=None, inType=None) > invokespecial emitINVOKEVIRTUAL(self, lexeme, inType,frame) = invokevirtual emitIFTRUE(self, label, frame) => ifgt emitIFFALSE(self, label, frame) => ifle emitDUP(self,frame) => dup emitPOP(self,frame) => pop emitl2F(self, frame) => i2f emitRETURN(self, inType, frame) = return, ireturn emitLABEL(self, label, frame) => Label emitGOTO(self, label, frame) => goto 290 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 10/15" }, { "page_index": 411, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_052.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_052.png", "page_index": 411, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:45+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method Labels: are valid in the body of a method < getNewLabelO: return a new label Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 412, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_053.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_053.png", "page_index": 412, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:47+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method Labels: are valid in the body of a method < getNewLabelO: return a new label 4 getStartLabelO: return the beginning label of a scope Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 413, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_054.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_054.png", "page_index": 413, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:50+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope getEndLabelO: return the end label of a scope Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 414, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_055.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_055.png", "page_index": 414, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:53+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 g getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 415, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_056.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_056.png", "page_index": 415, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:55+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope 1 getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come getBreakLabelO: return the label where a break should come Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 416, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_057.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_057.png", "page_index": 416, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:31:59+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope 1 getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come getBreakLabelO: return the label where a break should come < enterScope() Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 417, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_058.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_058.png", "page_index": 417, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:02+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come 1 g getBreakLabelO: return the label where a break should come 4 enterScopeO 4 exitScope( Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 418, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_059.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_059.png", "page_index": 418, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:05+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come getBreakLabelO: return the label where a break should come 4 enterScopeO 4 exitScopeO 4 enterLoopO Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 419, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_060.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_060.png", "page_index": 419, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:08+07:00" }, "raw_text": "Frame Tools are used to manage information used to generate code for a method . Labels: are valid in the body of a method 4 getNewLabelO: return a new label getStartLabelO: return the beginning label of a scope getEndLabelO: return the end label of a scope getContinueLabelO: return the label where a continue should come getBreakLabelO: return the label where a break should come 4 enterScope( 4 exitScope( A 6 enterLoopO < exitLoopO Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 11/15" }, { "page_index": 420, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_061.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_061.png", "page_index": 420, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:10+07:00" }, "raw_text": "Frame (cont'd) Local variable array 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 12/15" }, { "page_index": 421, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_062.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_062.png", "page_index": 421, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:12+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 422, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_063.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_063.png", "page_index": 422, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:14+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndex(: return the size of the local variable array 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 423, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_064.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_064.png", "page_index": 423, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:15+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndexO: return the size of the local variable array Operand stack Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 424, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_065.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_065.png", "page_index": 424, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:17+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndexO: return the size of the local variable array Operand stack 4 pushO: simulating a push execution Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 425, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_066.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_066.png", "page_index": 425, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:20+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndexO: return the size of the local variable array Operand stack 4 pushO: simulating a push execution 4 popO: simulating a pop execution Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 426, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_067.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_067.png", "page_index": 426, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:22+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndexO: return the size of the local variable array Operand stack 4 pushO: simulating a push execution 4 popO: simulating a pop execution 4 getMaxOpStackSizeO: return the max size of the operand stack Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 427, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_068.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_068.png", "page_index": 427, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:24+07:00" }, "raw_text": "Frame (cont'd) Local variable array 4 getNewlndexO: return a new index for a variable getMaxlndexO: return the size of the local variable array Operand stack 4 pushO: simulating a push execution 4 popO: simulating a pop execution 4 getMaxOpStackSizeO: return the max size of the operand stack Implemented in class Frame Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 12/15" }, { "page_index": 428, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_069.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_069.png", "page_index": 428, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:25+07:00" }, "raw_text": "Machine-Independent Code Generation Based on the source language Use facilities of Frame and Intermediate Code Generation (Emitter Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 13/15" }, { "page_index": 429, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_070.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_070.png", "page_index": 429, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:28+07:00" }, "raw_text": "BKlT-Java mapping A source program Java class A global variable a static field A function a static method A parameter a parameter A local variable a local variable An expression an expression A statement a statement An invocation an invocation 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 14/15" }, { "page_index": 430, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_071.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_071.png", "page_index": 430, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:30+07:00" }, "raw_text": "Summary Use BCEL to know which code should be generated 590 Dr. Phung Nguyen (University of Technology Code Generation November 25,2020 15/ 15" }, { "page_index": 431, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_072.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_072.png", "page_index": 431, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:31+07:00" }, "raw_text": "Summary Use BCEL to know which code should be generated Generate code for expressions first 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 15/15" }, { "page_index": 432, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_073.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_073.png", "page_index": 432, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:33+07:00" }, "raw_text": "Summary Use BCEL to know which code should be generated Generate code for expressions first Generate code for statements later 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 15/15" }, { "page_index": 433, "chapter_num": 10, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_074.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_10/slide_074.png", "page_index": 433, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:34+07:00" }, "raw_text": "Summary Use BCEL to know which code should be generated Generate code for expressions first Generate code for statements later Good luck 590 Dr. Phung Nguyen (University of Technology Code Generation November 25.2020 15/15" }, { "page_index": 434, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_001.png", "page_index": 434, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:36+07:00" }, "raw_text": "Sequence Control Dr. Nguyen Hua Phung HCMC University of Technology, Viet Nam December 7, 2020 Dr. Nguyen Hua Phung Sequence Contro 1/40" }, { "page_index": 435, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_002.png", "page_index": 435, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:37+07:00" }, "raw_text": "Outline Expressions Statements Program Units Dr. Nguyen Hua Phung Sequence Contro 2/40" }, { "page_index": 436, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_003.png", "page_index": 436, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:39+07:00" }, "raw_text": "Expressions o An expression is a syntactic entity whose evaluation either : o produces a value o fails to terminate -> undefined o Examples 4 + 3* 2 (a+ b) * (c - a) (b!= 0) ?(a/b) : 0 Dr. Nguyen Hua Phung Sequence Contro 4/40" }, { "page_index": 437, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_004.png", "page_index": 437, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:41+07:00" }, "raw_text": "Expressions (cont'd) Expression Evaluation Mechanism Expressions have functional composition nature (a+ b) * (c - d) + a b c d Expression Syntax Infix Prefix o Postfix Dr. Nguyen Hua Phung Sequence Control 5/40" }, { "page_index": 438, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_005.png", "page_index": 438, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:43+07:00" }, "raw_text": "nfix Notation (a+ b) * (c - d) Good for binary operators Used in most imperative programming language More than two operands? (b != 0) ? (a/b) : 0 o Smalltalk: myBox displayOn: myScreen at: 100@50 Dr. Nguyen Hua Phung Sequence Contro 6/40" }, { "page_index": 439, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_006.png", "page_index": 439, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:46+07:00" }, "raw_text": "Precedence 3 + 4 * 5 = 23, not 35 Evaluation priorities in mathematics Programming languages define their own precedence levels based on mathematics o A bit different precedence rules among languages can be confusing Dr. Nguyen Hua Phung Sequence Contro 7/40" }, { "page_index": 440, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_007.png", "page_index": 440, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:47+07:00" }, "raw_text": "Associativity If operators have the same level of precedence, then apply associativity rules Mostly left-to-right, except exponentiation operator An expression contains only one operator o Mathematics: associative Computer : optimization but potential problems o 1020 * 1020* 10-20 Dr. Nguyen Hua Phung Sequence Contro 8/40" }, { "page_index": 441, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_008.png", "page_index": 441, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:49+07:00" }, "raw_text": "Parentheses o Alter the precedence and associativity (A + B) * C Using parentheses, a language can even omit precedence and associativity rules o APL Advantage: simple Disadvantage: writability and readability Dr. Nguyen Hua Phung Sequence Contro 9/40" }, { "page_index": 442, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_009.png", "page_index": 442, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:52+07:00" }, "raw_text": "Conditional Expressions If statement if (count == 0) average else average = sum / count; Conditional Expression average = (count == 0) ? 0 : sum / count; o C-based languages, Perl, JavaScript, Ruby Dr. Nguyen Hua Phung Sequence Control 10/40" }, { "page_index": 443, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_010.png", "page_index": 443, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:54+07:00" }, "raw_text": "Prefix Notation Polish Prefix: * + a b - c d Cambridge Polish Prefix: (* (+ a b) (- c d) Normal Prefix: *(+(a,b),-(c,d)) o Derived from mathematical function f(x,y) Parentheses and precedence is no required. provided the -arity of operator is known Mostly see in unary operators o LISP: (append a b c my_list) Dr. Nguyen Hua Phung Sequence Contro 11/40" }, { "page_index": 444, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_011.png", "page_index": 444, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:55+07:00" }, "raw_text": "Posttix Notation Polish Postfix: a b + c d - * Cambridge Polish Postfix: ((a b +) (c d -) *) Normal Postfix: ((a,b)+,(c,d)-)* o Common usage: factorial operator (5!) o Used in intermediate code by some compilers o PostScript: (Hello World!) show Dr. Nguyen Hua Phung Sequence Contro 12/40" }, { "page_index": 445, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_012.png", "page_index": 445, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:32:58+07:00" }, "raw_text": "Operand Evaluation Order C program int a = 5; int fun1( { a = 17; return 3; } void main() a = a + fun10; } What is the value of a? 8 20 Reason: Side-effect on the operand of the expression Dr. Nguyen Hua Phung Sequence Contro 13/40" }, { "page_index": 446, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_013.png", "page_index": 446, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:01+07:00" }, "raw_text": "Evaluation Mechanisms o Eager evaluation First evaluate all operands . Then operators o How about a == 0 ? b : b/ a Lazy evaluation - Pass the un-evaluated operands to the operator Operator decide which operands are reguired . Much more expensive than eager Lazy for conditional, eager for the rest Dr. Nguyen Hua Phung Sequence Contro 14/40" }, { "page_index": 447, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_014.png", "page_index": 447, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:03+07:00" }, "raw_text": "Short-Circuit Evaluation (a == 0) ll (b/a > 2) If the first operand is evaluated as true, the second will be short-circuited Otherwise, \"divide by zero' How about (a> b) ll (b++/ 3) ? Some languages provide two sets of boolean operators: short- and non short-circuit o Ada: \"and\", \"or\" versus \"and then\", \"or else' Dr. Nguyen Hua Phung Sequence Control 15/40" }, { "page_index": 448, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_015.png", "page_index": 448, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:05+07:00" }, "raw_text": "Statements A statement is a syntactic entity whose evaluation: o does not return a value, but o changes the state of the system o Example a = 5; print \"pippo\" begin ... end Dr. Nguyen Hua Phung Sequence Contro 17/40" }, { "page_index": 449, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_016.png", "page_index": 449, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:06+07:00" }, "raw_text": "Assignment Statements leftExpr AssignOperator rightExpr address? value? 5 5 Evaluate left or right first is up to implementers Dr. Nguyen Hua Phung Sequence Contro 18/40" }, { "page_index": 450, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_017.png", "page_index": 450, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:08+07:00" }, "raw_text": "Assignment Statements C-based languages consider assignment as an expression while ((ch = getchar() != EOF) Introduce compound and unary assignment operators (+=, -=, ++, -) Increasing code legibility o Avoiding unforeseen side effects Dr. Nguyen Hua Phung Sequence Contro 19/40" }, { "page_index": 451, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_018.png", "page_index": 451, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:10+07:00" }, "raw_text": "Control Structures o Control statements . Selecting among alternative control flow paths - Causing the repeated execution of sequences of statements Control structure is a control statement and the collection of its controlled statements Dr. Nguyen Hua Phung Sequence Contro 20/40" }, { "page_index": 452, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_019.png", "page_index": 452, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:12+07:00" }, "raw_text": "Two-way Selection if control_expression then clause else clause o Proved to be fundamental and essential parts ot all programming languages Dr. Nguyen Hua Phung Sequence Contro 21/40" }, { "page_index": 453, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_020.png", "page_index": 453, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:14+07:00" }, "raw_text": "Dangling else if (sum == 0) if (count == 0) result = 0i else result = 1; Solution: including block in every cases Not all languages have this problem Fortran 95, Ada, Ruby: use a special word to end the statement Python: indentation matters Dr. Nguyen Hua Phung Sequence Control 22/40" }, { "page_index": 454, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_021.png", "page_index": 454, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:16+07:00" }, "raw_text": "Multiple-Selection Allows the selection of one of any number of statements or statement groups Perl, Python: don't have this lssues: . Type of selector expression? How are selectable segments specified? Execute only one segment or multiple segments? How are case values specified? What if values fall out of selectable segments? Dr. Nguyen Hua Phung Sequence Contro 23/40" }, { "page_index": 455, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_022.png", "page_index": 455, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:20+07:00" }, "raw_text": "Case Study: C Type must be int Exact value - Stmt sequences switch (index) - Block case 1 case 3 : odd += 1: sumodd += index; break; Multiple segments exited by break case 2 case 4 even += 1 ; sumeven += index; break; default printf(\"Error in.,switch\"). } for unrepresented values Dr. Nguyen Hua Phung Seguence Contro 24/40" }, { "page_index": 456, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_023.png", "page_index": 456, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:22+07:00" }, "raw_text": "Case Study : Pascal Integer or character - Single statement case exp of - Block 1 : clause A multiple values, 2,7 clause B subrange 3..5 clause C 10 : clause D else clause E end for unrepresented values Dr. Nguyen Hua Phung Sequence Contro 25/40" }, { "page_index": 457, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_024.png", "page_index": 457, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:24+07:00" }, "raw_text": "terative Statements Cause a statement or collection of statements to be executed zero, one or more times Essential for the power of the computer Programs would be huge and inflexible . Large amounts of time to write . Mammoth amounts of memory to store Design questions: o How is iteration controlled? o Logic, counting Where should the control appear in the loop? Pretest and posttest Dr. Nguyen Hua Phung Sequence Control 26/40" }, { "page_index": 458, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_025.png", "page_index": 458, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:26+07:00" }, "raw_text": "Counter-Controlled Loops o Counter-controlled loops must have: o Loop variable Initial and terminal values Stepsize Dr. Nguyen Hua Phung Sequence Contro 27/40" }, { "page_index": 459, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_026.png", "page_index": 459, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:28+07:00" }, "raw_text": "Case Study: Algol-based General form Semantic constant [define end_save] end save := last i = first for i:=first to last by step loop: do loop body if i > end save goto out end [loop body] Known number of iterations i := i + step before executing goto loop out: [undefine end_save] Dr. Nguyen Hua Phung Sequence Contro 28/40" }, { "page_index": 460, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_027.png", "page_index": 460, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:30+07:00" }, "raw_text": "Case study: C General form Semantic expr_1 loop: for (expr_1 ; expr_2; expr_3) if expr_2 = 0 goto out loop,body [loop body] expr_3 goto loop Can be infinite loop out: ... Dr. Nguyen Hua Phung Sequence Contro 29/40" }, { "page_index": 461, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_028.png", "page_index": 461, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:32+07:00" }, "raw_text": "Logically Controlled Loops Repeat based on Boolean expression rather than a counter Are more general than counter-controlled Design issues: . Should the control be pretest or posttest? Should the logically controlled loop be a special form of a counting loop or a separate statement? Dr. Nguyen Hua Phung Sequence Control 30/40" }, { "page_index": 462, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_029.png", "page_index": 462, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:34+07:00" }, "raw_text": "Case Study: C Forms Semantics loop: while (ctrl_expr) if ctrl_expr is false loop body goto out [loop body] goto loop out:... do loop: loop body [loop body] while (ctrl_expr); if ctrl_expr goto loop Dr. Nguyen Hua Phung Seguence Contro 31/40" }, { "page_index": 463, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_030.png", "page_index": 463, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:35+07:00" }, "raw_text": "User-Located Loop Control Programmer can choose a location for loop contro rather than top or bottom Simple design: infinite loops but include user-located loop exits Languages have exit statements: break and continue o A need for restricted goto statement Dr. Nguyen Hua Phung Sequence Contro 32/40" }, { "page_index": 464, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_031.png", "page_index": 464, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:37+07:00" }, "raw_text": "Case Study: C while (sum < 1000) { getnext(value) ; if (value < 0 break; sum += value; o What if we replace break by continue? Dr. Nguyen Hua Phung Sequence Contro 33/40" }, { "page_index": 465, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_032.png", "page_index": 465, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:39+07:00" }, "raw_text": "teration Based on Data Structures o Controlled by the number of elements in a data structure Iterator: o Called at the beginning of each iteration . Returns an element each time it is called in some specific order o Pre-defined or user-defined iterator Dr. Nguyen Hua Phung Sequence Contro 34/40" }, { "page_index": 466, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_033.png", "page_index": 466, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:41+07:00" }, "raw_text": "Case Study: Java ArrayList al = new ArrayList O); Iterator it = al.iterator O; while (it .hasNextO { Object element = it .nextO ; Dr. Nguyen Hua Phung Sequence Contro 35/40" }, { "page_index": 467, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_034.png", "page_index": 467, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:43+07:00" }, "raw_text": "Case Study: Ci String[] strList = {\"Bob\",\"Carol\",\"Ted\"}; foreach (String name in strList) Console.WriteLine(\"Name:{0}\", name); Dr. Nguyen Hua Phung Sequence Contro 36/40" }, { "page_index": 468, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_035.png", "page_index": 468, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:45+07:00" }, "raw_text": "Unconditional Branching Unconditional branch, or goto, is the most powerful statement for controlling the flow of execution of a program's statements Dangerous: difficult to read, as the result, highly unreliable and costly to maintain Structured programming: say no to goto Java, Python, Ruby: no goto It still exists in form of loop exit, but they are severely restricted gotos. Dr. Nguyen Hua Phung Sequence Control 37/40" }, { "page_index": 469, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_036.png", "page_index": 469, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:46+07:00" }, "raw_text": "Program Units to be continued Dr. Nguyen Hua Phung Sequence Contro 39/40" }, { "page_index": 470, "chapter_num": 11, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_11/slide_037.png", "page_index": 470, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:47+07:00" }, "raw_text": "Summary o Expressions - Operator precedence and associativity Side effects Statements Assignment Selection Statement o Loop structures Dr. Nguyen Hua Phung Sequence Contro 40/40" }, { "page_index": 471, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_001.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_001.png", "page_index": 471, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:48+07:00" }, "raw_text": "Control Abstraction Dr.. Nguyen Hua Phung HCMC University of Technology, Viet Nam 09,2013 Dr.. Nguyen Hua Phung Control Abstraction 1/39" }, { "page_index": 472, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_002.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_002.png", "page_index": 472, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:50+07:00" }, "raw_text": "Outline Subprogram Definition Subprogram Mechanisms Simple Call Return Recursie Call Exception Parameter Passing Higher-order Funtions Dr.. Nguyen Hua Phung ControlAbstractior 2/39" }, { "page_index": 473, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_003.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_003.png", "page_index": 473, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:52+07:00" }, "raw_text": "Outline Subprogram Definition Subprogram Mechanisms Simple Call Return Recursie Call Exception Parameter Passing Higher-order Funtions Dr.. Nguyen Hua Phung Control Abstraction 3/39" }, { "page_index": 474, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_004.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_004.png", "page_index": 474, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:54+07:00" }, "raw_text": "Subprogram Definition Subprogram definition consists of: o Specification Subprogram name Parameters input + output order type parameter passing mechanisms: by value, by reference, by name,.. Behaviour of the subprogram Implementation: Local data Collection of statements as subprogram body Dr.. Nguyen Hua Phung Control Abstraction 4/39" }, { "page_index": 475, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_005.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_005.png", "page_index": 475, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:56+07:00" }, "raw_text": "Example def apply(interval : Int , repeats : Boolean = true) (op: => Unit) { val timeOut = new javax.swing.AbstractActionO { def actionPerformed (e: java.awt.event.ActionEvent) = op } val t = new javax.swing.Timer(interval , timeOut) t.setRepeats(repeats) t.start() 1 Dr.. Nguyen Hua Phung Control Abstraction 5/39" }, { "page_index": 476, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_006.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_006.png", "page_index": 476, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:33:59+07:00" }, "raw_text": "Example def apply(interval: Int , repeats : Boolean = true) (op: => Unit) { val timeOut = new javax.swing.AbstractActionO { def actionPerformed (e: java.awt.event.ActionEvent) = op } val t = new javax.swing.Timer(interval , timeOut) t .setRepeats(repeats) t.start0 1 How many subprogram definitions are there in the above code? How many parameters are there in each subprogram definition? Dr.. Nguyen Hua Phung Control Abstraction 5/39" }, { "page_index": 477, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_007.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_007.png", "page_index": 477, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:01+07:00" }, "raw_text": "Subprogram Activation An activation of a subprogram: is created when the subprogram is invoked is destroyed when the subprogram completed its execution Dr.. Nguyen Hua Phung Control Abstraction 6/39" }, { "page_index": 478, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_008.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_008.png", "page_index": 478, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:03+07:00" }, "raw_text": "Subprogram Activation An activation of a subprogram: is created when the subprogram is invoked is destroyed when the subprogram completed its execution An activation includes Static part: Code segment o Dynamic part: Activation record o formal parameters local data return address other links Dr.. Nguyen Hua Phung Control Abstraction 6/39" }, { "page_index": 479, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_009.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_009.png", "page_index": 479, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:04+07:00" }, "raw_text": "Outline Subprogram Definition Subprogram Mechanisms 0 Simple Call Return Recursie Call Exception Parameter Passing Higher-order Funtions Dr.. Nguyen Hua Phung Control Abstraction 7/39" }, { "page_index": 480, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_010.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_010.png", "page_index": 480, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:06+07:00" }, "raw_text": "Subprogram Mechanisms Simple Call-Return Recursive Call Exception Processing Handler Coroutines Scheduled Subprograms Tasks Dr.. Nguyen Hua Phung Control Abstraction 8/39" }, { "page_index": 481, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_011.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_011.png", "page_index": 481, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:08+07:00" }, "raw_text": "Exercise int mul (Node root) f if (root == null) return 1: else root.val * mul(root.left) mul(root.right); * Rewrite the above function to short-circuit the traversal if val of a node in the binary tree is 0? Dr.. Nguyen Hua Phung Control Abstraction 9/39" }, { "page_index": 482, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_012.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_012.png", "page_index": 482, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:10+07:00" }, "raw_text": "Simple Call-Return Basic Features No recursion Explicit Call Site Single Entry Point Immediate Control Passing Single Execution Dr.. Nguyen Hua Phung Control Abstractior 10/39" }, { "page_index": 483, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_013.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_013.png", "page_index": 483, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:11+07:00" }, "raw_text": "Recursive Call Be able to call recursive Direct Recursice Call Indirect Recursive Call (Mutual Recursive) Other features same as Simple Call-Return Dr.. Nguyen Hua Phung Control Abstractior 11/39" }, { "page_index": 484, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_014.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_014.png", "page_index": 484, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:12+07:00" }, "raw_text": "Exception Processing Handler o May have no explicit call site Dr.. Nguyen Hua Phung Control Abstractior 12/39" }, { "page_index": 485, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_015.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_015.png", "page_index": 485, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:13+07:00" }, "raw_text": "Exception Processing Handler May have no explicit call site o Used in Dr.. Nguyen Hua Phung Control Abstraction 12/39" }, { "page_index": 486, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_016.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_016.png", "page_index": 486, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:15+07:00" }, "raw_text": "Exception Processing Handler May have no explicit call site o Used in Event-Driven Programming Dr.. Nguyen Hua Phung Control Abstraction 12/39" }, { "page_index": 487, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_017.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_017.png", "page_index": 487, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:16+07:00" }, "raw_text": "Exception Processing Handler May have no explicit call site o Used in Event-Driven Programming Error Handler Dr.. Nguyen Hua Phung Control Abstraction 12/39" }, { "page_index": 488, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_018.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_018.png", "page_index": 488, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:17+07:00" }, "raw_text": "Exception Processing Handler May have no explicit call site o Used in Event-Driven Programming Error Handler Dr.. Nguyen Hua Phung Control Abstraction 12/39" }, { "page_index": 489, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_019.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_019.png", "page_index": 489, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:20+07:00" }, "raw_text": "Exception Processing Handler May have no explicit call site o Used in Event-Driven Programming Error Handler Example, class EmptyExcp extends Throwable {int x=0;}; int average(int[] V) throws EmptyExcp(){ if (length(V)==0) throws new EmptyExcp(); else }; try{. average(W) ; 1 catch (EmptyExcp e) {write(\"Array_empty\"); Dr.. Nguyen Hua Phung Control Abstractior 12/39" }, { "page_index": 490, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_020.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_020.png", "page_index": 490, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:22+07:00" }, "raw_text": "Exception Mechanisms A language must specify. which exceptions can be handled and how they can be defined how an exception can be raised how an exception can be handled Dr.. Nguyen Hua Phung Control Abstractior 13/39" }, { "page_index": 491, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_021.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_021.png", "page_index": 491, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:24+07:00" }, "raw_text": "How an exception can be defined Java: subclass of Throwable Ada: values of a special type C++: any value Dr.. Nguyen Hua Phung Control Abstraction 14/39" }, { "page_index": 492, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_022.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_022.png", "page_index": 492, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:25+07:00" }, "raw_text": "How an exception can be raised Raising exception By user interaction (Click, MouseMove, TextChange, ...) Dr.. Nguyen Hua Phung Control Abstraction 15/39" }, { "page_index": 493, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_023.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_023.png", "page_index": 493, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:26+07:00" }, "raw_text": "How an exception can be raised Raising exception By user interaction (Click, MouseMove, TextChange, ...) By operating system Dr.. Nguyen Hua Phung Control Abstraction 15/39" }, { "page_index": 494, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_024.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_024.png", "page_index": 494, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:28+07:00" }, "raw_text": "How an exception can be raised Raising exception By user interaction (Click, MouseMove, TextChange, ...) By operating system By an object (Timer) Dr.. Nguyen Hua Phung Control Abstractior 15/39" }, { "page_index": 495, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_025.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_025.png", "page_index": 495, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:30+07:00" }, "raw_text": "How an exception can be raised Raising exception By user interaction (Click, MouseMove, TextChange, ...) By operating system By an object (Timer) By programmer (throw ) Dr.. Nguyen Hua Phung Control Abstractior 15/39" }, { "page_index": 496, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_026.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_026.png", "page_index": 496, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:33+07:00" }, "raw_text": "Example in Scala object Timer { def apply(interval: Int , repeats : Boolean = true (op: => Unit) { val timeOut = new javax.swing.AbstractAction( { def actionPerformed (e: java.awt.event.ActionEvent) = op val t = new javax.swing.Timer(interval , timeOut t . setRepeats(repeats) t.start0 } Timer(2000) { println(\"Timer went off\") } Timer(10000, false) { println(\"10 seconds are over!\") Dr.. Nguyen Hua Phung Control Abstraction 16/39" }, { "page_index": 497, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_027.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_027.png", "page_index": 497, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:34+07:00" }, "raw_text": "How an exception can be handled Define the protected block to intercept the exception for being handled Define exception handler associated with the protected block Dr.. Nguyen Hua Phung ControlAbstractior 17/39" }, { "page_index": 498, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_028.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_028.png", "page_index": 498, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:36+07:00" }, "raw_text": "How an exception can be handled Define the protected b/ock to intercept the exception for being handled Define exception handler associated with the protected block Termination Semantic non-resumable (common) + stack unwinding resumable o at the statement causing the error after the statement causing the error Dr.. Nguyen Hua Phung Control Abstraction 17/39" }, { "page_index": 499, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_029.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_029.png", "page_index": 499, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:39+07:00" }, "raw_text": "Coroutines A coroutine may postpone its execution and control is back to caller. Its execution later is resumed at the place it postponed. A B resume B resume A resume B resume A resume B resume A Dr.. Nguyen Hua Phung Control Abstraction 18/39" }, { "page_index": 500, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_030.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_030.png", "page_index": 500, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:41+07:00" }, "raw_text": "Tasks able to execute concurrently with other tasks run on multi-processor machine or single processor machine using time sharing Dr.. Nguyen Hua Phung Control Abstraction 19/39" }, { "page_index": 501, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_031.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_031.png", "page_index": 501, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:42+07:00" }, "raw_text": "Tasks able to execute concurrently with other tasks run on multi-processor machine or single processor machine using time sharing Issue? Dr.. Nguyen Hua Phung Control Abstractior 19/39" }, { "page_index": 502, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_032.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_032.png", "page_index": 502, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:44+07:00" }, "raw_text": "Tasks able to execute concurrently with other tasks run on multi-processor machine or single processor machine using time sharing Issue? o Synchronization Race condition o Deadlock Communication Dr.. Nguyen Hua Phung ControlAbstractior 19/39" }, { "page_index": 503, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_033.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_033.png", "page_index": 503, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:45+07:00" }, "raw_text": "Example in Scala val pa = (0 until 10000).toArray.par pa.map(_ + 1) pa map{ v => if (v % 2 == 0) v eIse -v } pa.fold(0) 1+ var a = 0 pa foreach { a +=- Dr.. Nguyen Hua Phung Control Abstractior 20/39" }, { "page_index": 504, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_034.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_034.png", "page_index": 504, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:47+07:00" }, "raw_text": "Scheduled subprograms The execution of callee is NOT started when it is invoked scheduled by time CALL A AT TIME = CURRENT TIME + 10 scheduled by priority CALL B WlTH PRIORlTY 7 Controlled by a scheduler Dr.. Nguyen Hua Phung Control Abstractior 21/39" }, { "page_index": 505, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_035.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_035.png", "page_index": 505, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:49+07:00" }, "raw_text": "Outline Subprogram Definition Subprogram Mechanisms Simple Call Return Recursie Call Exception Parameter Passing Higher-order Funtions Dr.. Nguyen Hua Phung Control Abstraction 22/39" }, { "page_index": 506, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_036.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_036.png", "page_index": 506, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:51+07:00" }, "raw_text": "Formal and Actual Parameter Definition o Formal parameters:int foo(float x,bool& y) : just a simple name close to a variable declaration combine with symbols relating to parameter passing mechanism Actual parameters/Arguments:foo(4*a,b an expression Dr.. Nguyen Hua Phung Control Abstraction 23/39" }, { "page_index": 507, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_037.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_037.png", "page_index": 507, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:53+07:00" }, "raw_text": "Formal and Actual Parameter Definition o Formal parameters:int foo(float x,bool& y): just a simple name close to a variable declaration C combine with symbols relating to parameter passing mechanism o Actual parameters/Arguments:foo(4*a,b o an expression Formal-Actual Corresponding by position int foo(float a,int b) = foo(x+1,y-2) o by name int foo(float a,int b) foo(b = x+1, a = y-2) Dr.. Nguyen Hua Phung Control Abstraction 23/39" }, { "page_index": 508, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_038.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_038.png", "page_index": 508, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:55+07:00" }, "raw_text": "Parameter Passing Input-Output o By value-result By reference By name Input Only o By value . By constant reference o Output Only By result As a result of a function Dr.. Nguyen Hua Phung Control Abstractior 24/39" }, { "page_index": 509, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_039.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_039.png", "page_index": 509, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:55+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 510, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_040.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_040.png", "page_index": 510, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:57+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 511, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_041.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_041.png", "page_index": 511, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:34:59+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result findMax(a,b) => int findMax(int x,int y) {...} caller callee value a 5 5 x value b 6 6 y Dr.. Nguyen Hua Phung ControlAbstractior 25/39" }, { "page_index": 512, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_042.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_042.png", "page_index": 512, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:01+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result int findMax(int x,int y) {...} caller callee a 5 7 x b 6 8 y Dr.. Nguyen Hua Phung ControlAbstractior 25/39" }, { "page_index": 513, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_043.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_043.png", "page_index": 513, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:03+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result findMax(a,b) int findMax(int x,int y) {...} caller callee value a 7 7 x value b 8 8 y Dr.. Nguyen Hua Phung ControlAbstractior 25/39" }, { "page_index": 514, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_044.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_044.png", "page_index": 514, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:04+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result caller a 7 b 8 Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 515, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_045.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_045.png", "page_index": 515, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:05+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result o Pass by reference Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 516, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_046.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_046.png", "page_index": 516, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:06+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 517, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_047.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_047.png", "page_index": 517, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:08+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference findMax(a,b) => int findMax(int& x,int& y) {...} caller callee address a 5 x address b 6 y Dr.. Nguyen Hua Phung ControlAbstractior 25/39" }, { "page_index": 518, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_048.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_048.png", "page_index": 518, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:10+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference int findMax(int& x,int& y) {...} caller callee a 5 x b 6 y Dr.. Nguyen Hua Phung Control Abstractior 25/39" }, { "page_index": 519, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_049.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_049.png", "page_index": 519, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:12+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference int findMax(int& x,int& y) {...} caller callee a 7 x b 8 y Dr.. Nguyen Hua Phung Control Abstractior 25/39" }, { "page_index": 520, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_050.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_050.png", "page_index": 520, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:13+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference findMax(a,b) < caller a 7 b 8 Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 521, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_051.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_051.png", "page_index": 521, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:15+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference Pass by name Dr.. Nguyen Hua Phung Control Abstraction 25/39" }, { "page_index": 522, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_052.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_052.png", "page_index": 522, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:16+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference Pass by name findMax(a,b) => int findMax(int=> x,int=> y) {...} Dr.. Nguyen Hua Phung Control Abstractior 25/39" }, { "page_index": 523, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_053.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_053.png", "page_index": 523, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:17+07:00" }, "raw_text": "nput-Output Parameters Pass by value-result Pass by reference Pass by name int findMax(int=> x,int=> y) {...} a = x b = y Dr.. Nguyen Hua Phung Control Abstractior 25/39" }, { "page_index": 524, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_054.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_054.png", "page_index": 524, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:20+07:00" }, "raw_text": "Exercise void swap(int x, int y) { int t = x; x = y; y = t : } void mainO f int a[] = {2, 1, 0}; i = 0; swap(i,a[i]); cout << i << a[0] << a[1] << a[2]; } Dr.. Nguyen Hua Phung ControlAbstractior 26/39" }, { "page_index": 525, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_055.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_055.png", "page_index": 525, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:21+07:00" }, "raw_text": "nput Only Parameters o Pass by value Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 526, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_056.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_056.png", "page_index": 526, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:22+07:00" }, "raw_text": "nput Only Parameters o Pass by value caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 527, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_057.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_057.png", "page_index": 527, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:24+07:00" }, "raw_text": "nput Only Parameters Pass by value findMax(a,b) => int findMax(int x,int y) {...} caller callee value a 5 5 x value b 6 6 y Dr.. Nguyen Hua Phung ControlAbstractior 27/39" }, { "page_index": 528, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_058.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_058.png", "page_index": 528, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:25+07:00" }, "raw_text": "nput Only Parameters Pass by value int findMax(int x,int y) {...} caller callee a 5 7 x b 6 8 y Dr.. Nguyen Hua Phung ControlAbstractior 27/39" }, { "page_index": 529, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_059.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_059.png", "page_index": 529, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:27+07:00" }, "raw_text": "nput Only Parameters Pass by value findMax(a,b) < caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 530, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_060.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_060.png", "page_index": 530, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:28+07:00" }, "raw_text": "nput Only Parameters o Pass by value Pass by constant reference Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 531, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_061.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_061.png", "page_index": 531, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:30+07:00" }, "raw_text": "nput Only Parameters Pass by value Pass by constant reference caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 532, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_062.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_062.png", "page_index": 532, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:32+07:00" }, "raw_text": "nput Only Parameters Pass by value Pass by constant reference findMax(a,b) => int findMax(const int& x,const int& y){...} caller callee address a 5 x address b 6 y Dr.. Nguyen Hua Phung Control Abstraction 27/39" }, { "page_index": 533, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_063.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_063.png", "page_index": 533, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:34+07:00" }, "raw_text": "nput Only Parameters Pass by value Pass by constant reference int findMax(const int& x,const int& y) {...} caller callee a 5 x b 6 y Dr.. Nguyen Hua Phung ControlAbstractior 27/39" }, { "page_index": 534, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_064.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_064.png", "page_index": 534, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:35+07:00" }, "raw_text": "nput Only Parameters Pass by value Pass by constant reference int findMax(const int& x,const int& y) {...} caller callee a 5 x b 6 y Dr.. Nguyen Hua Phung ControlAbstractior 27/39" }, { "page_index": 535, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_065.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_065.png", "page_index": 535, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:37+07:00" }, "raw_text": "nput Only Parameters Pass by value Pass by constant reference findMax(a,b) caller a 5 b 6 Dr.. Nguyen Hua Phung ControlAbstractior 27/39" }, { "page_index": 536, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_066.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_066.png", "page_index": 536, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:37+07:00" }, "raw_text": "Output Only Parameters o Pass by result Dr.. Nguyen Hua Phung Control Abstraction 28/39" }, { "page_index": 537, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_067.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_067.png", "page_index": 537, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:39+07:00" }, "raw_text": "Output Only Parameters Pass by result caller a 5 b 6 Dr.. Nguyen Hua Phung Control Abstraction 28/39" }, { "page_index": 538, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_068.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_068.png", "page_index": 538, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:41+07:00" }, "raw_text": "Output Only Parameters Pass by result findMax(a,b) => int findMax(int x,int y) {...} caller callee a 5 x b 6 y Dr.. Nguyen Hua Phung Control Abstractior 28/39" }, { "page_index": 539, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_069.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_069.png", "page_index": 539, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:43+07:00" }, "raw_text": "Output Only Parameters Pass by result int findMax(int x,int y) {...} caller callee a 5 3 x b 6 4 y Dr.. Nguyen Hua Phung ControlAbstractior 28/39" }, { "page_index": 540, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_070.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_070.png", "page_index": 540, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:44+07:00" }, "raw_text": "Output Only Parameters Pass by result findMax(a,b) caller value a 3 3 value b 4 4 Dr.. Nguyen Hua Phung ControlAbstractior 28/39" }, { "page_index": 541, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_071.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_071.png", "page_index": 541, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:45+07:00" }, "raw_text": "Output Only Parameters Pass by result As a result of a function Dr.. Nguyen Hua Phung Control Abstraction 28/39" }, { "page_index": 542, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_072.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_072.png", "page_index": 542, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:47+07:00" }, "raw_text": "Output Only Parameters Pass by result As a result of a function int foo0 ... return 0; No actual parameter: foo0 + 1 Dr.. Nguyen Hua Phung Control Abstraction 28/39" }, { "page_index": 543, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_073.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_073.png", "page_index": 543, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:51+07:00" }, "raw_text": "Exercise type VECT = array [1..3] of integer ; type VECTPTR = @VECT: procedure SUB1 : var A,B:VECT:P,Q:VECTPTR: begin A[1] := 7;A[2l := 8; A[3l := S 9: B[1] := 7;b[2] := 8; B[3] := 9: P := @A; Q := @B; SUB2(P,Q) ; end ; procedure SUB2(R:VECTPTR;var S:VECTPTR) begin R[1] := R[1] + 10; // 1 S[1] := S[1] + 10; // 2 if ... then R := S; // 3 else S := R; // 4 end ; Dr.. Nguyen Hua Phung Control Abstraction 29/39" }, { "page_index": 544, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_074.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_074.png", "page_index": 544, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:53+07:00" }, "raw_text": "Exercise (cont'd) Which storage (variable) is changed and what is its new value after changing after the following instruction is executed? a. // 1 // 2 // 3 // 4 d. Dr.. Nguyen Hua Phung ControlAbstractior 30/39" }, { "page_index": 545, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_075.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_075.png", "page_index": 545, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:54+07:00" }, "raw_text": "Outline Subprogram Definition Subprogram Mechanisms Simple Call Return Recursie Call Exception Parameter Passing Higher-order Funtions Dr.. Nguyen Hua Phung Control Abstraction 31/39" }, { "page_index": 546, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_076.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_076.png", "page_index": 546, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:56+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions o as its input parameters (fairly common) Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 547, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_077.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_077.png", "page_index": 547, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:57+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions as its input parameters (tairly common) as its out parameters (less common - but required in functional programming) Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 548, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_078.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_078.png", "page_index": 548, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:35:59+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions as its input parameters (tairly common) as its out parameters (less common - but required in functional programming) Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 549, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_079.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_079.png", "page_index": 549, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:01+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions as its input parameters (fairly common) as its out parameters (less common - but required in functional programming) Example, in stdlib.h of C, there is a built-in sorting function void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 550, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_080.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_080.png", "page_index": 550, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:03+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions as its input parameters (fairly common) as its out parameters (less common - but required in functional programming) Example, in stdlib.h of C, there is a built-in sorting function void qsort(void *base, size t nmemb, size t size , int(*compar)(const void *, const void *)); int int_sorter(const void *first_arg ,const void *second_arg) int first = *(int*)first_arg: int second = *(int*)second_arg : if (first < second) return -1; else if (first == second) return 0; else return 1: 1 Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 551, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_081.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_081.png", "page_index": 551, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:06+07:00" }, "raw_text": "Higher-order Functions A function is higher-order when it accepts functions as its input parameters (fairly common) as its out parameters (less common - but required in functional programming) Example, in stdlib.h of C, there is a built-in sorting function void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); int main( { int array[10],i ; /* fil1 array */ for ( i = 0; i < 10; ++i ) array[i] = 10 - i ; qsort(array, 1o, sizeof(int),int_sorter); for (i = 0; i < 10; ++i) printf (\"%dn\" ,array[i]); 1 Dr.. Nguyen Hua Phung Control Abstraction 32/39" }, { "page_index": 552, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_082.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_082.png", "page_index": 552, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:07+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 553, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_083.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_083.png", "page_index": 553, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:10+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, int x = 1: int f(int y){ return x+y; } int g (int h(int b)){ int x = 2: return h(3) + x; //shallow binding 1 [int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 554, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_084.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_084.png", "page_index": 554, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:12+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Static scope: z = int x = 1; int f(int y){ return x+y; } int g (int h(int b){ int x = 2; return h(3) + x; //shallow binding 1 [int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 555, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_085.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_085.png", "page_index": 555, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:14+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Static scope: z = 6 int x = 1; int f(int y){ return x+y; } int g (int h(int b){ int x = 2; return h(3) + x; //shallow binding 1 [int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 556, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_086.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_086.png", "page_index": 556, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:16+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Dynamic scope + Deep binding: z = int x = 1; int f(int y){ return x+y; } int g (int h(int b)){ int x = 2; return h(3) + x; //shallow binding } {int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 557, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_087.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_087.png", "page_index": 557, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:20+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Dynamic scope + Deep binding: z = 9 int x = 1; int f(int y){ return x+y; } int g (int h(int b)){ int x = 2; return h(3) + x; //shallow binding 1 {int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 558, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_088.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_088.png", "page_index": 558, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:22+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Dynamic scope + Shallow binding: z = int x = 1; int f(int y){ return x+y; } int g (int h(int b)){ int x = 2; return h(3) + x; //shallow binding 1 [int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 559, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_089.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_089.png", "page_index": 559, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:23+07:00" }, "raw_text": "Functions as Parameters What is non-local environment? o Deep binding Shallow binding Example, Dynamic scope + Shallow binding: z = 7 int x = 1; int f(int y){ return x+y; } int g (int h(int b)){ int x = 2; return h(3) + x; //shallow binding 1 [int x = 4; int z = g(f); //deep binding 1 Skip Scala Example Dr.. Nguyen Hua Phung Control Abstraction 33/39" }, { "page_index": 560, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_090.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_090.png", "page_index": 560, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:26+07:00" }, "raw_text": "Exercise var X:real : procedure SUB2(X,Y: real;function F(U: real): real) ; var Z: real : begin Z := abs(X - Y) ; Z := (F(X) + F(Y))* Z 1 2; write(Z); // ??? in static-scoping language procedure SUB1 : var Y: real : function FUNC(V: real ) : real : begin FUNC := X * V + Y: begin Y := 1: SUB2(0,1,FUNC) ; begin X := 3; SUB1 ; end . Dr.. Nguyen Hua Phung Control Abstraction 34/39" }, { "page_index": 561, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_091.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_091.png", "page_index": 561, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:29+07:00" }, "raw_text": "Example in Scala object FileMatcher { private def filesHere (new java.io.File (\".\")).listFiles def filesEnding(query: String) = for (file <- filesHere; if f ile .getName.endsWith(query)) yield file} def filesContaining(query: String) = for (file <- filesHere; if file .getName.contains(query)) yield file def filesRegex(query: String) = for (file <- filesHere ; if file .getName.matches(query)) yield file 1 Dr.. Nguyen Hua Phung Control Abstraction 35/39" }, { "page_index": 562, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_092.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_092.png", "page_index": 562, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:32+07:00" }, "raw_text": "Example in Scala object FileMatcher { private def filesHere (new java.io.File (\".\")).listFiles def filesEnding(query: String) = for (file <- filesHere ; if f ile .getName.endsWith(query)) yield file} def filesContaining(query: String) = for (file <- filesHere; if file .getName.contains(query)) yield file def filesRegex(query: String) = for (file <- filesHere ; if file getName.matches(query)) yield file Dr.. Nguyen Hua Phung Control Abstraction 35/39" }, { "page_index": 563, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_093.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_093.png", "page_index": 563, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:34+07:00" }, "raw_text": "Example in Scala object FileMatcher { private def filesHere (new java.io.File (\".\")).listFiles def filesMatching(query: String , matcher: (String , String) => Boolean) = { for (file <- filesHere; if matcher( file .getName, query) yield file } def filesEnding(query: String) = filesMatching(query, -.endsWith(_)) def filesContaining(query: String) = filesMatching(query, -.contains(_)) def filesRegex(query: String) = filesMatching(query, -.matches(_)) 1 Dr.. Nguyen Hua Phung Control Abstraction 36/39" }, { "page_index": 564, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_094.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_094.png", "page_index": 564, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:36+07:00" }, "raw_text": "Functions as Returns What returns as functions Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 565, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_095.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_095.png", "page_index": 565, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:36+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 566, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_096.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_096.png", "page_index": 566, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:38+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 567, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_097.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_097.png", "page_index": 567, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:39+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 568, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_098.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_098.png", "page_index": 568, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:42+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, void->int F O { int x = 1 : int g () { return x+1: 1 return g ; 1 void->int gg = FO; int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 569, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_099.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_099.png", "page_index": 569, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:44+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, void->int F O { int x = 1 : int g () { return x+1: 1 return g ; 1 void->int gg = FO; int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 570, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_100.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_100.png", "page_index": 570, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:46+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, void->int F O { int x = 1 : int g () { return x+1: 1 return g ; 1 void->int gg = FO; int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 571, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_101.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_101.png", "page_index": 571, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:48+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main void->int F O { gg int x = 1 : z int g () { return x+1: 1 return g ; 1 void->int gg = FO; int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 572, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_102.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_102.png", "page_index": 572, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:51+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main F void->int F O { gg x 1 int x = 1 : z int g () { return x+1: 1 return g ; 1 void->int gg = FO; int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 573, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_103.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_103.png", "page_index": 573, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:54+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main F void->int F O { gg x 1 int x = 1 : z int g () { return x+1: 1 return g ; g 1 void->int gg = FO; code int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 574, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_104.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_104.png", "page_index": 574, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:56+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main void->int F O { gg int x = 1 : z int g () { return x+1: 1 return g ; g 1 void->int gg = FO; code int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 575, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_105.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_105.png", "page_index": 575, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:36:58+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main void->int F O { gg int x = 1 : z int g () { return x+1: 1 return g ; g 1 void->int gg = FO; code int z = gg() ; Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 576, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_106.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_106.png", "page_index": 576, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:37:01+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main g void->int F O { gg int x = 1 : z int g () { return x+1: 1 return g ; g 1 void->int gg = FO; code int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 577, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_107.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_107.png", "page_index": 577, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:37:04+07:00" }, "raw_text": "Functions as Returns What returns as functions o Code Environment Example, main g No x void->int F O { gg to eval int x = 1 : z int g () { x + 1 return x+1: 1 return g ; g 1 void->int gg = FO; code int z = gg(); Dr.. Nguyen Hua Phung Control Abstraction 37/39" }, { "page_index": 578, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_108.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_108.png", "page_index": 578, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:37:06+07:00" }, "raw_text": "Exercise How to keep the environment for function as results? Does the same problem happen for function as parameter? If your answer is Yes, please give an example. >Skip Scala Example Dr.. Nguyen Hua Phung Control Abstractior 38/39" }, { "page_index": 579, "chapter_num": 12, "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_109.png", "metadata": { "doc_type": "slide", "course_id": "CO3005", "source_file": "/workspace/data/converted/CO3005_Principles_of_Programming_Languages/Chapter_12/slide_109.png", "page_index": 579, "language": "en", "ocr_engine": "PaddleOCR 3.2", "extractor_version": "1.0.0", "timestamp": "2025-10-31T13:37:07+07:00" }, "raw_text": "Summary Subprogram mechanisms Simple Call-Return Recursive Call Exception Coroutine Scheduled Call Tasks Parameter Passing Higher-order Functions Dr.. Nguyen Hua Phung ControlAbstractior 39/39" } ] }