Package org.web3d.parser.vrml97
Class VRML97RelaxedParser
java.lang.Object
org.web3d.parser.vrml97.VRML97RelaxedParser
- All Implemented Interfaces:
VRML97RelaxedParserConstants
A parser for VRML97 syntax that is not very strict about the incoming
syntax.
Automatically generated from the JavaCC source grammar VRML97Relaxed.jj The grammar is not a strict interpretation of the VRML97 BNF from Appendix A. You can see what JavaCC thinks the grammar is here
- Version:
- Grammar $Revision: 1.27 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionNext token.Current token.Generated Token Manager.Fields inherited from interface org.web3d.parser.vrml97.VRML97RelaxedParserConstants
COMMENT, DEF, DEFAULT, DOT, EOF, EVENTIN, EVENTOUT, EXPOSEDFIELD, EXTERNPROTO, FALSE, FIELD, ID, ID_FIRST, ID_REST, IS, LBRACE, LBRACKET, NULL, NUMBER_LITERAL, PROTO, RBRACE, RBRACKET, ROUTE, SCRIPT, STRING_LITERAL, TO, tokenImage, TRUE, USE
-
Constructor Summary
ConstructorsConstructorDescriptionVRML97RelaxedParser
(InputStream stream) Constructor with InputStream.VRML97RelaxedParser
(InputStream stream, String encoding) Constructor with InputStream and supplied encodingVRML97RelaxedParser
(InputStream is, ContentHandler ch, RouteHandler rh, ScriptHandler sh, ProtoHandler ph, ErrorHandler eh) Create a new parser instance that has all of the handlers set to the given references.VRML97RelaxedParser
(Reader stream) Constructor.VRML97RelaxedParser
(Reader rdr, ContentHandler ch, RouteHandler rh, ScriptHandler sh, ProtoHandler ph, ErrorHandler eh) Create a new parser instance that has all of the handlers set to the given references.Constructor with generated Token Manager. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Rule 20 - Turn a string into theFieldConstants
value.final void
Disable tracing.final void
Enable tracing.final void
Rule 10 - Parse a node statement.final void
Rule 9 - Parse a node statement.final String
FieldId()
Rule 22 - Parse a field identifier.final String
Rule 19 - Parse a field name string.final Object
FieldValue
(String fieldName) Rule 23 - Parse a field value statement.final String
Rule 29 - Parse a number that may contain multiple whitespace values - such as an SFVec3f.Generate ParseException.Fetch the documentLocator used by this parser.final Token
Get the next Token.final Token
getToken
(int index) Get the specific Token.final String
Id()
Generate an identifier as a string from the parsed token.void
Initialise the internals of the parser at start up.final void
Rule 7 - Parse a single field interface declaration.final String
Rule 26 - Parse a literal value for a single field value.final Object
MultiFieldValue
(String fieldName) Rule 25 - Parse a multi value field statement.final void
Rule 12 - Parse a node statement.final void
NodeBody()
Rule 13 - Parse a node statement.final void
Rule 14 - Parse a node statement.final String
Rule 17 - Parse a node statement.final void
Rule 2 - Parse a node statement.final String
Rule 18 - Parse a NodeType identifier.final String[]
Rule 28 - Parse a number that may contain multiple whitespace values - such as an SFVec3f.final void
Proto()
Rule 4 - Parse a PROTO declaration.final void
Rule 5 - Parse a node statement.final void
Rule 2 - Parse a node statement.void
ReInit
(InputStream stream) Reinitialise.void
ReInit
(InputStream stream, String encoding) Reinitialise.void
Reinitialise.void
Reinitialise.final int
Rule 21 - Turn a string into theFieldConstants
value.final void
Rule 6 - Parse an interface declaration that allows everything except exposedFields.final void
Rule 3 - Parse a node statement.final void
Rule 2 - Parse a node statement.final void
Scene()
Rule 0 - Parse the complete scene.final void
Rule 15 - Parse a node statement.final void
Rule 16 - Parse a node statement.void
Set the content handler instance.void
setDocumentUrl
(String url) Set the base URL of the document that is about to be parsed.void
Set the error handler instance.void
setErrorReporter
(org.j3d.util.ErrorReporter eh) Set the error reporter instance.void
Set the proto handler instance.void
Set the route handler instance.void
Set the script handler instance.final String
Rule 24 - Parse a single value of a field statement.final void
Rule 1 - Parse a statement.final String[]
Rule 27 - Parse an array of string literals.final String[]
URIList()
Rule 11 - Parse an MFField statement - principally a URIList on the EXTERNPROTO.
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
VRML97RelaxedParser
public VRML97RelaxedParser(InputStream is, ContentHandler ch, RouteHandler rh, ScriptHandler sh, ProtoHandler ph, ErrorHandler eh) Create a new parser instance that has all of the handlers set to the given references. These can be overridden with the set methods below. It is safe to pass in null references here.- Parameters:
is
- The stream to read characters fromch
- The content handler instance to userh
- The route handler instance to usesh
- The script handler instance to useph
- The proto handler instance to useeh
- The error handler instance to use
-
VRML97RelaxedParser
public VRML97RelaxedParser(Reader rdr, ContentHandler ch, RouteHandler rh, ScriptHandler sh, ProtoHandler ph, ErrorHandler eh) Create a new parser instance that has all of the handlers set to the given references. These can be overridden with the set methods below. It is safe to pass in null references here.- Parameters:
rdr
- The reader to source characters fromch
- The content handler instance to userh
- The route handler instance to usesh
- The script handler instance to useph
- The proto handler instance to useeh
- The error handler instance to use
-
VRML97RelaxedParser
Constructor with InputStream. -
VRML97RelaxedParser
Constructor with InputStream and supplied encoding -
VRML97RelaxedParser
Constructor. -
VRML97RelaxedParser
Constructor with generated Token Manager.
-
-
Method Details
-
initialize
public void initialize()Initialise the internals of the parser at start up. If you are not using the detailed constructors, this needs to be called to ensure that all internal state is correctly set up. -
setDocumentUrl
Set the base URL of the document that is about to be parsed. Users should always call this to make sure we have correct behaviour for the ContentHandler'sstartDocument()
call.The URL is cleared at the end of each document run. Therefore it is imperative that it get's called each time you use the parser.
- Parameters:
url
- The document url to set
-
getDocumentLocator
Fetch the documentLocator used by this parser. This is here so that the user of this parser can ask for it and set it before calling startDocument(). Once the scene has started parsing in this class it is too late for the documentLocator to be set. This parser does set it internally when asked for aScene()
but there may be other times when it is not set.- Returns:
- The documentLocator used for syntax errors
-
setContentHandler
Set the content handler instance.- Parameters:
ch
- The content handler instance to use
-
setRouteHandler
Set the route handler instance.- Parameters:
rh
- The route handler instance to use
-
setScriptHandler
Set the script handler instance.- Parameters:
sh
- The script handler instance to use
-
setProtoHandler
Set the proto handler instance.- Parameters:
ph
- The proto handler instance to use
-
setErrorHandler
Set the error handler instance.- Parameters:
eh
- The error handler instance to use
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter eh) Set the error reporter instance. If this is also an ErrorHandler instance, the document documentLocator will also be set.- Parameters:
eh
- The error handler instance to use
-
Scene
Rule 0 - Parse the complete scene.vrmlScene ::= statement* ;
The scene assumes that the caller will make the startDocument() and endDocument() calls on the ContentHandler before and after this method.- Throws:
ParseException
-
Statement
Rule 1 - Parse a statement.statement ::= nodeStatement | protoStatement | routeStatement ;
- Throws:
ParseException
-
NodeStatement
Rule 2 - Parse a node statement.nodeStatement ::= node | DEF NodeNameId node | USE NodeNameId ;
- Throws:
ParseException
-
RootNodeStatement
Rule 3 - Parse a node statement.rootNodeStatement ::= node | DEF NodeNameId node ;
- Throws:
ParseException
-
ProtoStatement
Rule 2 - Parse a node statement.protoStatement ::= proto | externproto ;
- Throws:
ParseException
-
Proto
Rule 4 - Parse a PROTO declaration.proto ::= PROTO NodeTypeId [ interfaceDeclaration* ] { protoBody } ;
- Throws:
ParseException
-
ProtoBody
Rule 5 - Parse a node statement.protoBody ::= protoStatement* rootNodeStatement statement* ;
- Throws:
ParseException
-
RestrictedInterfaceDecl
Rule 6 - Parse an interface declaration that allows everything except exposedFields.restrictedInterfaceDeclaration ::= eventIn fieldNameId eventId | eventOut fieldNameId eventId | field fieldNameId eventId fieldValue ;
Unfortunately we also need some context information here to know if we are in A script or a proto to know which handler to call.- Throws:
ParseException
-
InterfaceDecl
Rule 7 - Parse a single field interface declaration.interfaceDeclaration ::= restrictedInterfaceDeclaration | exposedField fieldNameId eventId fieldValue ;
- Throws:
ParseException
-
ExternProto
Rule 9 - Parse a node statement.externproto ::= EXTERNPROTO NodeTypeId [ externInterfaceDeclaration* ] URLList ;
- Throws:
ParseException
-
ExternInterfaceDecl
Rule 10 - Parse a node statement.externInterfaceDeclaration ::= accessType fieldNameId eventId
- Throws:
ParseException
-
RouteStatement
Rule 2 - Parse a node statement.routeStatement ::= ROUTE NodeNameId . eventOutId TO NodeNameId . eventInId ;
- Throws:
ParseException
-
URIList
Rule 11 - Parse an MFField statement - principally a URIList on the EXTERNPROTO.URLList ::= "[" STRING_LITERAL* "]" | STRING_LITERAL ;
- Throws:
ParseException
-
Node
Rule 12 - Parse a node statement.node ::= nodeTypeId { nodeBody } | "Script" { scriptBody } ; We also handle the empty cases for both body and script here
- Throws:
ParseException
-
NodeBody
Rule 13 - Parse a node statement.nodeBody ::= nodeBodyElement | nodeBodyElement nodeBody
The empty case is handled in the Node declaration- Throws:
ParseException
-
NodeBodyElement
Rule 14 - Parse a node statement.nodeBodyElement ::= fieldNameId fieldValue | fieldNameId IS fieldNameId | routeStatement | protoStatement ;
- Throws:
ParseException
-
ScriptBody
Rule 15 - Parse a node statement.scriptBody ::= scriptBodyElement | scriptBodyElement scriptBody
The empty case is handled in the Node declaration- Throws:
ParseException
-
ScriptBodyElement
Rule 16 - Parse a node statement.scriptBodyElement ::= nodeBodyElement | restrictedInterfaceDeclaration | eventIn fieldType eventInId IS eventInId | eventOut fieldType eventOutId IS eventOutId | field fieldType fieldNameId IS fieldNameId ;
- Throws:
ParseException
-
NodeNameId
Rule 17 - Parse a node statement.nodeNameId ::= Id ;
- Throws:
ParseException
-
NodeTypeId
Rule 18 - Parse a NodeType identifier.nodeTypeId ::= Id ;
- Throws:
ParseException
-
FieldNameId
Rule 19 - Parse a field name string.fieldNameId ::= Id ; eventInId ::= Id ; eventOutId ::= Id ; exposedFieldId ::= Id ;
- Throws:
ParseException
-
AccessType
Rule 20 - Turn a string into theFieldConstants
value."field" = FieldConstants.FIELD; "eventIn" = FieldConstants.EVENTIN; "eventOut" = FieldConstants.EVENTOUT; "exposedField" = FieldConstants.EXPOSEDFIELD;
- Throws:
ParseException
-
RestrictedFieldType
Rule 21 - Turn a string into theFieldConstants
value. Restricted declaration of a field type of "field" "eventIn" and "eventOut" but does not allow "exposedField""field" = FieldConstants.FIELD; "eventIn" = FieldConstants.EVENTIN; "eventOut" = FieldConstants.EVENTOUT;
- Throws:
ParseException
-
FieldId
Rule 22 - Parse a field identifier.Id
Concatention of fieldType that we really only care about the ID if the user wants to provided expanded types.- Throws:
ParseException
-
FieldValue
Rule 23 - Parse a field value statement.The value of a field. Just a literral string to pass back to the caller FieldValue :: = SingleFieldValue | MultiFieldValue
- Throws:
ParseException
-
SingleFieldValue
Rule 24 - Parse a single value of a field statement.SingleFieldValue ::= NodeStatement | # SFNode "NULL" | # empty SFNode or empty MFNode LiteralValue
- Throws:
ParseException
-
MultiFieldValue
Rule 25 - Parse a multi value field statement.MultiFieldValue ::= "["(NodeStatment)+ "]" | # MFNode "[ (SingleFieldvalue)* ]
- Throws:
ParseException
-
LiteralValue
Rule 26 - Parse a literal value for a single field value.LiteralValue ::= TRUE | FALSE | NumberArray | STRING_LITERAL
We do allow a full number array here - ie more than the max 4 values that an SFRotation contains. This makes our parsing faster, but less correct. Basically we assume the callback will deal with any extra numbers if they want to by either discarding them or throwing an error.- Throws:
ParseException
-
StringArray
Rule 27 - Parse an array of string literals.StringArray ::= STRING_LITERAL+
- Throws:
ParseException
-
NumberArray
Rule 28 - Parse a number that may contain multiple whitespace values - such as an SFVec3f.NumberArray ::= NUMBER_LITERAL+
- Throws:
ParseException
-
FixedNumberArray
Rule 29 - Parse a number that may contain multiple whitespace values - such as an SFVec3f.NumberArray ::= NUMBER_LITERAL+
- Throws:
ParseException
-
Id
Generate an identifier as a string from the parsed token.- Throws:
ParseException
-
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
generateParseException
Generate ParseException. -
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing.
-