wizard of house management - programming language and translators project

20
Wizard of House Management -Programming Language and Translators Project Rui Kuang Arvid Bessen Andrey Butov Svetlana Starshinina

Upload: xenos-guerra

Post on 30-Dec-2015

19 views

Category:

Documents


0 download

DESCRIPTION

Wizard of House Management - Programming Language and Translators Project. Rui Kuang Arvid Bessen Andrey Butov Svetlana Starshinina. WHOM. A programming language for creation and management of a household Language of the future: expanding the use of computers in our everyday lives - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Wizard of House Management - Programming Language and Translators Project

Wizard of House Management-Programming Language and Translators Project

Rui KuangArvid BessenAndrey ButovSvetlana Starshinina

Page 2: Wizard of House Management - Programming Language and Translators Project

WHOM

A programming language for creation and management of a household

Language of the future: expanding the use of computers in our everyday lives

Allows automation of tedious tasks

Page 3: Wizard of House Management - Programming Language and Translators Project

Goals

Simple Powerful Event-driven Object-oriented Extendible

Page 4: Wizard of House Management - Programming Language and Translators Project

What Can WHOM Do?

Specify how objects respond to changing conditions (environmental object states)

Example: if it rains, close all windows & turn off the sprinklers

Another example: if a window is broken, set off the alarm, call the police

Page 5: Wizard of House Management - Programming Language and Translators Project

Why WHOM?

Provides easy-to-use event handling, which is important in house manipulation

Easy to use even for non-programmers

Page 6: Wizard of House Management - Programming Language and Translators Project

Syntax and Semantics

Java-like syntax Basic Types:

– number and string– realtime and normal

Library support with “import” Object-oriented (“class”, “extends”) Static semantics analysis done in both AST walker and

backend Error handling class catches all the errors from Lexer,

Parser, AST walker and backend to log window for displaying

Page 7: Wizard of House Management - Programming Language and Translators Project

Recipe

Import library Class definition

– Attributes (class objects, number or string variables)– Methods– Inclass events (trigged by hardware)

Variable declaration Event implementation

– In-class event– Logic condition

Page 8: Wizard of House Management - Programming Language and Translators Project

Example

// foo.wlstring msg;

class foo{ number foo_num; void who_am_i(void){ msg = "I am the father"; }}

class cfoo extends foo{ void who_am_i(void){ msg = "I am the child"; } }

//example.whomImport “whom.wl”,“foo.wl”;foo a;cfoo b;

once (SECOND == 30){ a.who_am_i();}

once (SECOND == 0){ b.who_am_i();}

Page 9: Wizard of House Management - Programming Language and Translators Project

Example

import whom.wl;//class specificationclass AdjustableLamp extends Light{ number brightness = 0; void selfAdjust(){ brightness = (LIGHTNESS/10.0)*3.0; } EVENT_BUBBLE_DAD;}

AdjustableLamp lamp;

number oldLightness = 0;

once (oldLightness–LIGHTNESS>4){

lamp.selfAdjust();

oldLightness = LIGHTNESS;

}

once lamp.EVENT_BUBBLE_BAD{

lamp.brightness=0;

}

Page 10: Wizard of House Management - Programming Language and Translators Project

The Backend – Main Challenges

Event-driven Support for complex scoping rules (nested)

– static / global– dynamic / stack– classes, subclasses

Class hierarchy Object-oriented for object-oriented language: Classes

corresponding to aspects of the language

Page 11: Wizard of House Management - Programming Language and Translators Project

Overview – Main Classes

ObservableObject and Event– Events subscribe to ObservableObjects– Subscribers notified if ObservableObject changes

Expression and Statement Scopes: ParsingScope and InstantiatedScope Classes

Page 12: Wizard of House Management - Programming Language and Translators Project

Walking the Tree

Get variables / objects for name (existence check) Get methods (dynamic) Construct expressions out of them (type checking) Construct statement out of expressions Statements + scope: block Associate block with surrounding block, method, event,

...

Page 13: Wizard of House Management - Programming Language and Translators Project

Execution

Variable changes: all events listening to it reevaluate their conditions

Condition holds: execute associated block by executing statements, by executing expressions.

Nifty features:– Recursion– Subclassing / polymorphism

Page 14: Wizard of House Management - Programming Language and Translators Project

WHOM Testing

Intended Execution environment: – An embedded system.

Viable solution: – Software Emulator

Testing solution:– WEM & Organized test programs.

Page 15: Wizard of House Management - Programming Language and Translators Project

WEM – [W]HOM [EM]ulator

Emulation Features– Full display of current state of household.– Dynamic update of external variables such as time.– Ability to affect the behavior of the system by modifying

environment variables.

Page 16: Wizard of House Management - Programming Language and Translators Project

WEM – Debugging Tools

Page 17: Wizard of House Management - Programming Language and Translators Project

WEM – Organized Test Programs

Tier 1 – Source parsing & WHOM syntax.– whitespace parsing, comment parsing…

Tier 2 – Backend logic– declaration of classes– global variables– real-time variables – conditional statements – loops

Page 18: Wizard of House Management - Programming Language and Translators Project

WEM – Organized Test Programs

Tier 3 – Event logic– event logic– events triggered by real-time / environment

variables

Tier 4 – Advanced concepts– recursion– dynamically updated real-time variables

Page 19: Wizard of House Management - Programming Language and Translators Project

WEM – Organized Test Programs

Toy Box Tier – ‘Hack’ programs– Temporary programs. If proven useful, will be

moved to one of the primary tiers as part of the standard round of testing.

Experimental Tier – What If…?– Code which is ‘theoretically’ possible, but useful for

no more than personal curiosity.

Page 20: Wizard of House Management - Programming Language and Translators Project

Lessons Learned

Everything is more complicated than it appears…

But without complexity there is no fun!

We had a lot of fun working on WHOM…… (We don’t want to live in an automated

house…)