CS代考 CSE 3341, Part 1

Computer and Information Science Engineering

Principles of Programming Languages

Copyright By PowCoder代写 加微信 powcoder

Computer Sc. & Eng.

Homeworks, Projects, Exams, Grades
Homeworks:
Four homeworks, worth 25 points each
Homeworks will be due one week after they are assigned
Late penalty: 20% for each day or part thereof
Interpreter for the Core programming language: 100 pts
Tokenizer: 40 pts; Rest: 60 pts
Scheme project: 100 pts
Late penalty: 10% for each day or part thereof
Midterm, Friday, March 11: 150 pts
Final exam: 150 pts
Exams must be taken on scheduled dates
Exception: Medical emergencies (with documentation)
Grading: I will grade the exams. Our graders, (.8)
and (.40), will grade the homeworks and projects
Final course grades will be based on the Carmen scale

Homeworks, Projects, Exams (contd.)
Homeworks and projects will be posted on will be due on Carmen at 11:59 pm on due dates
The class slides will be posted on Carmen and on will use Piazza for discussions
If you have any questions about any homework or the projects, post the questions on not post questions that have been previously answered
Do not e-mail these questions to me or to the graders
The only e-mails you should send me should be about personal matters such as serious health problems
E-mail any questions you have about grades you received in a homework or project to the graders
As a general rule, I will respond to emails and Piazza posts only once a day, probably in the early afternoon
Office hours will be on Zoom and I will post the link

Course Organization
Course outline and tentative schedule
Part 1 (2 weeks)
Introduction
Syntax, Semantics, Programming methodology
Compilers and interpreters
Part 2 (3.5 weeks)
Regular expressions, Finite State Automata (FSAs)
Regular expression for Core
Tokenizer project for Core
BNF/Context-Free Grammars; BNF grammar for Core
Parse trees
Recursive descent approach to compilers, interpreters
Concrete, abstract parse trees
Context-free, Context-sensitive, Runtime conditions
Simple (but bad!) representation of abstract parse trees for Core
Recursive descent printing, execution, parsing
Interpreter project for Core

Course Organization (contd.)
Course outline and tentative schedule
Part 3 (4.5 weeks)
Why is it a bad representation?
ParseTree class-based approach
Object-oriented approach
Midterm Exam
Part 4 (3.5 weeks)
Functional programming
S-expressions and ListsTokenizer project for Core
Lisp/Scheme code using design notation (pseudo-code)
Scheme project
Scheme formal notation
Lisp interpreter: Some details
Part 5 (1.5 weeks)
Haskell: Some key ideas
Haskell examples

CSE 3341, Part 1
Classroom Procedures, etc.
You are expected to attend every class period but I will not record attendance
I will record the lectures and post the links on Piazza but watching those recordings will be a very poor substitute for attending class
When you are in class, you must follow OSU’s policies about mask-wearing.
Your mask must be worn properly so that it covers your nose and mouth
Do not eat in the class. If you need a drink, be quick and put your mask back on
If you don’t hear something I say, please raise your hand and ask me to repeat
Do not sit way in the back of the class if there is room in the front

CSE 3341, Part 1
Course Organization
Main Goal:
Discuss key concepts underlying PLs
Sub-Goals:
Alternative programming paradigms
Implementation issues
At end of the course:
Given a feature, you should be able to:
Decide whether you like it or not, and why
Have an idea how to implement it
Decide what kinds of problems it is suited for.
For the first ten weeks or so, we will be talking about aspects of various languages including Java, C++, Python, JavaScript (maybe); also Pascal and Fortran.
During the last five weeks, we will discuss Lisp and Scheme; and talk briefly about Haskell.

CSE 3341, Part 1
Some Key Points
Text: The Scott book is very good but is also hard to read and contains *far* too much material. So:
Use it as a reference
Do NOT miss classes
*You* are responsible for creating your own class notes
Slides are NOT class “notes”
What we say in class overrides what you may find online
So when you do your homework assignments and answer questions in the exam etc., they should be based on the class discussion, the detailed notes I will post and the text, not what you may have seen or heard elsewhere

