cs 3240 languages and computation n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CS 3240: Languages and Computation PowerPoint Presentation
Download Presentation
CS 3240: Languages and Computation

Loading in 2 Seconds...

play fullscreen
1 / 72

CS 3240: Languages and Computation - PowerPoint PPT Presentation


  • 152 Views
  • Uploaded on

CS 3240: Languages and Computation. Course Overview Sasha Boldyreva. Personnel. Instructor: Alexandra (Sasha) Boldyreva Email: aboldyre@cc.gatech.edu Office: Klaus 3444 Office Hours: Tue. & Wed. at 2:00 to 3:00 pm Or by appointment TAs: TBA Email: TBA Office Hours: TBA.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

CS 3240: Languages and Computation


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. CS 3240: Languages and Computation Course Overview Sasha Boldyreva

    2. Personnel • Instructor: Alexandra (Sasha) Boldyreva • Email: aboldyre@cc.gatech.edu • Office: Klaus 3444 • Office Hours: • Tue. & Wed. at 2:00 to 3:00 pm • Or by appointment • TAs: TBA • Email: TBA • Office Hours: TBA

    3. Required Textbooks Bundle ISBN# 1418879746, including • “Compiler Construction Principles and Practice” by Kenneth C. Louden, Thompson Course Technology, 1997, ISBN 0534939724 • “Introduction to Theory of Computation, Second Edition” by Michael Sipser, Thompson Course Technology, 2005, ISBN 0534950973

    4. Course Objectives • Formal languages • Understand definitions of regular and context-free languages and their corresponding “machines” • Understand their computational powers and limitations • Compiler concepts • Understand their applications in compilers • Front-end of compiler • Lexical analysis, parsing, semantic analysis • Theory of computation • Understand Turing machines • Understand decidability

    5. Course Syllabus Lexical analysis, scanners, pattern matching Regular expressions, DFAs, NFAs and automata Limits on regular expressions, pumping lemma Practical parsing, LL and LR parsing Context-free languages, grammars, Chomsky Hierarchy Pushdown automata, deterministic vs. non-deterministic Attribute grammars, type inferencing Context-free vs. context-sensitive grammars Decidable vs. Undecidable problems, Turing Machines, Halting Problem Complexity of computation, classes of languages P/NP, space and time completeness

    6. Grading • Homeworks: 25% • Mini-project: 15% • Midterm : 30% • Final: 30% • Homeworks to be submitted in class - hardcopy • No late homework or assignments • Homework should be concise, complete, and precise • Tests will be in class

    7. Class Policies • Students must write solutions to assignments completely independently • General discussions are allowed on assignments among students, but names of collaborators must be reported • Cell phones off, silence please

    8. Resources • Class webpage: see T-Square • Check for schedule changes.

    9. Introduction toCompiler Concepts

    10. Compilers • What is a compiler? • A program that translates an executable program from source language into target language • Usually source language is high-level language, and target language is object (or machine) code • Related to interpreters • Why compilers? • Programming in machine (or assembly) language is tedious, error prone, and machine dependent • Historical note: In 1954, IBM started developing FORTRAN language and its compiler

    11. Why study theory of compiler? • Besides it is required… • Prerequisite for developing advanced compilers, which continues to be active as new computer architectures emerge • Useful to develop software tools that parse computer codes or strings • E.g., editors, debuggers, interpreters, preprocessors, … • Important to understand how compliers work to program more effectively

    12. How Does Compiler Work? Scanner Request Token Get Token Start Parser • Front End: Analysis of program syntax and semantics Semantic Action Semantic Error Checking Intermediate Representation

    13. Parts of Compilers Focus of this class. Analysis Front End 1. Lexical Analysis 2. Syntax Analysis 3. Semantic Analysis Synthesis Back End 4. Code Generation 5. Optimization

    14. The Big Picture • Parsing: Translating code to rules of grammar. Building representation of code. • Scanning: Converting input text into stream of known objects called tokens. Simplifies parsing process. • Grammar dictates syntactic rules of language i.e., how legal sentence could be formed • Lexical rules of language dictate how legalword is formed by concatenating alphabet.

    15. Overall Operation • Parser is in control of the overall operation • Demands scanner to produce a token • Scanner reads input file into token buffer & forms a token (How?) • Token is returned to parser • Parser attempts to match the token (How?) • Failure: Syntax Error! • Success: • Does nothing and returns to get next token, or • Takes semantic action

    16. Overall Operation • Semantic action: look up variable name • If found okay • If not: put in symbol table • If semantic checks succeed, do code-generation (How?) • Continue to get next token • No more tokens? Done!

    17. Scanning/Tokenization Input File Token Buffer • What does the Token Buffer contain? • Token being identified • Why a two-way ( ) street? • Characters can be read • and unread • Termination of a token

    18. Example main() m

    19. Example main() am

    20. Example main() iam

    21. Example main() niam

    22. Example main() (niam

    23. Example main() niam Keyword: main

    24. Parser • Translating code to rules of a grammar • Control the overall operation • Demands scanner to produce a token • Failure: Syntax Error! • Success: • Does nothing and returns to get next token, or • Takes semantic action

    25. Grammar Rules <C-PROG>  MAIN OPENPAR <PARAMS> CLOSEPAR <MAIN-BODY> <PARAMS>  NULL <PARAMS>  VAR <VAR-LIST> <VARLIST>  , VAR <VARLIST> <VARLIST>  NULL <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE> VAR <VAR-LIST>; <ASSIGN-STMT>  VAR = <EXPR>; <EXPR>  VAR <EXPR>  VAR<OP><EXPR> <OP>  + <OP>  - <TYPE>  INT <TYPE>  FLOAT

    26. Demo main() { int a,b; a = b; } Scanner Token Buffer Parser

    27. Demo main() { int a,b; a = b; } Scanner Token Buffer "Please, get me the next token" Parser

    28. Demo main() { int a,b; a = b; } Scanner m Parser

    29. Demo main() { int a,b; a = b; } Scanner am Parser

    30. Demo main() { int a,b; a = b; } Scanner iam Parser

    31. Demo main() { int a,b; a = b; } Scanner niam Parser

    32. Demo main() { int a,b; a = b; } Scanner (niam Parser

    33. Demo main() { int a,b; a = b; } Scanner niam Parser

    34. Demo main() { int a,b; a = b; } Scanner Token Buffer Token: main Parser

    35. Demo main() { int a,b; a = b; } Scanner Token Buffer Parser "I recognize this"

    36. Parsing (Matching) • Start matching using a rule • When match takes place at certain position, move further (get next token & repeat) • If expansion needs to be done, choose appropriate rule (How to decide which rule to choose?) • If no rule found, declare error • If several rules found, the grammar (set of rules) is ambiguous

    37. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner "Please, get me the next token" Parser

    38. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: MAIN Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY>

    39. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner "Please, get me the next token" Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY>

    40. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: OPENPAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY>

    41. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: CLOSEPAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <PARAMETERS>  NULL

    42. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: CLOSEPAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <PARAMETERS>  NULL

    43. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: CLOSEPAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY>

    44. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: CURLYOPEN Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE

    45. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: INT Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <TYPE>  INT

    46. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: INT Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <TYPE>  INT

    47. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: INT Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <TYPE>  INT

    48. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: VAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <VARLIST>  , VAR <VARLIST> <VARLIST>  NULL

    49. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: ',' [COMMA] Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <VARLIST>  , VAR <VARLIST> <VARLIST>  NULL

    50. Scanning & Parsing Combined main() { int a,b; a = b; } Scanner Token: VAR Parser <C-PROG>  MAIN OPENPAR <PARAMETERS> CLOSEPAR <MAIN-BODY> <MAIN-BODY>  CURLYOPEN <DECL-STMT> <ASSIGN-STMT> CURLYCLOSE <DECL-STMT>  <TYPE>VAR<VAR-LIST>; <VARLIST>  , VAR <VARLIST> <VARLIST>  NULL