Package org.web3d.parser.x3d
Class X3DRelaxedParser
java.lang.Object
org.web3d.parser.x3d.X3DRelaxedParser
- All Implemented Interfaces:
X3DRelaxedParserConstants
A parser for VRML97 syntax that is not very strict about the incoming
syntax.
Automatically generated from the JavaCC source grammar X3DRelaxedParser.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.25 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionNext token.Current token.Generated Token Manager.Fields inherited from interface org.web3d.parser.x3d.X3DRelaxedParserConstants
AS, COMPONENT, DEF, DEFAULT, DOT, EOF, EXPORT, EXTERNPROTO, FALSE, ID, ID_FIRST, ID_REST, IMPORT, IN_MULTI_LINE_COMMENT, INITIALIZE_ONLY, INPUT_ONLY, INPUT_OUTPUT, IS, LBRACE, LBRACKET, META, MULTI_LINE_COMMENT, NULL, NUMBER_LITERAL, OUTPUT_ONLY, PROFILE, PROTO, RBRACE, RBRACKET, ROUTE, SCRIPT, SINGLE_LINE_COMMENT, STRING_LITERAL, TO, tokenImage, TRUE, USE
-
Constructor Summary
ConstructorsConstructorDescriptionX3DRelaxedParser
(InputStream stream) Constructor with InputStream.X3DRelaxedParser
(InputStream stream, String encoding) Constructor with InputStream and supplied encodingX3DRelaxedParser
(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.X3DRelaxedParser
(Reader stream) Constructor.X3DRelaxedParser
(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 27 - Turn a string into theFieldConstants
value.final String[]
Rule 35 - Parse a MFBool arrayfinal void
Rule 3 - Parse a component name declarationfinal void
Disable tracing.final void
Enable tracing.final void
Rule 18 - Parse an EXPORT statement.final void
Rule 15 - Parse a node statement.final void
Rule 14 - Parse a node statement.final String
FieldId()
Rule 28 - Parse a field identifier.final String
Rule 26 - Parse a field name string.final Object
FieldValue
(String fieldName) Rule 29 - 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 void
Header()
Rule 1 - parse a header item.final String
Id()
Generate an identifier as a string from the parsed token.final void
Rule 17 - Parse an IMPORT statement.void
Initialise the internals of the parser at start up.final void
Rule 13 - Parse a single field interface declaration.final String
Rule 32 - Parse a literal value for a single field value.final void
MetaDecl()
Rule 4 - Parse a component name declarationfinal Object
MultiFieldValue
(String fieldName) Rule 31 - Parse a multi value field statement.final void
Rule 20 - Parse a node statement.final void
NodeBody()
Rule 21 - Parse a node statement.final void
Rule 22 - Parse a node statement.final String
Rule 24 - Parse a node statement.final void
Rule 7 - Parse a node statement.final String
Rule 25 - Parse a NodeType identifier.final String[]
Rule 34 - Parse a number that may contain multiple whitespace values - such as an SFVec3f.final void
Rule 2 - Parse a profile name declarationfinal void
Proto()
Rule 10 - Parse a PROTO declaration.final void
Rule 11 - Parse a node statement.final void
Rule 6 - Parse a proto body statement.final void
Rule 9 - Parse a node statement.void
ReInit
(InputStream stream) Reinitialise.void
ReInit
(InputStream stream, String encoding) Reinitialise.void
Reinitialise.void
Reinitialise.final void
Rule 12 - Parse an interface declaration that allows everything except exposedFields.final void
Rule 8 - Parse a node statement.final void
Rule 16 - Parse a node statement.final void
Scene()
Rule 0 - Parse the complete scene.final void
Rule 23 - Parse a node statement.final void
Rule 24 - 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 30 - Parse a single value of a field statement.final void
Rule 5 - Parse a statement.final String[]
Rule 33 - Parse an array of string literals.final String[]
URIList()
Rule 19 - 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
-
X3DRelaxedParser
public X3DRelaxedParser(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
-
X3DRelaxedParser
public X3DRelaxedParser(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
-
X3DRelaxedParser
Constructor with InputStream. -
X3DRelaxedParser
Constructor with InputStream and supplied encoding -
X3DRelaxedParser
Constructor. -
X3DRelaxedParser
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 documentLocator will also be set.- Parameters:
eh
- The error handler instance to use
-
Scene
Rule 0 - Parse the complete scene.vrmlScene ::= header | header statement *
The scene assumes that the caller will make the startDocument() and endDocument() calls on the ContentHandler before and after this method.- Throws:
ParseException
-
Header
Rule 1 - parse a header item.header ::= profileDecl componentDecls
- Throws:
ParseException
-
ProfileDecl
Rule 2 - Parse a profile name declarationprofileDecl ::= PROFILE profileName | empty;
- Throws:
ParseException
-
ComponentDecl
Rule 3 - Parse a component name declarationcomponentDecl ::= COMPONENT componentName | COMPONENT componentName ":" integer | empty;
- Throws:
ParseException
-
MetaDecl
Rule 4 - Parse a component name declarationcomponentDecl ::= META "key string" "value string" empty;
- Throws:
ParseException
-
Statement
Rule 5 - Parse a statement.statement ::= nodeStatement | protoStatement | routeStatement | importStatement | exportStatement ;
- Throws:
ParseException
-
ProtoBodyStatement
Rule 6 - Parse a proto body statement.protoBodyStatement ::= nodeStatement | protoStatement | routeStatement | importStatement ;
- Throws:
ParseException
-
NodeStatement
Rule 7 - Parse a node statement.nodeStatement ::= node | DEF NodeNameId node | USE NodeNameId ;
- Throws:
ParseException
-
RootNodeStatement
Rule 8 - Parse a node statement.rootNodeStatement ::= node | DEF NodeNameId node ;
- Throws:
ParseException
-
ProtoStatement
Rule 9 - Parse a node statement.protoStatement ::= proto | externproto ;
- Throws:
ParseException
-
Proto
Rule 10 - Parse a PROTO declaration.proto ::= PROTO NodeTypeId [ interfaceDeclaration* ] { protoBody } ;
- Throws:
ParseException
-
ProtoBody
Rule 11 - Parse a node statement.protoBody ::= protoStatement* rootNodeStatement statement* ;
- Throws:
ParseException
-
RestrictedInterfaceDecl
Rule 12 - 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 13 - Parse a single field interface declaration.interfaceDeclaration ::= restrictedInterfaceDeclaration | exposedField fieldNameId eventId fieldValue ;
- Throws:
ParseException
-
ExternProto
Rule 14 - Parse a node statement.externproto ::= EXTERNPROTO NodeTypeId [ externInterfaceDeclaration* ] URLList ;
- Throws:
ParseException
-
ExternInterfaceDecl
Rule 15 - Parse a node statement.externInterfaceDeclaration ::= accessType fieldNameId eventId
- Throws:
ParseException
-
RouteStatement
Rule 16 - Parse a node statement.routeStatement ::= ROUTE NodeNameId . eventOutId TO NodeNameId . eventInId ;
- Throws:
ParseException
-
ImportStatement
Rule 17 - Parse an IMPORT statement.ImportStatement ::= "IMPORT" NodeNameId '.' NodeNameId | "IMPORT" NodeNameId '.' NodeNameId "AS" NodeNameId
- Throws:
ParseException
-
ExportStatement
Rule 18 - Parse an EXPORT statement.ImportStatement ::= "EXPORT" NodeNameId | "EXPORT" NodeNameId "AS" NodeNameId
- Throws:
ParseException
-
URIList
Rule 19 - Parse an MFField statement - principally a URIList on the EXTERNPROTO.URLList ::= "[" STRING_LITERAL* "]" | STRING_LITERAL ;
- Throws:
ParseException
-
Node
Rule 20 - 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 21 - Parse a node statement.nodeBody ::= nodeBodyElement | nodeBodyElement nodeBody
The empty case is handled in the Node declaration- Throws:
ParseException
-
NodeBodyElement
Rule 22 - Parse a node statement.nodeBodyElement ::= fieldNameId fieldValue | fieldNameId IS fieldNameId | routeStatement | protoStatement ;
- Throws:
ParseException
-
ScriptBody
Rule 23 - Parse a node statement.scriptBody ::= scriptBodyElement | scriptBodyElement scriptBody
The empty case is handled in the Node declaration- Throws:
ParseException
-
ScriptBodyElement
Rule 24 - Parse a node statement.scriptBodyElement ::= nodeBodyElement | interfaceDeclaration | inputOnly fieldType eventInId IS eventInId | outputOnly fieldType eventInId IS eventInId | inputOutput fieldType eventOutId IS eventOutId | initializeOnly fieldType fieldNameId IS fieldNameId ;
- Throws:
ParseException
-
NodeNameId
Rule 24 - Parse a node statement.nodeNameId ::= Id ;
- Throws:
ParseException
-
NodeTypeId
Rule 25 - Parse a NodeType identifier.nodeTypeId ::= Id ;
- Throws:
ParseException
-
FieldNameId
Rule 26 - Parse a field name string.fieldNameId ::= Id ; eventInId ::= Id ; eventOutId ::= Id ; exposedFieldId ::= Id ;
- Throws:
ParseException
-
AccessType
Rule 27 - Turn a string into theFieldConstants
value."field" = FieldConstants.FIELD; "eventIn" = FieldConstants.EVENTIN; "eventOut" = FieldConstants.EVENTOUT; "exposedField" = FieldConstants.EXPOSEDFIELD;
- Throws:
ParseException
-
FieldId
Rule 28 - 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 29 - 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 30 - Parse a single value of a field statement.SingleFieldValue ::= NodeStatement | # SFNode "NULL" | # empty SFNode or empty MFNode LiteralValue
- Throws:
ParseException
-
MultiFieldValue
Rule 31 - Parse a multi value field statement.MultiFieldValue ::= "["(NodeStatment)+ "]" | # MFNode "[ (SingleFieldvalue)* ]
- Throws:
ParseException
-
LiteralValue
Rule 32 - 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 33 - Parse an array of string literals.StringArray ::= STRING_LITERAL+
- Throws:
ParseException
-
NumberArray
Rule 34 - 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
-
BooleanArray
Rule 35 - Parse a MFBool arrayNumberArray ::= (TRUE | FALSE)+
- 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.
-