CSE 401 – Compilers

CSE 401 – Compilers

CSE341: Programming Languages CSE341: Programming Languages CSE 401 – Compilers Lecture 1 CourseLecture Mechanics 1 CourseML Variable Mechanics Bindings Lecture 2: Languages, Automata, Regular ML Variable Bindings Expressions & Scanners Dan Grossman Michael Ringenburg Fall 2011 Dan Grossman Winter 2013 Fall 2011 Winter 2013 UW CSE 401 (Michael Ringenburg) ADministrave Notes CSE341: ProgrammingCSE341: Programming Languages Languages • Reading – Cooper & TorczonLecture: Chapter 1, anD SecEons 2.1-2.4 1 Lecture 1 – Try to finish by the enD of the week – it’ll be helpful Course MechanicsCourse Mechanics for the first homework. ML Variable BindingsML Variable Bindings • First homework Dan Grossman Dan Grossman Fall 2011 – ShoulD be out on FriDay (I’ll post on course website Fall 2011 anD senD an email). – Will be Due a week from FriDay (January 18). – Note: You have 4 late Days for the en)re quarter. Use them wisely (see syllabus for Details). Winter 2013 UW CSE 401 (Michael Ringenburg) B-2 ReminDers CSE341: ProgrammingCSE341: Programming Languages Languages • Please vote for office hours by enD-of-Day ThursDay (see link on course home page). Lecture 1 Lecture 1 Course Mechanics – Select whichever slots you think you coulD Course Mechanics ML Variable Bindings reasonably aenD. ML Variable Bindings Dan Grossman – We will use this to help DeciDe office hours for the Dan Grossman Fall 2011 TAs anD the instructor. Fall 2011 • Please pick your project partner, anD senD mail to cse401-staff[at]cs. – First piece of the project will be releaseD (early) next week, so you shoulD pick partners this week. Winter 2013 UW CSE 401 (Michael Ringenburg) B-3 Snow CSE341: ProgrammingCSE341: Programming Languages Languages • It’s the Eme of year where the “S”-worD starts to show up occasionally in weather forecasts. Lecture 1 Lecture 1 Course MechanicsCourse Mechanics • The scheDule for the quarter is Eght, so if we ML Variable Bindings Do have a snow Day at some point, we may ML Variable Bindings Dan Grossman have to rush through some of the material. Dan Grossman Fall 2011 – If this happens, take advantage of the extra Eme Fall 2011 on the snow Day to pay extra aenEon to the readings – with less Eme to cover the material in class, the readings become corresponDingly more important. Winter 2013 UW CSE 401 (Michael Ringenburg) B-4 AgenDa CSE341: ProgrammingCSE341: Programming Languages Languages • Finish course intro (history) • IntroDuce Scanning (part 1 of your project) Lecture 1 Lecture 1 Course MechanicsCourse Mechanics – Quick review of basic concepts of formal ML Variable BindingsML Variable Bindings grammars Dan Grossman – Regular expressions Dan Grossman Fall 2011 – Lexical specificaon of programming languages Fall 2011 – Using finite automata to recognize regular expressions – Scanners anD Tokens Winter 2013 UW CSE 401 (Michael Ringenburg) B-5 Some History • Early computers – hanD coDeD assembly language CSE341: ProgrammingCSE341: Programming Languages Languages (punchcarDs!) – HarD to write anything complex – but earliest computers Lecture 1 Lecture 1 coulDn’t execute any thing that Course MechanicsCoursecomlex Mechanics. • 1952: Grace Hopper writes first compiler (for A-0), anD ML Variable Bindings coins the term “compiler”. ML Variable Bindings – EssenEally a collecEon of mathemacal subrouEnes that coulD Dan Grossman be calleD. The compiler woulD take a series of calls anD convert Dan Grossman them into an executable. Fall 2011 – Successors: A-1, A-2 (first “open source” sojware), anD later … Fall 2011 B-0! • 1957: IBM writes first real “high-level” language compiler, for FORTRAN. (FORTRAN is high level compareD to assembly.) – CompeEEve with hanD-opEmizeD coDe. – RequireD 18 person-years (hopefully your projects won’t take this long!) Winter 2013 UW CSE 401 (Michael Ringenburg) B-6 Some History • 1962: First CSE341:bootstrapped ProgrammingCSE341: compiler (for LISP) Programming Languages Languages – A compiler that was compileD by itself, rather than wri\en in assembly (or another language). Lecture 1 Lecture 1 – Requires iniEally creang a very simple compiler in assembly or Course Mechanics another language, anD then using that to compile the iniEal Course Mechanics bootstrappeD compiler. ML Variable BindingsML Variable Bindings • IniEal compiler may contain just a subset of the language. As this compiler is refineD to compile more of the language, the compiler itself Dan Grossman can begin to use more of the language. Dan Grossman – Much more efficient that wriEng in assembly (like the first Fall 2011 compilers). Fall 2011 – Great way to test a compiler. • Rest of 1960’s, into 1970’s – Work on formalizing scanning anD parsing (theory anD pracEce). – Automac parser anD scanner generators • Lex (lexical analyzer) anD Yacc (Yet Another Compiler Compiler) • JFlex anD Cup are Direct DescenDants of these C-baseD tools. Winter 2013 UW CSE 401 (Michael Ringenburg) B-7 Some History CSE341: ProgrammingCSE341: Programming Languages Languages • Late 1970’s, 1980’s – New languages (funcEonal; object-orienteD) Lecture 1 Lecture 1 – New architectures (RISC, parallel machines, caches, …) Course MechanicsCourse Mechanics – Back-enD improvements: OpEmizaon, Register ML Variable BindingsML Variable Bindings Allocaon, Automac parallelizaon Dan Grossman • 1990s Dan Grossman Fall 2011 – ImproveD techniques for compiling object orienteD coDe Fall 2011 • Efficiency in the presence of Dynamic Dispatch anD small methoDs – Just-in-Eme compilers (JITs) – Compiler technology to effecEvely use new harDware (RISC, parallel machines, complex memory hierarchies) Winter 2013 UW CSE 401 (Michael Ringenburg) B-8 Some History CSE341: ProgrammingCSE341: Programming Languages Languages • Last Decade – Compilaon techniques in many new places Lecture 1 Lecture 1 Course Mechanics • E.g., parsing, semanEc analysis, source-to-source Course Mechanics translaon useD for sojware analysis, verificaon, ML Variable BindingsML Variable Bindings security Dan Grossman Dan Grossman – PhaseD compilaon – blurring the lines between Fall 2011 “compile Eme” anD “runEme” Fall 2011 • Programs can generate anD compile specializeD versions of rouEnes “on the fly”. • Can use machine learning to control opEmizaons – MulEcore: parallelism everywhere! Winter 2013 UW CSE 401 (Michael Ringenburg) B-9 Any quesEons? CSE341: ProgrammingCSE341: Programming Languages Languages • Don’t hesitate to ask – I’m teaching this course because I enjoy talking about Lecture 1 Lecture 1 Course Mechanics compilers. Course Mechanics ML Variable BindingsML Variable Bindings • If you have a quesEon, it’s likely other people Dan Grossman Dan Grossman Do as well, but they are too shy to ask. So Fall 2011 Fall 2011 you’ll be Doing them a favor too. Winter 2013 UW CSE 401 (Michael Ringenburg) B-10 AgenDa CSE341: ProgrammingCSE341: Programming Languages Languages • Finish course intro • Introduce Scanning (part 1 of your project) Lecture 1 Lecture 1 Course MechanicsCourse Mechanics – Quick review of basic concepts of formal ML Variable BindingsML Variable Bindings grammars Dan Grossman – Regular expressions Dan Grossman Fall 2011 – Lexical specificaon of programming languages Fall 2011 – Using finite automata to recognize regular expressions – Scanners anD Tokens Winter 2013 UW CSE 401 (Michael Ringenburg) B-11 Programming Language Specificaons CSE341: ProgrammingCSE341: Programming Languages Languages • Since the 1960s, the syntax of every significant programming language has been specifieD by a Lecture 1 Lecture 1 formal grammar Course MechanicsCourse Mechanics – If you ever have the “pleasure” of reading a language ML Variable BindingsML Variable Bindings specificaon Document, you’ll see that each secEon Dan Grossman typically consists of a formal grammar for some piece Dan Grossman Fall 2011 of the syntax, followeD by notes Describing the Fall 2011 semanEcs. – First Done in 1959 with BNF (Backus-Naur Form) grammar useD to specify ALGOL 60 syntax – BorroweD from the linguisEcs community (Chomsky) Winter 2013 UW CSE 401 (Michael Ringenburg) B-12 Review of Formal Languages anD Automata Theory CSE341: ProgrammingCSE341: Programming Languages Languages Oink!!! • Starring Mr. Pig Lecture 1 Lecture 1 • Alphabet: a finite set of symbols anD characters Course MechanicsCourse Mechanics – E.g., {‘iML’, ‘k’, ‘n’, ‘o’, ‘!’, ‘ ’} Variable BindingsML Variable Bindings • String: a finite, possibly empty sequence of Dan Grossman Dan Grossman symbols from an alphabet Fall 2011 Fall 2011 – E.g., “oink” • Language: a set of strings (possibly empty or infinite) – E.g., {“oink!”, “oink oink!”, “oink oink oink!”, …} Winter 2013 UW CSE 401 (Michael Ringenburg) B-13 Finite Specificaons of Possibly Infinite Languages • Automaton – a recognizer; a machine that accepts all CSE341: ProgrammingCSE341: Programming Languages Languages strings in a language (anD rejects all other strings) Lecture 1 Lecture 1 – E.g., a pig Detector: accepts all sequences of oinks, rejects Course Mechanics “moo”s or “Coursebaa”s Mechanics ML Variable Bindings • Grammar – a generator that proDuceD all strings in the ML Variable Bindings language (anD nothing else) Dan Grossman Dan Grossman – Unfortunately, we can’t use a pig as our grammar – no pig Fall 2011 (that I’ve met) can generate infinite “oink” sequences. Fall 2011 – Instead we use formal (aka mathemacal) grammars. • A parEcular language may be specifieD by many Different grammars anD automata – But, a grammar or automaton specifies only one language Winter 2013 UW CSE 401 (Michael Ringenburg) B-14 Language (Chomsky) hierarchy: quick reminder •

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    35 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us