Thursday, April 02, 2009

Adding python syntax highlighting to bespin

Support for Python got recently added to Codemirror, thanks to Timothy Farrell. So I grabbed those sources and ported them to bespin.
It doesn't work yet perfect in every case one can think of, but it does highlight Python.
The current features are (summarized from original demo page):
  • Token-based syntax highlighting - currently very little lexical analysis happens. Few lexical errors will be detected.
  • Use the normal indentation mode to enforce regular indentation, otherwise the "shift" indentation mode will give you more flexibility (not used yet in bespin).
  • Parser Options: Python version, error display
The patch with python support is now applied at my repo at bitbucket.

Tuesday, March 31, 2009

Javascript based parser generator system

I hope this is real (because April 1 is approaching, see my previous post): The first ever LALR(1) parser generator system written in and for Javascript. Would be interesting to add this to bespin, declarative grammars (as used in flex/yacc) are relatively easy to define, compared to codemirror which I used for the new, alternative bespin syntax engine and which is an interruptible-resumable continuation-passing style parser and needs to be written programatically for each language.
Similar to the narcissus parser implemented by Malte, such LALR(1) based parsers could be used for generating outline views and syntax checks running in a background worker thread. What it can't be used for is syntax highlighting, because LALR(1) based parsers need to reparse the whole file for every change to a document and that makes them too slow for syntax highlighting in realtime.

Internet Explorer Eightpril.1 with Webkit/Gecko rendering option !

I guess this is an April 1 joke leaked out too early and with perfectly photoshopped screenshots. If it is not a hoax, then, according to this article, the new Internet Explorer 8.1 will also allow to use Firefox extensions ! Ha ha !

Sunday, March 29, 2009

iBespin

Now that my bespin syntax engine is more or less working and got added to the main repo, I experimented again with inline previews, but this time I think the result is a bit more in line with what one actually needs:
I added a preview setting. Using previews is the same as always, either click on the icon, or type the command: preview.
Below are the new settings:
  • set preview window - default, an external window, as we have now.
  • set preview inline - instead of editor canvas we have an iframe containing the preview
  • set preview iphone - a non-modal popup containing an iframe with dimensions of the iPhone screen. Of course you should use Safari for this.
With ESC key the previews get closed / toggled off.
Now this just needs to be cleaned up a bit and turned into a patch or pushed to my repo at bitbucket.