VRML 1.0 parser in scheme
The parser is not developed further as a standalone module, it has been
integrated into the PLT-Scheme version of the SX modelling
This module implements a VRML 1.0 parser. The implementation is partly based
on QV 1.0 (a quick VRML parser) by Paul S. Strauss of Silicon Graphics.
The module only implements the parsing, therefore what to do with the
parsed vrml world is up to you. There is no semantic checks either!
The parser strictly conforms to the VRML 1.0 standard (to the best of my
knowledge and the found documentation, except bugs).
All node types and formats
are implemented and recognised. The only exported function is
which expects a port (opened for reading) as an argument. The function
returns an association list in the case of success and #f in the case of
an error. The format of the resulting association list is:
(node-name (field-1 value-1) (field-2 value-2) ...)
where 'node-name' is a symbol corresponding to a valid, standard VRML node
name or an extended node name. 'field-1' is a valid field name in the
node and 'value-1' is the value of the field. 'value-1' can be the
default value or the read value. In the case of a multi value field
(e.g. MFFloat) 'value-1' is a list. Valid boolean values are the symbols
of 'TRUE' and 'FALSE'. The enum and bitmask values are also symbols.
SFMatrix is a 4 by 4 array in the association list.
Nodes grouping other nodes store their sub nodes in a list which is
identified by the symbol 'children'. Extended nodes are also read but
the default value for a field is #f.
An example VRML world is:
#VRML V1.0 ascii
string [ "Hello", "World" ]
The result is:
(string ("Hello" "World"))
The parser is placed under the GNU Public License (GPL) version 2.0.
- It is not too difficult to make a VRML97 parser based on this parser.
The real difficulty is to visualise a VRML97 world. At the moment I only
need static worlds, therefore VRML 1.0 is enough. In the not too distant
future I may make the VRML97 parser :-) .
- If you want to use this module you only have to modify the error reporting
function (vrml-error). The module otherwise is self-contained.
- It can be used under several Scheme implementations, for example:
For the bigloo version the bigloo.scm file is included which implements some
features existing in guile but not in bigloo.
Back to my Home page
Copyright © 1998-2005