Monday, July 16, 2012

Illness, beer and steam

So yeah did a bit of that stuff.
But due to a mate's party to use up home brew not as much as I'd hoped.
This weekend my son is sick and steam is having a sale.
Then my son got sick.
So didn't do much on coding.
Also didn't get much time to work on a post over the weekend.

But I'm having wicked writers block right now on a couple of parsers, formaters and conditional logic engines.
So to clear the tubes I thought I'd write quick post on something unlike the other project I have done alot of work on.

I am talking about compiler compilers, or if you would prefer rules engines, or code that generates rules engines, or etl, or machine learning.. Look alot of things are around which are all the same thing this.

What is this? We this is a system, logic of sort that generates other logic based on arbitrary source data.
The source data could be anything, it could be rules, airline fares, server logs, usage logs, transaction records, data about something or some one, data structures to be processed, something completely different or a combination of these.

So we have our source structures and we want to drive behaviour based on them. The process of doing this is actually easy. We build a framework to construct a working logical structure made up of the various tokens in the source data. In early projects I found that simple lexical analyse worked well for creating these structures, since I've found that contextual analyse often allows for greater flexibility in this construction.

Now we assign a behavioural value to the structure, this behavioural value will relate to what we actually do based on the model.

Well my writers block is going..But so this is more than mindless babling an example.
A simple one.

Lets say you want to build a web application to I dont know... catelogue your son's skylander collection.
But your lazy and you just want to design the page with what it looks like and nothing else.
In this case we use two special elements coreValue and coreValueRepeat. The existance of these values indicates the data needs to exist.
We construct a in memory structure, database, view page, edit page, create page, search page and summary page from how these are used in the one html file.

And our input? Simply:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/html">
<head>
    <title><coreValue src="name" type="alpha"/></title>
</head>
<body>
<div class="Title"> <coreValue src="name" type="alpha"/>
</div>
<div class="Description">
    <h1>Description of <coreValue src="name"/></coreValue> </h1>
    <p><coreValue src="ours.hasIt" type="boolean"/> <coreValue src="ours.maxLevel" type="boolean"/> <coreValue src="ours.fullUpgrades" type="boolean"/></p>
    <p><coreValue src="description" type="alpha"/></p>
</div>
<div class="Stats">
    <h1>Statistics for <coreValue src="name"/></coreValue> </h1>
    <p>Power: <coreValue src="statistic.power" type="int"/></p>
    <p>Defense: <coreValue src="statistic.defense" type="int"/></p>
    <p>Speed: <coreValue src="statistic.speed" type="int"/></p>
    <p>Luck: <coreValue src="statistic.Luck" type="int"/></p>
</div>
<div class="Abilities">
    <h1>Abilities for <coreValue src="name"/></coreValue> </h1>
    <coreValueRepeat src="abilities">
     <p><b></b><coreValue src="name" type="alpha"/></b></p>
        <p><coreValue src="description" type="alpha"/></p>
        <coreValueRepeat src="upgrates">
            <p>Name: <coreValue src="name" type="alpha"/></p>
            <p>Description: <coreValue src="description" type="alpha"/></p>
            <p>Cost: <coreValue src="cost" type="int"/></p>
        </coreValueRepeat>
    </coreValueRepeat>
</div>


</body>
</html>

From this file the building blocks for the entire web application are present, as such or compiler compiler will build the application for us.
There are many other ways we can use these for us..

No comments:

Post a Comment