200 likes | 304 Views
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
E N D
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 • Allows automation of tedious tasks
Goals • Simple • Powerful • Event-driven • Object-oriented • Extendible
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
Why WHOM? • Provides easy-to-use event handling, which is important in house manipulation • Easy to use even for non-programmers
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
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
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 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; }
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
Overview – Main Classes • ObservableObject and Event • Events subscribe to ObservableObjects • Subscribers notified if ObservableObject changes • Expression and Statement • Scopes: ParsingScope and InstantiatedScope • Classes
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, ...
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
WHOM Testing • Intended Execution environment: • An embedded system. • Viable solution: • Software Emulator • Testing solution: • WEM & Organized test programs.
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.
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
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
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.
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…)