Compiler Construction

Slides:



Advertisements
Similar presentations
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
Advertisements

Reasons to study concepts of PL
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Squeak and Botkit-Port Jeff Forbes Joel Miller. Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Wilf LaLonde ©2012 Comp 4501 COMP 4501 Advanced Computer Game Design and Development Wilf LaLonde.
Session 6 Comments on Lab 3 & Implications of Inheritance.
OOP Basics Classes & Methods (c) IDMS/SQL News
PRG 420 Entire Course FOR MORE CLASSES VISIT PRG 420 Week 1 Individual Assignment Hello world PRG 420 Week 2 Individual Assignment.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
COP Topics Java Basics - How to write & call your own method - Math methods (static methods) - String methods (instance methods) - Errors Classes.
Swift by Kevin Gamboa Teky Alvarado Hieu Tran Elizabeth Sanchez
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
EGR 2261 Unit 13 Classes Read Malik, Chapter 10.
CSC 222: Object-Oriented Programming
Component 1.6.
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
C# for C++ Programmers 1.
Programming what is C++
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Concepts of Object Oriented Programming
INTERMEDIATE PROGRAMMING WITH JAVA
CSc 1302 Principles of Computer Science II
CS 3304 Comparative Languages
Introduction to the C Language
CSC 221: Computer Programming I Spring 2010
PRG 420 NERD Marvelous Learning / prg420nerd.com
Pamela Moore & Zenia Bahorski
CSC 221: Computer Programming I Fall 2005
Chapter 1 Reasons to study concepts of PLs Programming Domains
Java for Android is specific
Variables and Primative Types
Data types and variables
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
1.1 Reasons to study concepts of PLs
Programming Language Concepts (CIS 635)
Wrapper Classes ints, doubles, and chars are known as primitive types, or built-in types. There are no methods associated with these types of variables.
PRG 420 Education for Service-- snaptutorial.com.
PRG 420 NERD Lessons in Excellence -- prg420nerd.com.
PRG 420 Teaching Effectively-- snaptutorial.com
Procedural Abstraction Object-Oriented Code
PRG 420 NERD Education for Service-- prg420nerd.com.
PRG 420 Education for Service-- prg420.com. PRG 420 Week 1 Coding a Simple “Hello, world!” Java™ Program(New Syllabus) For more course tutorials visit.
Introduction to the C Language
Object Oriented Programming (OOP) LAB # 8
Inheritance Basics Programming with Inheritance
Feedback from Assignment 1
Stacks.
Coding Concepts (Data Structures)
Introduction to Programming Using C++
CMSC 202 Java Primer 2.
Topic 1: Problem Solving
Computer Programming with JAVA
Unit 3 Test: Friday.
Chapter 6: Programming Languages
CISC124 Labs start this week in JEFF 155. Fall 2018
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Object Oriented Programming in java
CSE 142, Spring 2012 Building Java Programs Chapter 1
Classes CS 21a: Introduction to Computing I
Introducing JavaScript
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Review of Previous Lesson
Trees That Represent Grammars
CMSC 202 Constructors Version 9/10.
Presentation transcript:

Compiler Construction 95.3002 Compiler Construction

My Background Introduced “Regular Right Part Grammars” in my PhD thesis from Univ. Waterloo in 1975. Google it. Smalltalk expert, co-author of 3 books, Inside Smalltalk, Vols. 1 and 2, and Smalltalk/V: Practice and Experience, and sole author of Discovering Smalltalk, 32 refereed papers, 89 “Smalltalk Column” articles in JOOP (Journal of Object-Oriented Programming) Game engine expert. Published a game (MultiWorld Racing) on the iPhone and Android (racing/exploration in an infinite but small world; no longer available). Had employees working with me building a PC game which became the basis for mobile version. A number of my former employees working for Silicon Knights (Jeff Giffen) and Rock Star Games (Nan Ma, Adriaan Blaauw) Previous courses taught – “Advanced Shaders” and other 4th year gaming courses.

Marking Scheme Assignments 60% Exam 40% Assignments To ensure we really understand Letter grades only Exam 40% To force review and retention Assignments Actual assignments and how many is a work in progress More assignments than last year but less complex. #0: Setting up Unmarked #1: Implementing Scanners and Parsers #2: Implementing Finite State Machines #3: Building Scanner/Parsing Tables (First half) #4: Building Readback Tables (Second half) #5: Simple Code Generation

