Sunday, January 13, 2008

The SpanLayer

In this post I'm going to continue two threads from previous posts.

First, I mentioned previously that I think of modeling as object-orientation with first-class relationships between the objects and I talked about the containment relationship which is built into the lattice metamodel. In this post I want to talk about implementing another kind of relationship as a layer called the SpanLayer.

Second, I've described the Gem syntax and noted that it has no pre-assigned semantics. Here I'm going to reach into this toolbox of syntax and begin assigning meaning to it.

The idea of the SpanLayer is to build a hashtable that maps some of the facets to others. We will interpret the ` (back-tick) prefixing a Word as designating the target (or end-point) of a "span" and the ~ (tilde) prefixing a Word as designating the source (or start-point) of a span.

Let's look at an example:



The text for the above model looks like this:
`foo `bar [ a b ~foo (c ~bar ~foo) ]
The SpanLayer shown in the diagram is simply highlighting the sources and targets of the spans by blanking out the text for the facets that aren't related to spanning. This is ok for a start, but it would be better to show spans more like this:



Here the span targets are shown with a different shape and the spans themselves are drawn from source to target. This FancySpanLayer was built on top of the SpanLayer. It uses the raw span information provided by the SpanLayer and renders it in a more sensible way.

0 comments: