News for hackers. Stuff that matters.
Re:The Lemon Parser Generator by haxiomic on Tuesday September 29, 2015 @10:37AM (#10296579)
Lemon is great. I used it to develop a browser based GLSL parser[0]. I spent ages working with existing javascript parser generators and kept running into walls with syntax and performance until I settled on porting Lemon.

I ported the core parser to haxe rather than straight javascript which means it can be used to build dependancy free parsers for python, java, c++, php (and any other haxe-supported[1] language)

I've only ported the LALR portion of the parser - the data tables are still generated by the c version of lemon. Although I haven't wrapped it up in a self-contained project, if you want to do something similar have a look at the gh repo[2]. I've not documented anything, but if someone finds this and is interested in building a cross-platform parser with a similar method feel free to get in touch and I'll give you a guide on using the code. If there's enough interest I'll build it out into something self-contained and easy to use.

[0] http://haxiomic.github.io/haxe-glsl-parser/

[1] http://haxe.org/manual/introduction-what-is-haxe.html

[2] https://github.com/haxiomic/haxe-glsl-parser/tree/master/too...

Re:The Lemon Parser Generator by hobo_mark on Tuesday September 29, 2015 @05:33PM (#10299828)
what kind of limitations did you find in the JavaScript ones?
Re:The Lemon Parser Generator by haxiomic on Thursday October 01, 2015 @10:21AM (#10311311)
There were a few aims I wanted to meet:

- Stick as closely as possible to the GLSL specification by using the reference grammar with minimal modification

- Produce a haxe version of the parser so I could do some haxe-compile-time magic with it

Haxe is fairly similar to javascript so I tried altering PEG.js to spit out haxe. The result was a 9000 line file which it turns out was too big to compile. ANTLR looked promising but it appeared to be a bit too much to work create a haxe port of the runtime.

Lemon was minimalistic and had a simple syntax which was fairly close to the syntax of the reference grammar. The core parser is only about 300 lines[0] and everything else is in data tables[1] which are generated by the lemon command line tool.

[0] https://github.com/haxiomic/haxe-glsl-parser/blob/master/gls...

[1] https://github.com/haxiomic/haxe-glsl-parser/blob/master/gls...