Times Class: Tues/Thurs 8:30am (1.5 hours) 202 Tory Building Help sessions: Mon/Thurs 6pm 5345 Herzberg Also, Saturday 9am Totally voluntary Help with programming details. Watch others work. See status of other people’s work… I will be there. I will also stay as late as you do. I can be there on other days if you want. seminar room (no computers) If you don’t have your own computer, I can look in on you periodically in labs that have machines Few assignments can be done in 1 lab session, many in 2, some need 3.

Implementation Language 2 Years ago – Required Smalltalk Privately Allowed 3 people using Java + 1 Person using Ruby Only Ruby implementor finished Last Year – Allowed other languages but recommended Smalltalk 2 people using Java + 1 Person using Python All finished but Java group switched to Smalltalk after first assignment Usually get a handful of people dropping out because of the heavy workload (only early dropouts, no late dropouts)

What the Course Aimed to Teach Compiler technology. Compiler constructor technology. What the Assignments Aimed to Do To end up with your own tool that could be used for developing a real compiler of your own (for your portfolio of achievements) None of the assignments were independent (each needed the previous one to be able to work)

What’s Different This Year Compiler technology. Compiler constructor technology. What the Assignments Aim to Do To develop subsets of the code needed to build a compiler constructor When done, you’ll understand how to build the tool but won’t have a working tool. If you really want to have a complete working tool, I can provide extra help for you to do it if you want.

What Else is Different More encouragement for other languages but … some of the notes are in Smalltalk You have to at least be able to translate from Smalltalk to your language choice. Since the assignments are more standalone, they can be done in any language. We’ll provide 2 assignments paths (the standalone path and the tools path where each assignment requires the previous one). I consider the tool path to be more work but more rewording.

Why Do I Recommend Smalltalk More object-oriented than Java Java: A number like 123 is an int (a primitive value). It is not an object. Java: Each slot in the array can hold an object or a primitive value but you can’t mix them. You can’t have an array of Apples OR ints. Smalltalk, Ruby, Python: allow collections of anything; including ints, Dogs, and even classes. Classes are not objects in C++. They are in Java. More object-oriented than Java or Ruby Java or Ruby: Control structures are built-in. There is no method corresponding to a for-loop. Smalltalk: allow you to reimplement existing control structures and to define new one. It’s the reason we call Smalltalk a “fast prototyping” language.

Why Do I Recommend Smalltalk More object-oriented than Java or C++ Smalltalk: Objects have instance methods and class methods both of which uses inheritance. Java and C++ have static methods. It supports inheritance but not generally. The internet struggles to explain how static methods work. The answer is that it supports “compile time” inheritance only. Friendlier meta-level facilities than Java You have the name of a method in a variable. How do you execute it. Java has a syntax that says “I don’t want you to do this” but I will allow you if you really really really want to.

What is Smalltalk Most Known For? Keyword based messages Java: object1 . between (object2, object3) Smalltalk: object1 between: object2 and: object3 No dot Keywords The name of the method is between:and: Smalltalk: 100 factorial No colon if there are no parametters Note that it’s CONSISTENTLY receiver first, message (i.e., selector and parameters) second Smalltalk: Array new: 10 Java: new int [10] Implication: More bracket needed (sometimes) Smalltalk: object1 between: (3 raisedTo: 3.14) and: object3 Means what it says Smalltalk: object1 between: 3 raisedTo: 3.14 and: object3 Selector is between:raisedTo:and:

What’s Annoying About Smalltalk Uses := for assignment and . for end of statement. But a = b is equality comparison, == is identity comparison, a := 5. is an assignment statement Uses square brackets [ and ] instead of braces { and }, single quotes for strings instead of double quotes, and “;” is also used. ‘this is a string’ versus character $a 1 to: 10 do: [:k | Transcript space; << k.] Send a second message to the same receiver Since square brackets are taken, you can’t subscript with them. Other languages: a [p] = b [q] Smalltalk: a at: p put: (b at: q) The Smalltalk we use for the course is old. Not supported natively on Macs Some people used virtual machines to get around the problem. The School is willing to put Smalltalk on some lab machines if you want it. There are other courses that need virtual machines too.

Knowing Java Knowing Smalltalk Helps you program in non-object oriented languages Java programmers structure C programs better than those who don’t understand object oriented programming Knowing Smalltalk Helps you program in other object oriented languages like Ruby or Python Smalltalk programmers structure Ruby and Python programs better than those who just know Java. They can also use their meta-level facilities better since they get used to doing it in Smalltalk.