From last two weeks I was working on application to parse EcmaScript, popularly known as Javascript, that generates an AST. I am using Esprima to do the same. From past few weeks, I was stuck up with many (almost-good) things, that kinda decreased my IQ. Everyday, I try to write some lines to deep parse this AST, but leave after a line or two, I just wasn’t in mood. But today, finally I took some time out of my (busy) schedule and wrote this.
I need to deep-parse AST for two purposes:
{ phase:two;//Telling us the phase is two //Lines follow }
All the lines that follow will be rendered in Apache Jelly phase two. This needed deep parsing as I need to identify all the children of phase two
block statement and render them differently.
Without further ado, here is the code.
The idea is to make a dictionary of all the complex look-aheads that might contain other statements, and recursively call the same function reading and processing all nodes.