shake, with fries

by Zach Carter

Posts tagged compiler

Feb24

CoffeeScript compiler now uses Jison

jison coffee-script compiler | comments

The new CoffeeScript self compiler uses Jison for generating the parser. The whole build script runs on Node.

Jeremy, the creator of CoffeeScript, spurred me to make some quick performance improvements (and bug fixes) to Jison so that the CoffeeScript grammar could build in a timely fashion. And while there are still many improvements to be made, handling such a large and complex grammar is quite a feat!

Jeremy also reported that parsing times are quick, though that's more of a testament to v8, I'm sure.

Dec27

Orderly.js: Orderly to JSONSchema Compiler

javascript commonjs jison orderly jsonschema json compiler parser | comments

Orderly is a textual format for describing JSON. Orderly can be compiled into JSONSchema. It is designed to be easy to read and write.

I decided to give Jison a real-world spin by creating an Orderly to JSONSchema compiler for JavaScript. After about three days, interspersed with lots of eating and family vists, I have a working implementation, which I call Orderly.js.

Usage

var orderly = require("orderly");

var orderlySource = "array {};";

var jsonSchemaSource = orderly.compile(orderlySource);

var jsonSchemaObject = orderly.parse(orderlySource);

print(JSON.stringify(jsonSchemaObject));

An API for building parsers

I must say, Jison made this really simple. I don't consider myself a speedy coder in the slightest, probably the opposite, but I was able to crank this out in a (holiday) weekend. Jison takes care of the hard parts of parsing, all you need is a working grammar* and the appropriate hooks. I'll be writing more on Jison shortly.

*This can be non-trivial, though if the language you are parsing already specifies a grammar, as was the case with Orderly, you're set!

Dec23

Stay parsey, my friends.

javascript commonjs parser lexer compilers jison | comments

I hinted on twitter that I was implementing some kind of compiler in JavaScript. It was a project I began to help study for a compilers course I was taking, which also gave me an opportunity to earn extra credit. Though, really, I just thought it was a friggen cool thing to implement. I ended up focusing on the compiler front-end to create a parser generator, which I call Jison.

Anyway, the semester ended, I received the extra credit, and pushed the source to github. I'm still working on the initial documentation to include in a more formal announcement this week.

The demo page that was built to showcase some of the features to my professor is also available. It turned out to be a very useful tool for this particular niche in its own right. The page can help you visually debug CFGs, so it is helpful regardless of the parsing tool the grammar is intended for, or would be helpful for simply learning about CFGs and parsing algorithms.

I'll post a follow up with documentation and more examples soon. For now, check out the JSON parser.

Stay parsey, my friends.