Sunday, 6 January 2008

Moonshine core interpreter

xkcd rockband

Today I will show you a demonstration of the Mooshine core interpreter running two different Lua programs which utilise the Firefox browser.

The first program as outlined below tests the standard module:

-- test standard module
print("\n" .. std.version() .. "\n") -- print version
std.msg("Hello from Moonshine!") -- display message
local ans = std.prompt("Enter number:") -- display prompt

It does the following...

  1. Prints the version of the standard module in the interpreter

  2. Displays a message box in the browser

  3. Displays a prompt for user input

The second program retrieves the latest XKCD comic panel (a example of which is in this post) from the XKCD atom feed and displays it in a new browser window...

-- display latest xkcd web
-- comic from the xkcd atom feed
-- in a new browser window
-- make a request for xkcd comic feed
feed = net.httpreq("")
-- match comic panel
img = string.match(feed,
-- display comic panel in a new window

The current version of the Moonshine core interpreter is an executable written in C with embedded Lua. Most of the functionality itself comes from the included modules.

To properly work as part of my extension, I will rewrite the core intepreter in C++ as an XPCOM component (which use classes).

See the demonstration (animated GIF)

Image courtesy of xkcd (CC-BY-NC)

Digg This Story

Sunday, 23 December 2007


pa loved his ol' moonshine.

I've been working on a project to integrate Lua with the Firefox web browser, in the form of an extension which adds support for the language to write background services or on-demand applications to run directly in the browser.

I have yet to write more code to get the integration working. I will enter this project into the Mozilla Lab's extend Firefox Contest. So hopefully, I'll have enough implemented by the deadline.

For more information, please see the Google code project page.

Image courtesy of ladyphoenixx_1999 (CC-BY-NC-ND)

Digg This Story

Monday, 26 November 2007

XML parser demonstration

Video on YouTube.

I managed to get the parser to handle attributes and tags with attributes.
xml.stag is no longer necessary and has been replaced with the more vesatile xml.tag .
Above is an approximately 8 minute video demonstrating use of the parser within the Lua interpreter. I apologise for the poor quality.

The next step for the parser now is to implement handling a specific occurrence of tag for the specified functions.

This video is licenced under same licence as the rest of this blog contents, except third party stuff of course (such as featured images).

Digg This Story