tag:blogger.com,1999:blog-3729811.post1089867960663652232..comments2023-09-28T02:20:20.305-07:00Comments on Pushed wrong button, rebooted the Internet ...: Erlang JS compiler - dealing with objectsRoberto Sacconhttp://www.blogger.com/profile/17372747301844271000noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-3729811.post-48717558039604506482008-12-02T18:24:00.000-08:002008-12-02T18:24:00.000-08:00This may be totally out line, but I thought you'd ...This may be totally out line, but I thought you'd appreciate this comment. Regarding the complexity of parsing JavaScript using ugly things like Yacc,lex etc. There is something called a PEG grammar which is like CFG with one minor difference (non-deterministic choices are turned into sequential choices, never mind if you don't understand this now). Point is that PEG grammars (with a little standard sugar) are sufficient to describe all languages (even C mixed up with the macro languages on top) and especially JavaScript (which is a walk in park actually). PEG grammars can be compiled in linear time (super fast). What you need to care about as a programmer is that you have to write one clean grammar when you use PEG, instead of a parser + grammar + hacks when you use Lex/yacc. And it also happens so that the PEG parsers were initially designed for functional languages, because they are very easily implementable there. If you haven't heard of PEG grammars, it is because they recently (past 10 years) have been re-discovered in Computer Science as extremely useful. You can learn everything about them here: http://www.cs.nyu.edu/~rgrimm/xtc/.The state of the art compiler XTC is written in Java. But you can still use it to write a JavaScript to Erlang compiler, easily. I would be happy to hear if you decide to pursue this, maybe I could even help. (Find my email on my homepage)Anonymousnoreply@blogger.com