On the left a sample tree is shown.
The tree is generated by the EmbedParser component which
loads its rules from a section of the defs.cfg file
(this file is in the ASPCIDE.EXE directory).
The component EmbedParser component is not a compact
component. It consists of a set of about 20 different parser
classes intended to search for certain syntax constructions
and/or keyords and operators. You do not need to know these
details but if you are interested read this page.
Defs.cfg file contains several sections which in turn
contain more subsections. Every 1-st level section contains
a rule definition for parsing. For example ASP parser
definition describes that two parser will be loaded - one
for <% %> tags and one for the HTML comments (used to
search for include directives). Applied to a string this
parser returns a collection of components which hold the
different parts of the ASP page with additional attributes -
easy to inspect from a script and thus
"understand" the page structure.
The definition shown on the picture is a simplified form
of the result of the VBS parser. It contains much more rule
definitions which define how to recognize Sub/Function
declarations, Dim statements, Class definitions and so on.
Resulting tree is a collection of collections with all the
code components classified in the appropriate place - under
the containing node. Thus for a script/application using
this tree a Sub (for example) is a node with sub nodes
containing its statements and local variable declarations.
Parser definitions consist of instructions what internal
components to use in which order and how to initialize it.
Once defined the parsing procedure is just passing a string
or a file to the component and obtaining the tree as
result.
For the current version of ASPC we do not need full depth
of the syntax tree thus we do some tricks to simplify our
work. Planning future extensions includes more complex
parsers with much more features thus we decided to not
publish documentation for the parser itself at this
time. If you are interested we will include such a
documentation. |