Modisco JSP Parser has been developed using an ANTLR grammar It can support JSP file, as well as HTML files, TAG files, and JSP/TAG fragment files
The ANTLR grammar is composed with rules representing what could be founded in a JSP file :
Updating the Grammar
Non XML Conformity
In order to build the inheritance tree, we had to store all the founded tags, and each time closing one is detected, re build the inheritance tree.
on whenis detected, and so on.
User Code in the generated one
Because we do not know if a tag will be closed later in the code, we had to manually implement some text concatenation.
Let's say we meet a new opening tag:
This is some HTML content
We cannot declared a rule "'<p>' 'any letter' '</p>'" because </p> might never appears, or a JSP expression could be there. That is why we concatenate manually the potentially present content after an opening tag, and wait till we found a known token.