[Source] MFTime parse error in class X3DFieldReader
Don Brutzman
brutzman at nps.edu
Sat Mar 2 17:27:04 PST 2013
In package org.web3d.parser.x3d; class X3DFieldReader.java, the first
constructor for MFTime fails to parse values correctly, returning an
empty array.
Not sure how to fix this, it involves javacc compiler.
There is another MFTime constructor; untested. Probably could be used
instead by using .split() on the String input here to create a String[]
array instead. That would be a good approach to shrink codepaths.
Brief inspection showed that patterns look similar for similar parsers
among different datatypes.
This should get recorded as a bug and fixed by someone knowledgeable.
I've modified my prototype which triggered the bug to use MFFloat
instead, which is actually better for the case I'm working on.
Starts at line 1906.
/**
* Parse an MFTime value. In VRML97 MFTime are not legal field
types. However,
* we provide it here for completeness and that it might be used by
VRML 3.0.
* <pre>
* MFTime ::=
* "[" NUMBER_LITERAL* "]" |
* NUMBER_LITERAL*
* </pre>
*
* @param value The raw value as a string to be parsed
* @return The array of time values parsed
* @throws InvalidFieldFormatException The field does not match the
* required profile
*/
public double[] MFTime(String value) throws
InvalidFieldFormatException {
StringReader input = new StringReader(value);
double[] ret_val = null;
try {
synchronized(mutex) {
fieldParser.ReInit(input);
System.err.println ("Warning, MFTime fails to parse
correctly");
ret_val = fieldParser.MFTime();
}
} catch(ParseException pe) {
throw new InvalidFieldFormatException(pe.getMessage(),
locator.getLineNumber(),
locator.getColumnNumber());
} catch(TokenMgrError tme) {
throw new InvalidFieldFormatException("Invalid field value
encountered when parsing MFTime field value",
locator.getLineNumber(),
locator.getColumnNumber());
}
return ret_val;
}
all the best, Don
--
Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
More information about the Source
mailing list