<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>

<feed xmlns="http://purl.org/atom/ns#" version="0.3" xml:lang="en-US">
<link href="https://www.blogger.com/atom/21999460" rel="service.post" title="Little Languages" type="application/atom+xml"/>
<link href="https://www.blogger.com/atom/21999460" rel="service.feed" title="Little Languages" type="application/atom+xml"/>
<title mode="escaped" type="text/html">Little Languages</title>
<tagline mode="escaped" type="text/html">in which the authors cook up disposable little languages for the amusement of all.</tagline>
<link href="http://littlelanguages.com/" rel="alternate" title="Little Languages" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460</id>
<modified>2006-04-17T08:56:05Z</modified>
<generator url="http://www.blogger.com/" version="6.72">Blogger</generator>
<info mode="xml" type="text/html">
<div xmlns="http://www.w3.org/1999/xhtml">This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site. Please visit the <a href="http://help.blogger.com/bin/answer.py?answer=697">Blogger Help</a> for more info.</div>
</info>
<convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">false</convertLineBreaks>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114526416534341179" rel="service.edit" title="Inversion" type="application/atom+xml"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-04-17T01:39:00-07:00</issued>
<modified>2006-04-17T08:56:05Z</modified>
<created>2006-04-17T08:56:05Z</created>
<link href="http://littlelanguages.com/2006/04/inversion.html" rel="alternate" title="Inversion" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114526416534341179</id>
<title mode="escaped" type="text/html">Inversion</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>I want to talk briefly about a powerful language implementation technique, but I don't have any sample code for this one, because any sample code I provided would have all sorts of little fiddly bits which would distract from my main point. The technique is <b>inversion</b>, and it is increadibly powerful.</p>

<p>
I could tell you that inversion is the process of turning a program into a tool, or that inversion is the act of re-writing a program to externalize it's game logic, or even that inversion is the process by which an API is wedded directly to a runtime environment, and the program is left for later. Maybe these descriptions are helpful, maybe they aren't, but they do set the stage.
</p>

<p>
Let's say that I've got a program which does something with, say, image files. That program is supported by a large API, and the API is supported by a complex environment which must be setup and torn down. So the program, roughly speaking, runs like this: first, it parses its arguments, and exits early if there is a problem (or help was asked for), then it sets up its environment, then it runs it core logic, a rather small program "written" in the language of the API, which actually does the work, then it tears everything down, and exits. If you want to add a new feature, you need to add a new bit to the API, or to the core logic, and sometimes to both. But as the API grows more powerful, more and more features are just additions to the core logic. And the core logic needs to be very general, because it can't be changed by the end user.
</p>

<p>
To invert such a program, we would stick a language interpreter in where the core logic currently resides (a big deal for compiled languages, but trivial for scripting languages). Then, interesting new applications of the API can be had by putting together a new little core program which runs in a language defined in terms of abstractions on the API, and that program can be very simple, because it need only handle its immediate application.
</p>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114383087230352056" rel="service.edit" title="YubNub and Articulated Keywords" type="application/atom+xml"/>
<link href="http://yubnub.org/" rel="related" title="YubNub and Articulated Keywords" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-03-31T10:43:00-08:00</issued>
<modified>2006-04-02T00:55:39Z</modified>
<created>2006-03-31T18:47:52Z</created>
<link href="http://littlelanguages.com/2006/03/yubnub-and-articulated-keywords.html" rel="alternate" title="YubNub and Articulated Keywords" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114383087230352056</id>
<title mode="escaped" type="text/html">YubNub and Articulated Keywords</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Previously, I posted on <a href="/2006/02/articulated-keywords.html">articulated keywords</a>, which might better be described as <b>location bar commands</b>. Well, <a href="http://yubnub.org/">YubNub</a> is location bar commands writ large. The service provides a means of matching (and acting on) hundreds (thousands?) of commands, of defining new commands, and of commenting <i>on</i> the commands. All from adding a single keyword bookmark.</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114344808592287503" rel="service.edit" title="XML Macros" type="application/atom+xml"/>
<link href="http://littlelanguages.com/web/languages/xmlmacros/" rel="related" title="XML Macros" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-03-27T00:12:00-08:00</issued>
<modified>2006-03-27T08:28:57Z</modified>
<created>2006-03-27T08:28:05Z</created>
<link href="http://littlelanguages.com/2006/03/xml-macros.html" rel="alternate" title="XML Macros" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114344808592287503</id>
<title mode="escaped" type="text/html">XML Macros</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>There are many complex things which can be done with XSLT, and because of this, many people overlook the very simple things which XSLT can also provide. Previously, I discussed XSLT page compilers, but there is a technique buried in that idea which I thought should get some more light, so I'm presenting it here as it's own thing.</p>

