[ProofPower] PP on windows

Gregg Reynolds dev at arabink.com
Thu Jan 26 11:55:25 EST 2006


Rob Arthan wrote:
> 
...
> This is very interesting. I think you are actually using sieve etc. as the 
> basis of something quite different from what it is actually intended for (not 
> that there's anything wrong with that).
> 
Great Moments of Historical Serendipity?  You have inadvertently
provided the key that unlocked (for me, at least) the Grand Unified
Theory of All Text Munging.  Seriously!  I think it was the notion of
combining view with category that did it.

Think MVC pattern.  Then think GPHC:

	Grammar - Perspective - Handler - Controller

For sieve, this means replacing "category" with "grammar", and "filter"
with "handler".  The sieve file itself is the controller.

In an MVC application, the modeled object is pragmatic - it represents
some untidy aspect of the real world, like a person or my bank account.
 Maybe the model is accurate, maybe not; the only way to find out is for
end-users to work with the software.  But in (all?) text mungers the
object modeled is completely knowable and formally specified: model =
grammar.  (Exception:  natural language text.)

The controller - sieve's view file - maps grammatical productions (or
fragments, if desired) to handlers that represent a perspective on the
source file.

So e.g. instead of =SMLLABELLED etc, use just one =SML.  Actually, use
<sml>; see below.  Use a parameter to provide different labels to
different segments.  Alternatively, supply production names:
=SML funcdecl
or the like.  Then the handler can provide different labels for
different phrase classes.

Extended SML should not be =SML; it doesn't conform to the grammar, so
it is a different language.  That should be reflected in the category
label, not the handler.

A more sophisticated version:  the handler understands the grammar, so
it can pick out phrase classes and label them as directed by some kind
of stylesheet.  Or it can TeXify the code for a "publication"
perspective, syntax-check it for a "validity" perspective, compile it
for a "computation" perspective, etc.

With GPHC you can get total separation of the model, view, and handler.
 Or at least maximal encapsulation.

If you think about GPHC a bit you'll see that pretty much every text
transformation tool fits the pattern.  Parsers and compilers, for
example.  Why not provide support for multiple views in a parser
grammar?  Support splitting of handlers from grammars?  You can come up
with lots and lots of ideas for generic, multilanguage text mungers,
many of which can probably be hacked together out of existing code
fairly easily.

Sieve has provoked such a flood of ideas in my little grey cell I don't
know if I'll ever get to PP proper. ;)  I've got more, but I think I'll
post them on a web page instead of filling up everybody's mailboxes.
> 
> I should also add that if I was thinking about designing anything like sieve 
> today, I would find it difficult to justify not using XML and I'd hope that 
> there'd be some usable XML technology out there to help. (See Roger's posting 
> for more info on what he's been doing in that area).
> 
Problem solved.  All you need to do is mark up the doc file using CDATA
sections.  Instead of =SML, use sth like:

	  <cat name="sml" parms="foo bar">
	  <![CDATA[ ...sml code here... ]]>
	  </cat>

You could also:  <sml parms="foo bar"> to keep it short(er).

Embedded in C code:

	  <c><![CDATA[
	  ...C code here...
	  /*
	  ]]></c>
	  <tex><![CDATA[ ...text stuff here... ]]></tex>
	  <c><![CDATA[
	  */

It's a little ugly, but it should work.

Then just write an XSLT stylesheet to munge the content as needed.
Parameterize it for views.  Use XALAN extensions, or add an extension to
support shell scripts or whatever is needed.  See

http://xml.apache.org/xalan-j/extensions.html

This approach has at least two things going for it.  One, you no longer
have to maintain a specialized tool.  Two, "XML-enabled" makes PP more
marketable.  Three, you automatically get whatever functionality others
made add to XALAN.  Seventh, you can use specialized XSL editors to
create your handlers.

Cheers,

gregg




More information about the Proofpower mailing list