turing machine simulation language
play

Turing Machine Simulation Language Isaac McGarvey Joshua Gordon - PowerPoint PPT Presentation

Turing Machine Simulation Language Isaac McGarvey Joshua Gordon Keerti Joshi Snehit Prabhu Overview What is a TM Basic language Read/Write, Moving along tape head, Control constructs, Arbitrary tape alphabet. Scope of Language


  1. Turing Machine Simulation Language Isaac McGarvey Joshua Gordon Keerti Joshi Snehit Prabhu

  2. Overview • What is a TM • Basic language Read/Write, Moving along tape head, Control constructs, Arbitrary tape alphabet. • Scope of Language – Single tape datastructure – Single pass compilation without look-ahead.

  3. Overview • Evolution of TMSL – Started with configuration file syndrome – Moved on to an ambitious high-level language plan – Converged on low-level scripting language with a tractable mapping from script to TM constructs. • Limitations – No function definitions or code reusability. – No arithmetic. – No variables.

  4. Language Overview • Grammar: – Our programs are composed of symbols and statements – A symbol list • which specifies the characters which may be written to and read from the tape (in addition to the special blank character) – A statement list • Which specifies control flow and commands • Statements are generally of two types: – Atomics (e.g., left, right, write, exit) – Composites (e.g., if, while, until, unless) • Composites are simply statements which contain lists of statements within their definition, e.g. – UNLESS LPAREN symbol_list RPARENLBRACE stmt_list RBRACE

  5. Writing a program: Unsigned subtraction • 0,1 /*alphabet specification */ • while (1) { • if (1) { • write _ • right • while (1) { • right • } • Sample Input : 1111011_ _ _ • Output : _ _ 11000 _ _ _ • Demo?

  6. Implementation • Machine Simulator – 2 scanners & parsers – Following transitions stored in list – Dynamically growing input tape

  7. Implementation • Compiler – Scanner & parser – AST types: statements, symbols – Code generation • Single pass: minimal semantic error checking • Translating statements into states and transitions • Bookkeeping: assigning state numbers to statements

  8. Implementation

  9. Summary and Lessons Learned Language Design concepts • Even out work through the semester • Test cases (Regression suite) • Good experience with the language • Its fun to build your own compiler!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend