Wednesday, October 8, 2008

Smpl Compiler Milestone 1 Complete!

This blog post is a bit late. Our plan for completion of milestone 1 on the compiler was the end of August, 2008. We finished a couple of weeks late, about mid September. Not bad, considering that at one point our schedule showed completion in 2009!

Milestone 1 included the highest risk areas:
  • Nearly all of the Smpl lexer/parser, including basic table support.
  • The start of a type checker.
  • The basic engine features necessary to do something with Smpl: Schema, category membership, templates, basic functions.
  • Textual output.

How does it look? Good. Real good. No, I mean, really, really good!

We're now building demos. Here's some examples of how good:

DSL/DSM/Code Generation:
  • Hardware module specification. This demonstrates using Smpl to model an ASIC VHDL or Verilog module, including description, dates, Generics, and Interfaces (Ports). The Smpl schema for this example was 18 lines of code. The generation of a VHDL module entity from a Smpl model is 40 lines of code. The generation of a professional Tex document specification from the model used 30 lines of Smpl code. In none of this code did I have to think about how to lex or parse my DSL, or how to construct the abstract syntax tree, or how to patch up references, or any of the stuff you usually have to do when writing a DSL. This entire process would take about 1-2 hours!
  • Object Relational Mapping. We created an object oriented Smpl model of a database. From this model, we do a two step translation (ORM Model to SQL Model, then SQL Model to SQL Text) that generates the SQL code that creates the database. ORM Schema: 20 lines; SQL Schema: 20 lines; Translation from ORM to SQL: 50 lines; Translation from SQL Model to SQL Text: 45 lines. This is just the beginning (it doesn't handle queries yet), but it creates all tables and foreign keys to handle object inheritance and references. That's only 135 lines of code, ritten in a few hours!

How about small business/organization automation:
  • A consulting business' client list, hour logs, and billing. This application uses Smpl to model client's contact information, projects, contract details, and consultant timesheets. Foreach project, it will generate an e-mail to each client containing a Word document attachment showing hours, rate, and total bill. Yes, a Microsoft Word Document (thanks for .docx, Microsoft!) Schema: 18 lines: translation to E-mail & Word Document: 70 lines. That includes the text of the e-mail message! Oh yeah, and I should mention that the word document template (Smplified) is 78 lines of code--but I didn't have to write that--smplc generated it from the .docx file for me!
  • Church organization model. This allows describing the parts of the organization, the members and what parts they are involved in, and a calendar, and generates: E-mail lists for all, parts, or specific members (either by name or by title) of the organization, Reminder e-mails, Web site, and a Word Document directory. The entire Smpl code is roughly 250 lines. Wow!
What does the Smpl look like, you ask? I'm not yet ready to present the details, but I will give you a couple of example models. The following is real code. Read by the computer. Processed and generating the above described artifacts.

An up/down counter module specification in Smpl looks like:

Up Down Count : Module
Description:
This module is a simple n bit unsigned counter, where n is a generic,
supports counting up, down, or pausing. The counter can be reset, count
up, or count down based on inputs.
Initial Version: 5/21/2008
Generic:
Bits
Description: The number of bits used to represent the count value.

Port: Direction Width Description
--------------------------------------------------------------------------------
Clock in System clock.
Reset in Reset the count.
Count Up in If true, the counter counts up each clock cycle.
Count Down in If true (and Count Up is false), counts down.
Count out Bits Current count value.



A consultant's client and billing data looks like:


Company:
Boeing
Address: 1 Boeing Lane
City State Zip: Tacoma, WA 98765

Project:
Superconductor Research
Contact: Bill Jones
Contact Email: bill@yo.com
Client: Boeing
Under Contract:
Consultant Rate
--------------------
Phil Smith 95
Bob Wilson 110

Engine Mount Design
Contact: Tom Smith
Contact Email: tom@dude.com
Client: Boeing
Under Contract:
Consultant Rate
--------------------
Bob Wilson 90

:Hour Log
For: Phil Smith
Entry:
Date For Project Hours
-------------------------------------
9/2 Superconductor Research 4
9/12 Superconductor Research 8
9/24 Superconductor Research 3

:Hour Log
For: Bob Wilson
Entry:
Date For Project Hours
-------------------------------------
9/3 Superconductor Research 3
9/12 Engine Mount Design 9
9/21 Superconductor Research 4


There is still a lot of work ahead. We're looking for professionals to join us, especially on the marketing side. Its time to take this technology out of the lab, and make it available to the masses.