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

turing machine simulation language
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Turing Machine Simulation Language

Isaac McGarvey Joshua Gordon Keerti Joshi Snehit Prabhu

slide-2
SLIDE 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.

slide-3
SLIDE 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.

slide-4
SLIDE 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

slide-5
SLIDE 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?
slide-6
SLIDE 6

Implementation

  • Machine Simulator

– 2 scanners & parsers – Following transitions stored in list – Dynamically growing input tape

slide-7
SLIDE 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
slide-8
SLIDE 8

Implementation

slide-9
SLIDE 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!