CSE 3341, Part 1
Some Relevant parts of the
Below are some parts of the Scott book that deal with the same or related topics as the ones we will discuss but the book is far too detailed and is not an easy read. (Chapter/section nos. are from the third edition of the book)
Chapter 2, especially 2.1, 2.2, 2.3 (Syntax, Tokenizer, Parser)
Section 3.2 (Memory management)
Parts of Chapter 6 (?) (Language implementation issues)
Chapter 7, especially 7.1, 7.2, 7.7 (Memory management)
Sections 8.1, 8.2, 8.3 (Language implementation issues)
Sections 9.2, 9.4 (Language implementation issues)
(9.6 is useful if you are interested in Smalltalk on which Objective-C is based)
Section 10.3 (Scheme)
Sections 15.1, 15.2 (some details of Java implementation)

CSE 3341, Part 1
How do we study a language?
What do legal programs in L look like?
In the Core interpreter project, the tokenizer and the parser will be responsible for the syntax
Semantics:
What do the various instructions of L do (when exec.)?
In the Core interpreter project, the executor will be responsible for the semantics
Programming Methodology:
How are you supposed to use the features of L?
For solving what kinds of problems?

CSE 3341, Part 1
Language Implementation: Compilers
Problem: Compilers (and interpreters) are more subtle than many students realize

What we will do: Explore some of the subtleties in the next few slides, using several schematic diagrams to guide the discussion

CSE 3341, Part 1
Compilers (contd.)
Important Notation Used in the Diagrams:
“C” will denote a compiler
“I” will denote an interpreter (a bit later)
“P” will denote an arbitrary “user program”
“M” will denote both a machine language and the “machine”
“L” will denote a “high-level” language
For any program, the superscript will denote the language the program is written in
CM is a compiler written in M
PL is a user program written in L
The subscript will summarize what the program does
So the following denotes a compiler, written in M, that translates any program written in L into an equivalent program in M:

CSE 3341, Part 1
Compilers (contd.)

: Compiler, in M, for translating from L to M
In the figures, the middle box shows the program currently running; the box on the left is the input to that program;; the one on the right is the output from the program

CSE 3341, Part 1
Compilers (contd.)
Problem: What if a new language L’ was introduced?
Can we avoid writing the compiler for L’ *in* M?

Answer: Yes!

CSE 3341, Part 1
Compilers (contd.)
Problem: But we are still working with M since the compiler we wrote, in L, is still translating L’ programs into equivalent programs in M. Can we avoid that?

Answer: Yes!

CSE 3341, Part 1
Compilers: The Total Picture

This is how it is done in practice
The original C++ compiler was written in C and translated C++ programs into equivalent C programs

CSE 3341, Part 1
Identify a language I

For each L, write

For each M, write

New machines are easy to handle: Why?
New languages are easy to handle: Why?
Common intermediate language: C

Compilers: Intermediate Langs.

CSE 3341, Part 1
Language Implementation:Interpreters
Question: What exactly is an interpreter?
Answer: An interpreter I for a high-level language L is a program, written in machine language M that takes, as input, any user program P, written in L and executes it
In other words: I does not translate P into an equivalent program in M. Instead, it directly executes it
But it may store P in a different form such as a
parse-tree to simplify the execution process
Notation: The following denotes an interpreter for L written in the machine language M:

CSE 3341, Part 1
Interpreters (contd.)

: Interpreter for L (written in M)

CSE 3341, Part 1
Interpreters

: Interpreter for L (written in M)
Advantages/disadvantages of compilers vs. interpreters?
Running theme for course: Runtime vs compile-time

CSE 3341, Part 1
Knowledge Check
What is javac?
Can you characterize it using our notation?

What is the JVM?
Can you characterize it using our notation?

What is an assembler?
Can you characterize it using our notation?

What is a CPU?
Can you characterize it using our notation?

/docProps/thumbnail.jpeg

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com