|
From: Braden M. <br...@en...> - 2001-09-28 03:47:45
|
On Thu, 2001-09-27 at 22:41, clayton wrote:
> i think my model here was Matt Sergeant's
> {of axkit fame amongst others}
> XML::LibXML and XML::LibXSLT
> http://search.cpan.org
>
> were made using perl's xs to wrap
> around xmlsoft.org's
> libxml and libxslt
XML parsers have significantly different obligations from VRML parsers.
XML is a metalanguage. An XML parser functions as a substrate for
higher-level parsing. Thus the typical yield from an XML parser is
something akin to a syntax tree. Most applications would want a VRML
parser to yield a scene graph.
[tangent time...]
In general, VRML scene graphs do not directly map to a serialized form.
However, the ability to serialize scene graphs has been an important
feature in OpenVRML. I think it is important that we keep this; but let
me tell you, it makes managing scopes a *bitch*.
Imagine a vrmlstring with a PROTO inside it. A script calls
createVrmlFromString(), and sends the resulting MFNode to a Group in the
scene. Now, the VRML97 spec sez that the vrmlstring's scope is unique.
So where do we hang the PROTO definition in the serialized output?
Ultimately I decided that the world's scope should sprout a new node
type in response to this kind of action. But this isn't so
straightforward either. What if the world's scope already has a
conflicting type? The conflict must be resolved by arbitrarily changing
the name of the new type. What it comes down to is that there's no way
to behave in a fashion that's likely to be predictable to users 100% of
the time.
> what i need to know is how to call the parsing and validating routines/sub/functions/...
> without calling the display routines
> then i could call those
> methods directly and use those
> infos to generate a report of some sort
>
> {mostly straight out for now}
That would be the Vrml97Parser class. This is code generated by ANTLR.
It is not part of the public API. These methods are used to construct a
scene graph, not a syntax tree.
If it's a syntax tree you want, your best bet is to simply use
OpenVRML's ANTLR grammar as a starting point. Look at Vrml97Parser.g and
the ANTLR documentation. ANTLR has support for Abstract Syntax Trees,
but we do not use this in OpenVRML. Of course, the ANTLR grammar could
be extended in that direction for your application.
> btw an easy c wrapper might be to use perl as a middle man!
I rather doubt that.
--
Braden McDaniel e-mail: <br...@en...>
<http://endoframe.com> Jabber: <br...@ja...>
|