WHAT: this is a blog where i collect news about the usage of javascript a serious programming language on the client side and server side. WHY: because it seams to be the most ubiquitous language and has functions as first class objects, and closures and ....

Thursday, June 12, 2008

Parser JS/CC and Code Mirror combined

Well I was thinking about making a nice edit area for a wiki, with a markup with a real defined context free grammar parsed by a
LALR.

Why? well you will have nested bracket structures even in text....
Mediawiki fails here, it seams to be just some regular expressions matching.. :-(

Ok I found this nice parser JS/CC by Jan Max Meyer,
a great tool beacuse:
  • its completly done in javascript, so you can parse at the client like on the server
  • has a flexible template mechanism

an this great Code Editor: CodeMirror by Marijn Haverbeke.
I liked it more that all the others because:
  • It uses a parser, and you can extend it with your own parser.
  • It supports long documents, as each line brack has a own copy of the parser state (a continuation sort of. So for the next line simply take the parser an continue parsing.
  • It supports undo/redo
  • You can earn a lot of programming techniques by looking at the code :-)
Well so why not combine JS/CC and CodeMirror ?

I created an js/cc driver_editor.js_ template which can be used to create a parser that fits right into the CodeMirror editor ...anybody interested? Send an email to me :-)





-

3 comments:

Evan Moran said...

This is a good idea. I'd be interested in this!

Tom said...

More than 1 year after this post, what is the state of the art?

Anonymous said...

Hi, stumbled upon this post about codemirror and grammars.

You might like this add-on for codemirror:

https://github.com/foo123/codemirror-grammar

PS: i am the author

Cheers,
Nikos