I would like to know if there exists a LaTeX processor that works similar to SAXON for XML and XSLT documents. I would need it to extract some information from source code, and define its semantics.
LaTeX is completely open source and written in TeX, you can find a documented version of the sources as the file source2e
texdoc source2e in most distributions.
TeX is also open source, written in WEB, a literate programming language that produces both the (pascal, originally, but now C) source of the program and also a (TeX) document describing the source in complete detail. tex.web is also available in all TeX distributions, or you can get the fully typeset and indexed version as the published book TeX: The Program.
Given the clarification of your aims in comments I don't think the source of either LaTeX or TeX will help much.
I suspect that a more productive way forward would be to convert to XHTML using
tex4ht and then analysing the resulting XML. In deriving a tree structure from a latex document you need to make a lot of more or less arbitrary choices, and existing convertors have already made them. For example you probably want to expand some macros so if the user has gone
then you see
\mysec as a section marker, but you don't want to expand all macros, as LaTeX is just defined via macros so for example you want to see
\section as part of the tree structure, you don't want to expand it all out and just see a weird collection of spacing and font setting commands. there can never be any hard rules about which macros to expand and which to consider as marking the document tree structure, it's all heuristics and guesswork unless you know the document author.
In the meantime, I've found this project that could convert LaTeX elements into HTML+MathML, and also implements a LaTeX parser.