Deriving a GIFT grammar (with PEG.js)

Re: Deriving a GIFT grammar (with PEG.js)

by Cris Fuhrman -
Number of replies: 2

I've got PEG.js parsing all the GIFT examples I could find. Have a look at the online development environment:

http://peg.arcanis.fr/2xz6e6/

The GitHub repository has automated tests (using node.js and mocha). I've not used the JavaScript objects for anything real, so perhaps there are better ways to format them. The hard part is the parsing, and I think it's mostly done. Hope this is useful to someone.

My next goal would be to write some kind of auto-completion editor for GIFT questions, to make them easier to write. Let me know if you're interested in working on this.

In reply to Cris Fuhrman

Re: Deriving a GIFT grammar (with PEG.js)

by Ali Tavakoli -

I wish I'd found this post earlier smile ; but in any case, here's my contribution: https://github.com/atavakoli/gift-grammar/blob/master/gift.pegjs

It can also parse all of the examples linked from the GIFT format page, and the output is a JSON array of questions/answers. Below Attached is the output for the set of examples linked from the format page.

AFAICT it supports all features except for escape sequences, changes in format, and categories; but, it should be easy enough to expand upon & improve, if there's interest.

Feel free to use this however you'd like!

Average of ratings: Useful (1)