I want to write parser for JavaScript.
What I figured it out that I need to use some sort of scanning each character and as soon as I interact with any {, I must track for the next } (closing braces).
For efficient usage I can use stack.
Can anyone suggest me some better idea or approach to build a parser for JavaScript with Java?
There already is a complete JavaScript engine written in Java, names Rhino. Obviously it has to include a parser, and it’s open source, so you could have a look how it’s done there.
I suspect that you’ll find that parsing a language such as JavaScript is much more complex than you expect.