Well, I wrote a VRML parser a few years ago but I can't give you the source as it belongs to my old company (I can't use it either if it makes you feel any better)
To write this you need to write a parser that understands a certain syntax; Tools such as lex and yacc are

for this but I wrote it by hand (probably out of stupidity more than anything else

)
First I converted the VRML tokens into an intermediate 'language', a bit like pcode and then I used that to build the scene. The first phase is called (If I can remember my CS course) lexical analysis and splitting it up like this makes the job of building the scene more straight forward. For the first phase, you have to be able to determine what a single token and also to verify data types. Syntax errors are spotted when you have a token or datatype you did not expect and 'scene build-time' errors are things like polygons indexing vertices that aren't there. I'm not really too fond of VRML as a way of describing 3d scenes but I've found that doing things this way means you can reuse the code to parse other languages that are described in this kind of way (i.e. they look a bit like C or pascal)
Hope that helps,
Tim.