Maybe I should explain in more detail what I would like to achive.
I'd like to parse a source-file (HTML file with JavaScript embedded in
ASP-like fashion) with a custom HTML parser.
I want to have a string (or Reader or something, really doesn't
matter) that I can append JavaScript source to as I pick it up in my
HTML source.
I want to have a tree-representation of the JavaScript source (I
believe this is already being build in Rhino parsing), but it should
be build piece-by-piece as I append more and more JavaScript to the
JavaScript string.
As I parse my HTML, everytime I bump into a "<% ... %>" syntax I will
get the content between <% and %> and append it to the string
containing the previous <%...%> sections. This should also append the
correct sub-tree to the tree-representation.
Every time I get to a "%>" in the HTML source and after I've appended
the content to the string and the tree has been updated I need to do
the following:
a) Check that the combined JavaScript - so far - is correct if you
look at the syntax.
b) Check if I'm now inside a function, a for-loop inside af while-loop
inside a function etc.
c) Check if any errors in the - so far - parsed JavaScript, and if it
has then get line-number and possible column-number etc.
As I parse the HTML and the JavaScript <%...%> sections and append to
the string and the tree the JavaScript will eventually (if no errors
of course) contain a complete and working JavaScript context.
Please note that everytime I get the content inside <%...%> it could
contain fx. "for (i = 0; i < 10; i++) {" with no ending "}", but as
I'm not at the end of the HTML then this is - so far - correct syntax,
so no errors should be shown here.
Is the above duable with Rhino or do I have to build my own JavaScript
parser - which I'd rather not :-D If it is not possible with Rhino,
does someone know of a person that could build a custom parser for me
(based on the Rhino, so that improvements could easily be added in the
future)? Thanks!
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino