4 ms·
Are there PEGs available for languages like Javascript? Given recent discussion of Perl being undecidable, I assume there isn't one for Perl. Has anyone tackled
by raganwald 17y ago
Are there PEGs available for languages like Javascript? Given recent discussion of Perl being undecidable, I assume there isn't one for Perl. Has anyone tackled such a thing for Ruby?
Update: Thanks for the links! That being said, I didn't mean parsers written in Javascript or Ruby, I mean PEGs or CFGs that parse Javascript and/or Ruby programs :-)
- ErrantX 17y agohttp://treetop.rubyforge.org/ http://treetop.rubyforge.org/ Im writing a programming language in Ruby at the moment - and after playing with that for a few days I've gone back to "hand coded lexer plus Racc for grammar". It's probably personal preference but I find that a little more tunable.
- moserware 17y agoYou might look at OMeta/JS: http://tinlizzie.org/ometa-js/#JavaScript_Compiler http://tinlizzie.org/ometa-js/#JavaScript_Compiler OMeta is based upon PEGs and is worth a look because it has some great meta-meta ideas from the 60's that were ignored. (Also, there are several ports of OMeta to other languages)
- scythe 17y agoThey're native in Perl 6, and people above have linked to libraries for Lua and Clojure. I think there's a library for Python as well somewhere or other. Also peg/leg for C is intended (iirc) as a direct competitor to flex/bison et al.
- dmajda 17y agoECMAScript 5 PEG parser: http://boshi.inimino.org/3box/PEG/build/ES5.html http://boshi.inimino.org/3box/PEG/build/ES5.html (Hmm, I must definitely try to port it to PEG.js :-) As for Ruby, I am not sure if it is even possible to create a PEG grammar. Its lexer and parser are heavily interconnected and there is a lot of state involved. If the grammar will be created, I don't think it would be pretty.