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 environment.


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 "vrml-1-read" 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
 Separator {
    renderCulling ON
    AsciiText {
        string    [ "Hello", "World" ]
        justification LEFT
    Cube {
        height  10.0
The result is:
    (renderCulling ON) 
        ( (AsciiText 
              (string ("Hello" "World")) 
              (spacing 1.0) 
              (justification LEFT) 
              (width (0.0))) 
              (width 2.0)
              (height 10.0)
              (depth 2.0))


The parser is placed under the GNU Public License (GPL) version 2.0.



Back to my Home page

Copyright © 1998-2005 Péter Iványi