Wizard of House Management Programming Language and Translators

  • Slides: 20
Download presentation
Wizard of House Management -Programming Language and Translators Project Rui Kuang Arvid Bessen Andrey

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

WHOM l l l A programming language for creation and management of a household

WHOM l l l 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

Goals l l l Simple Powerful Event-driven Object-oriented Extendible

Goals l l l Simple Powerful Event-driven Object-oriented Extendible

What Can WHOM Do? l l l Specify how objects respond to changing conditions

What Can WHOM Do? l l l 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

Why WHOM? l l Provides easy-to-use event handling, which is important in house manipulation

Why WHOM? l l Provides easy-to-use event handling, which is important in house manipulation Easy to use even for non-programmers

Syntax and Semantics l l Java-like syntax Basic Types: – – l l number

Syntax and Semantics l l Java-like syntax Basic Types: – – l l 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

Recipe l l Import library Class definition – – – l l Attributes (class

Recipe l l Import library Class definition – – – l l Attributes (class objects, number or string variables) Methods Inclass events (trigged by hardware) Variable declaration Event implementation – – In-class event Logic condition

Example // foo. wl string msg; class foo{ number foo_num; void who_am_i(void){ msg =

Example // foo. wl string 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. whom Import “whom. wl”, “foo. wl”; foo a; cfoo b; once (SECOND == 30){ a. who_am_i(); } once (SECOND == 0){ b. who_am_i(); }

Example import whom. wl; //class specification class Adjustable. Lamp extends Light{ number brightness =

Example import whom. wl; //class specification class Adjustable. Lamp extends Light{ number brightness = 0; void self. Adjust(){ brightness = (LIGHTNESS/10. 0)*3. 0; } EVENT_BUBBLE_DAD; } Adjustable. Lamp lamp; number old. Lightness = 0; once (old. Lightness–LIGHTNESS>4){ lamp. self. Adjust(); old. Lightness = LIGHTNESS; } once lamp. EVENT_BUBBLE_BAD{ lamp. brightness=0; }

The Backend – Main Challenges l l Event-driven Support for complex scoping rules (nested)

The Backend – Main Challenges l l Event-driven Support for complex scoping rules (nested) – – – l l static / global dynamic / stack classes, subclasses Class hierarchy Object-oriented for object-oriented language: Classes corresponding to aspects of the language

Overview – Main Classes l Observable. Object and Event – – l l l

Overview – Main Classes l Observable. Object and Event – – l l l Events subscribe to Observable. Objects Subscribers notified if Observable. Object changes Expression and Statement Scopes: Parsing. Scope and Instantiated. Scope Classes

Walking the Tree l l l Get variables / objects for name (existence check)

Walking the Tree l l l 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, . . .

Execution l l l Variable changes: all events listening to it reevaluate their conditions

Execution l l l 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

WHOM Testing l Intended Execution environment: – l Viable solution: – l An embedded

WHOM Testing l Intended Execution environment: – l Viable solution: – l An embedded system. Software Emulator Testing solution: – WEM & Organized test programs.

WEM – [W]HOM [EM]ulator l Emulation Features – – – Full display of current

WEM – [W]HOM [EM]ulator l 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.

WEM – Debugging Tools

WEM – Debugging Tools

WEM – Organized Test Programs l Tier 1 – Source parsing & WHOM syntax.

WEM – Organized Test Programs l Tier 1 – Source parsing & WHOM syntax. – l whitespace parsing, comment parsing… Tier 2 – Backend logic – – – declaration of classes global variables real-time variables conditional statements loops

WEM – Organized Test Programs l Tier 3 – Event logic – – l

WEM – Organized Test Programs l Tier 3 – Event logic – – l event logic events triggered by real-time / environment variables Tier 4 – Advanced concepts – – recursion dynamically updated real-time variables

WEM – Organized Test Programs l Toy Box Tier – ‘Hack’ programs – l

WEM – Organized Test Programs l Toy Box Tier – ‘Hack’ programs – l 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.

Lessons Learned l l Everything is more complicated than it appears… But without complexity

Lessons Learned l l 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…)