MScheme

9
Advanced Programming 2009/2010 – Group 23 Rui Sebastião 56939 José Duarte Lourenço 58515 Sofia Teixeira 58600

description

MScheme. Advanced Programming 2009/2010 – Group 23 Rui Sebastião 56939 José Duarte Lourenço 58515 Sofia Teixeira 58600. Agenda. Architecture Input Processing Algorithm Environment Notion Extensions microScheme Reference. Architecture. Command pattern Recursion. Input Processing. - PowerPoint PPT Presentation

Transcript of MScheme

Advanced Programming 2009/2010 – Group 23Rui Sebastião 56939

José Duarte Lourenço 58515Sofia Teixeira 58600

Architecture

Input Processing◦ Algorithm

Environment Notion

Extensions

microScheme Reference

Command pattern

Recursion

Main Expression Parser

If-else structure

String matching with the language reference…

… Or Type Matching with language types

Check the car of incoming cons If it is a known command, execute it with

our eval nodes Inside each eval node:

◦ Evaluate recursively with Expression Parser the car of the expression received until it is of a known type

If it is of a known type, perform adequate evaluation◦ Self evaluating expressions◦ Cons expressions◦ Symbols that are Functions and must evaluate

again on Expression Parser

At the beginning of the program, an initial environment is set with the known symbols and keywords

On each let, let*,letrec instruction and lambda a new internal environment is pushed into our List of Environments

At the end of its execution, the stack pointer returns to the global environment

No push and pop operations: we don’t want to lose previous environments!

Exception handling

Approaching our types to the ones in Scheme

JFields

define lambda

cond, if write, display, newline, read

let, let*, letrec car, cdr, cons

+, -, *, /, remainder, quotientjcall, jnew, jmethod, jconstructor, jtype

beginJnull, jstring, jboolean, jchar,

jdouble, jfloat, jint, jlong, jbyte, jshort

<, >, >=, <= set!, set-car!, set-cdr!

not, eq?, =, null?‘, quote, list, apply, map,

list-ref, length

and, orprocedure?, number?, pair?, boolean?, list?, zero?, odd?,

even?