<p>
Due to the way that XSLT processing descends, it is possible to use the XSLT identity transform in adition to some <i>simple</i> templates to write XSLT transformations which behave very similarly to hygenic macros (possibly identically, but my Scheme is still weak, so I'm avoiding that statement). You can extend existing XML languages with new elements, and use simple XSLT documents to resolve those elements down to the base language which you are extending.
</p>

<p>
This often proves to be a powerful technique, especially when designing <i>new</i> languages, as a macro resolving transformation can be performed on your new language before the transformation which provides its semantics, dramatically reducing the implementation complexity. The basic approach resolves arround that old workhorse of XSLT hackers, the identity transform:
  </p>
<pre>&lt;xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

&lt;!--
 ! This transform provides a guide towards defining
 ! XML macros using XSLT. We expand only our XML
 ! extensions, and preserve everything else in a
 ! document.
 +--&gt;

&lt;xsl:template match="node()"&gt;
  &lt;!--
   ! This is an identity template in XSLT. However,
   ! due to the very low specificity (a technical
   ! aspect of XSLT) of the match, other templates
   ! will override this one when they match.
   +--&gt;
  &lt;xsl:copy&gt;
    &lt;xsl:for-each select="attribute::*"&gt;
      &lt;xsl:copy/&gt;
      &lt;/xsl:for-each&gt;
    &lt;xsl:apply-templates/&gt;
    &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;

&lt;xsl:template match="bi"&gt;
  &lt;!--
   ! This defines the element 'bi',
   ! which is both bold and italic.
   +--&gt;
  &lt;b&gt;&lt;i&gt;
    &lt;xsl:apply-templates/&gt;
    &lt;/i&gt;&lt;/b&gt;
  &lt;/xsl:template&gt;

&lt;xsl:template match="def"&gt;
  &lt;!--
   ! This defines the element 'def',
   ! which provides a link to search the web
   ! for the definition of a term.
   +--&gt;
  &lt;a href="http://google.com/search?q=define%3A{.}"&gt;
    &lt;xsl:value-of select='.'/&gt;
    &lt;/a&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:transform&gt;</pre>

Which permits us to transform this input document, which isn't <i>quite</i> HTML:
<pre>&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Sample&lt;/title&gt;
  &lt;/head&gt;
&lt;body&gt;
Here is &lt;bi&gt;my&lt;/bi&gt; page,
 and I like &lt;def&gt;monkeys&lt;/def&gt;.
  &lt;/body&gt;
  &lt;/html&gt;</pre>
Into this output document, which <i>is</i> pure HTML:
<pre>&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type"
 content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Sample&lt;/title&gt;
  &lt;/head&gt;
&lt;body&gt;
Here is &lt;b&gt;&lt;i&gt;my&lt;/i&gt;&lt;/b&gt; page,
 and I like
 &lt;a href="http://google.com/search?q=define%3Amonkeys"&gt;monkeys&lt;/a&gt;.
  &lt;/body&gt;
  &lt;/html&gt;</pre>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114180498991792154" rel="service.edit" title="List Resolution Techniques for Grammar Development" type="application/atom+xml"/>
<link href="http://press.samedi-studios.com/drafts/dunnavant2004list_resolution/dunnavant2004list_resolution.pdf" rel="related" title="List Resolution Techniques for Grammar Development" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-03-07T23:53:00-08:00</issued>
<modified>2006-03-08T09:15:49Z</modified>
<created>2006-03-08T08:03:09Z</created>
<link href="http://littlelanguages.com/2006/03/list-resolution-techniques-for-grammar.html" rel="alternate" title="List Resolution Techniques for Grammar Development" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114180498991792154</id>
<title mode="escaped" type="text/html">List Resolution Techniques for Grammar Development</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This is a paper I wrote a while back, cribbed together from a utility fragment of my thesis. It doesn't present anything new, but I think it does a good job of communicating some techniques which are quite useful in practical grammar developmen, a subject which I have always thought was to little discussed. It is only three pages, and I think it is pretty easy to read. I would post it here, but I'm too lazy to try and translate LaTeX into blogger.</p>

<p>
<b>Update:</b> I've messed about with <b>latex2html</b>, and I've uploaded an html version to:<br/>
<a href="http://littlelanguages.com/web/crutcher/lrtgd/index.html">http://littlelanguages.com/web/crutcher/lrtgd/index.html</a>
</p>

<blockquote>
<b>Abstract:</b> Most popular parser generation tools work in terms of grammar rules which are not directly capable of providing list semantics. While the basic techniques for realizing list semantics are frequently re-invented, the literature has suffered from a lack of a solid collection of these techniques. This paper presents a collection of techniques for realizing various forms of lists as grammatically re-written forms using AST re-writes compatible with most parser generation environments. Also provided is a set of additional EBNF extension operators for specifying AST re-write actions.
</blockquote>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114140707276613680" rel="service.edit" title="A Pattern Language for Language Implementation" type="application/atom+xml"/>
<link href="http://press.samedi-studios.com/publications/2004/jones2004pl4li.plopD5/jones2004pl4li.pdf" rel="related" title="A Pattern Language for Language Implementation" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-03-03T09:26:00-08:00</issued>
<modified>2006-03-03T17:31:12Z</modified>
<created>2006-03-03T17:31:12Z</created>
<link href="http://littlelanguages.com/2006/03/pattern-language-for-language.html" rel="alternate" title="A Pattern Language for Language Implementation" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114140707276613680</id>
<title mode="escaped" type="text/html">A Pattern Language for Language Implementation</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">This is a paper from a while back that we workshoped at PLoP 2004. We are still shopping about for a place to publish it, but it hase some valuable things to say about language implementation.

<blockquote>
<b>Abstract.</b> Programming languages are typically considered to be difficult to implement. However, a programming language tailored to an application domain can be an extremely powerful productivity enhancer. We present a pattern language for implementing languages that gathers together many ideas that are known in the language implementation community that should be more widely known. By applying this pattern language, productivity can be increased by the blossoming of more programming languages tailored to a specific purpose. We begin by discussing some of the dichotomies that shape the language design process. The pattern language itself consists of patterns describing various language flavors, and patterns for doing syntactic recognition, evaluation, and source production. </blockquote>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114038785233282895" rel="service.edit" title="CommandLoop module in python" type="application/atom+xml"/>
<link href="http://littlelanguages.com/web/software/python/modules/cmdloop.py" rel="related" title="CommandLoop module in python" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-02-19T14:24:00-08:00</issued>
<modified>2006-02-27T18:17:18Z</modified>
<created>2006-02-19T22:24:12Z</created>
<link href="http://littlelanguages.com/2006/02/commandloop-module-in-python.html" rel="alternate" title="CommandLoop module in python" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114038785233282895</id>
<title mode="escaped" type="text/html">CommandLoop module in python</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
Here's a python module which provides a base class for writing simple
interactive command loop environments. It makes use of python 2.4 decorators
to describe the command functions.
</p>

<p>
CommandLoop provides a base class for writing simple interactive user
environments.  It is designed around sub-classing, has a simple command
parser, and is trivial to initialize.
</p>

Here is a trivial little environment written using CommandLoop:
<pre>
import cmdloop

class Hello(cmdloop.CommandLoop):
  PS1='hello&gt;'

  @cmdloop.aliases('hello', 'hi', 'hola')
  @cmdloop.shorthelp('say hello')
  @cmdloop.usage('hello TARGET')
  def helloCmd(self, flags, args):
    '''
    Say hello to TARGET, which defaults to 'world'
    '''
    if flags or len(args) != 1:
      raise cmdloop.InvalidArguments
    print &gt;&gt; self.OUT, 'Hello %s!' % args[0]

  @cmdloop.aliases('quit')
  def quitCmd(self, flags, args):
    '''
    Quit the environment.
    '''
    raise cmdloop.HaltLoop

Hello().runLoop()
</pre>

Here's a more complex example:
<pre>
import cmdloop

class HelloGoodbye(cmdloop.CommandLoop):
  PS1='hello&gt;'

  def __init__(self, default_target = 'world'):
    self.default_target = default_target
    self.target_list = []

  @cmdloop.aliases('hello', 'hi', 'hola')
  @cmdloop.shorthelp('say hello')
  @cmdloop.usage('hello [TARGET]')
  def helloCmd(self, flags, args):
    '''
    Say hello to TARGET, which defaults to 'world'
    '''
    if flags or len(args) &gt; 1:
      raise cmdloop.InvalidArguments
    if args:
      target = args[0]
    else:
      target = self.default_target
    if target not in self.target_list:
      self.target_list.append(target)
    print &gt;&gt; self.OUT, 'Hello %s!' % target

  @cmdloop.aliases('goodbye')
  @cmdloop.shorthelp('say goodbye')
  @cmdloop.usage('goodbye TARGET')
  def goodbyeCmd(self, flags, args):
    '''
    Say goodbye to TARGET.
    '''
    if flags or len(args) != 1:
      raise cmdloop.InvalidArguments
    target = args[0]
    if target in self.target_list:
      print 'Goodbye %s!' % target
      self.target_list.remove(target)
    else:
      print &gt;&gt; self.OUT, \ 
        "I haven't said hello to %s." % target

  @cmdloop.aliases('quit')
  def quitCmd(self, flags, args):
    '''
    Quit the environment.
    '''
    raise cmdloop.HaltLoop

  def _onLoopExit(self):
    if len(self.target_list):
      self.pushCommands(('quit',))
      for target in self.target_list:
        self.pushCommands(('goodbye', target))
    else:
      raise cmdloop.HaltLoop

HelloGoodbye().runLoop()
</pre>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/21999460/114008218233175561" rel="service.edit" title="Articulated Keywords" type="application/atom+xml"/>
<link href="http://littlelanguages.com/web/languages/articulated-keywords/keywords.html" rel="related" title="Articulated Keywords" type="text/html"/>
<author>
<name>Crutcher Dunnavant</name>
</author>
<issued>2006-02-16T01:29:00-08:00</issued>
<modified>2006-02-17T10:22:00Z</modified>
<created>2006-02-16T09:29:42Z</created>
<link href="http://littlelanguages.com/2006/02/articulated-keywords.html" rel="alternate" title="Articulated Keywords" type="text/html"/>
<id>tag:blogger.com,1999:blog-21999460.post-114008218233175561</id>
<title mode="escaped" type="text/html">Articulated Keywords</title>
<content type="application/xhtml+xml" xml:base="http://littlelanguages.com/" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<h3>Firefox's Bookmark Keywords</h3>
<p>
In Firefox, you can set a keyword for a bookmarked page. This keyword can
be typed in as a shortcut to the location bar. If the bookmark link has a
"%s" in it, then the text after the keyword will be substituted in.
  </p>
<p>
For example, if the user had a bookmark (with the keyword 'k') of:
  </p>
<pre>http://foo.bar.org/search?q=%s</pre>
<p>
And the user typed in:
  </p>
<pre>k foo bar baz</pre>
<p>
Then the browser would construct:
  </p>
<pre>http://foo.bar.org/search?q=foo bar baz</pre>

<h3>Creating articulated keywords</h3>
<p>
Given Firefox's bookmark keywords, and javascript's abaility to access the
query string of the url, it is possible to write bookmarks which jump to
pages which parse the query as a <i>command sequence</i>. Such command
dispatch systems usually treat the first variable token as a command, and
dispatch to functions registered on those names.
  </p>
<p>
Note: it is also possible to bookmark 'javascript: ...' links, called
bookmarklets. These can be quite useful, but require updating, while the
articulated keywords method described here need users to set it once, and
can be updated in a suite, and all users will see the updates.
  </p>

<p>
A sample implementation is provided in 
<a href="http://littlelanguages.com/web/languages/articulated-keywords/keywords.html">keywords</a>
  </p>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
</feed>
