Extensible 3D (X3D) encodings
Part 2: Classic VRML encoding

Annex A

(normative)

Grammar
 

--- X3D separator bar ---

cube A.1 Introduction

A.1.1 Topics

This annex specifies the grammar for each syntactic element in this part of ISO/IEC 19776. Table A.1 contains a table of contents that lists the topics in this clause:

Table A.1 — Topics in this annex

A.1 Introduction
   A.1.1 Topics
   A.1.2 Overview
A.2 General
A.3 Nodes
A.4 Fields

Table A.1 — Topics in this annex
Table A.2 — X3D Classic VRML encoding lexical elements

A.1.2 Overview

It is not possible to parse X3D files using a context-free grammar. Semantic knowledge of the names and types of fields (either built-in or user-defined using PROTO or EXTERNPROTO) shall be used during parsing so that the parser knows which field type is being parsed.

For the Classic VRML encoding, the # character begins a comment. The first line of the file, the header, also starts with a # character. Two forms of comment are allowed, a single line comment and a block comment. A single line comment starts with a # and continues until the next line or file terminator, whichever comes first. A block comment starts with #/* and continues until */#. Line terminators are ignored. An unterminated block comment is an error.

Within either a single line comment or a block comment, all characters are ignored except as described above. A single line or block comment cannot start within a double-quoted SFString or within MFString fields. Within an SFString or MFString field, the # character or #/* character sequence is considered part of the SFString or MFString field.

The carriage return (0x0d), linefeed (0x0a), space (0x20), tab (0x09), and comma (0x2c) characters are whitespace characters wherever they appear outside of quoted SFString or MFString fields. Any number of whitespace characters and comments may be used to separate the syntactic entities of an X3D file. All reserved keywords are displayed in boldface type.

Any characters (including linefeed and '#') may appear within the quotes of SFString and MFString fields. A double quote character within a string shall be preceded with a backslash (e.g., "Each  double quotes character \" shall have a backslash."). A backslash character within a string shall be preceded with a backslash forming two backslashes (e.g., "One backslash \\ character").

6 Encoding of nodes contains a description of the allowed fields for all pre-defined node types. The double, float, and int32 symbols are expressed using Perl regular expression syntax; see [PERL] for details. The  string symbol has not been formally specified; 5 Encoding of fields contains a more complete description of its syntax.

The following conventions are used in the semi-formal grammar specified in this clause:

  1. Keywords and terminal symbols which appear literally in the Classic VRML encoded X3D file, are specified in bold.
  2. Non-terminal symbols used in the grammar are specified in italic.
  3. Production rules begin with a non-terminal symbol and the sequence of characters "::=", and end with a semi-colon (";").
  4. Alternation for production rules is specified using the vertical-bar symbol ("|").

Table A.2 contains the complete list of lexical elements for the grammar in this part of ISO/IEC 19776.

Table A.2 — X3D Classic VRML encoding lexical elements

Keywords Terminal
symbols
Other
symbols
AS
COMPONENT
DEF
EXPORT
EXTERNPROTO
FALSE
IMPORT
IS
META
NULL
PROFILE
PROTO
ROUTE
TO
TRUE
UNIT
USE
inputOnly
outputOnly
inputOutput
initializeOnly
period (.)
open brace ({)
close brace (})
open bracket ([)
close bracket (])
colon (:)
Id
double
fieldType
float
int32
string

Terminal symbols and the string symbol may be separated by one or more whitespace characters. Keywords and the Id, fieldType, float, int32, and double symbols shall be separated by one or more whitespace characters.

--- X3D separator bar ---

cube A.2 General

x3dScene ::=
       headerStatement
       profileStatement
       componentStatements
       unitStatements
       metaStatements
 statements ;
headerStatement ::=
#X3D 3.3 utf8 string ;
profileStatement ::=
PROFILE profileNameId ;
profileNameId ::=
Id ;
componentStatements ::=
componentStatement |
componentStatement componentStatements |
empty ;
componentStatement ::=
COMPONENT componentNameId:componentSupportLevel ;
componentNameId ::=
Id ;
componentSupportLevel ::=
int32 ;
unitStatements ::=
unitStatement |
unitStatement unitStatements |
empty ;
unitStatement ::=
UNIT categoryNameId unitNameId unitConversionFactor ;
categoryNameId ::=
Id ;
unitNameId ::=
Id ;
unitConversionFactor ::=
double ;
exportStatement ::=
EXPORT nodeNameId AS exportedNodeNameId ;
importStatement ::=
IMPORT inlineNodeNameId.exportedNodeNameId AS nodeNameId ;
metaStatements ::=
metaStatement |
metaStatement metaStatements |
empty ;
metaStatement ::=
META metakey metavalue ;
metakey ::=
string ;
metavalue ::=
string ;
statements ::=
statement |
statement statements |
empty ;
statement ::=
nodeStatement |
importStatement |
exportStatement |
protoStatement |
routeStatement ;
nodeStatement ::=
node |
DEF nodeNameId node |
USE nodeNameId ;
rootNodeStatement ::=
node | DEF nodeNameId node ;
protoStatement ::=
proto |
externproto ;
protoStatements ::=
protoStatement |
protoStatement protoStatements |
empty ;
proto ::=
PROTO nodeTypeId [ interfaceDeclarations ] { protoBody } ;
protoBody ::=
protoStatements rootNodeStatement statements ;
interfaceDeclarations ::=
interfaceDeclaration |
interfaceDeclaration interfaceDeclarations |
empty ;
restrictedInterfaceDeclaration ::=
inputOnly fieldType inputOnlyId |
outputOnly fieldType outputOnlyId |
initializeOnly fieldType initializeOnlyId fieldValue;
interfaceDeclaration ::=
restrictedInterfaceDeclaration |
inputOutput fieldType inputOutputId fieldValue ;
externproto ::=
EXTERNPROTO nodeTypeId [ externInterfaceDeclarations ] URLList ;
externInterfaceDeclarations ::=
externInterfaceDeclaration |
externInterfaceDeclaration externInterfaceDeclarations |
empty ;
externInterfaceDeclaration ::=
inputOnly fieldType inputOnlyId |
outputOnly fieldType outputOnlyId |
initializeOnly fieldType initializeOnlyId |
inputOutput fieldType inputOutputFieldId ;
routeStatement ::=
ROUTE nodeNameId . outputOnlyId TO nodeNameId . inputOnlyId ;
URLList ::=
mfstringValue ;
empty ::=
;
--- X3D separator bar ---

cube A.3 Nodes

node ::=
nodeTypeId { nodeBody } |
Script { scriptBody } |
ComposedShader {composedShaderBody} |
PackagedShader {packagedShaderBody} |
ShaderProgram {shaderProgramBody} ;
nodeBody ::=
nodeBodyElement |
nodeBodyElement nodeBody |
empty ;
scriptBody ::=
extensibleBodyElement |
extensibleBodyElement scriptBody |
empty ;
extensibleBodyElement ::=
nodeBodyElement |
restrictedInterfaceDeclaration |
inputOnly fieldType inputOnlyId IS inputOnlyId |
outputOnly fieldType outputOnlyId IS outputOnlyId |
initializeOnly fieldType initializeOnlyId IS initializeOnlyId;
inputOutput fieldType inputOutputId IS inputOutputId;
composedShaderBody ::=
extensibleBodyElement |
extensibleBodyElement composedShaderBody |
empty ;
packagedShaderBody ::=
extensibleBodyElement |
extensibleBodyElement packagedShaderBody |
empty ;
shaderProgramBody ::=
extensibleBodyElement |
extensibleBodyElement shaderProgramBody |
empty ;
nodeBodyElement ::=
initializeOnlyId fieldValue |
inputOutputId fieldValue |
initializeOnlyId IS initializeOnlyId |
inputOnlyId IS inputOnlyId |
outputOnlyId IS outputOnlyId |
inputOutputId IS inputOutputId |
routeStatement |
protoStatement ;
nodeNameId ::=
Id ;
nodeTypeId ::=
Id ;
inlineNodeNameId ::=
Id ;
exportedNodeNameId ::=
Id ;
nodeTypeId ::=
Id ;
initializeOnlyId ::=
Id ;
inputOnlyId ::=
Id ;
inputOutputId ::=
Id ;
outputOnlyId ::=
Id ;
Id ::=
IdFirstChar |
IdFirstChar IdRestChars ;
IdFirstChar ::=
Any ISO-10646 character encoded using UTF-8 except: 0x30-0x3a, 0x0-0x20, 0x22, 0x23, 0x27, 0x2b, 0x2c, 0x2d, 0x2e, 0x5b, 0x5c, 0x5d, 0x7b, 0x7d, 0x7f ;
IdRestChars ::=
Any number of ISO-10646 characters except: 0x0-0x20, 0x22, 0x23, 0x27, 0x2c, 0x2e, 0x3a, 0x5b, 0x5c, 0x5d, 0x7b, 0x7d, 0x7f ;
--- X3D separator bar ---

cube A.4 Fields

fieldType ::=
MFBool |
MFColor |
MFColorRGBA |
MFDouble |
MFFloat |
MFImage |
MFInt32 |
MFMatrix3d |
MFMatrix3f |
MFMatrix4d |
MFMatrix4f |
MFNode |
MFRotation |
MFString |
MFTime |
MFVec2d |
MFVec2f |
MFVec3d |
MFVec3f |
MFVec4d |
MFVec4f |
SFBool |
SFColor |
SFColorRGBA |
SFDouble |
SFFloat |
SFImage |
SFInt32 |
SFMatrix3d |
SFMatrix3f |
SFMatrix4d |
SFMatrix4f |
SFNode |
SFRotation |
SFString |
SFTime |
SFVec2d |
SFVec2f |
SFVec3d |
SFVec3f |
SFVec4d |
SFVec4f ;
 
fieldValue ::=
sfboolValue |
sfcolorValue |
sfcolorRGBAValue |
sfdoubleValue |
sffloatValue |
sfimageValue |
sfint32Value |
sfmatrix3dValue |
sfmatrix3fValue |
sfmatrix4dValue |
sfmatrix4fValue |
sfnodeValue |
sfrotationValue |
sfstringValue |
sftimeValue |
sfvec2dValue |
sfvec2fValue |
sfvec3dValue |
sfvec3fValue |
sfvec4dValue |
sfvec4fValue |
mfboolValue |
mfcolorValue |
mfcolorRGBAValue |
mfdoubleValue |
mffloatValue |
mfimageValue |
mfint32Value |
mfmatrix3dValue |
mfmatrix3fValue |
mfmatrix4dValue |
mfmatrix4fValue |
mfnodeValue |
mfrotationValue |
mfstringValue |
mftimeValue |
mfvec2dValue |
mfvec2fValue |
mfvec3dValue |
mfvec3fValue |
mfvec4dValue |
mfvec4fValue ;
sfboolValue ::=
TRUE |
FALSE ;
sfcolorValue ::=
float float float ;
sfcolorRGBAValue ::=
float float float float ;
sfdoubleValue ::=
double ;
double ::=
([+/-]?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+\-]?[0-9]+)?))
sffloatValue ::=
float ;
float ::=
([+/-]?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+\-]?[0-9]+)?)).
sfimageValue ::=
int32 int32 int32 ...
sfint32Value ::=
int32 ;
int32 ::=
([+\-]?(([0-9]+)|(0[xX][0-9a-fA-F]+)))
sfmatrix3dValue ::=
double double double double double double double double double ;
sfmatrix3fValue ::=
float float float float float float float float float ;
sfmatrix4dValue ::=
double double double double double double double double double double double double double double double double ;
sfmatrix4fValue ::=
float float float float float float float float float float float float float float float float ;
sfnodeValue ::=
nodeStatement |
NULL ;
sfrotationValue ::=
float float float float ;
sfstringValue ::=
string ;
string ::=
".*" ... double-quotes must be \", backslashes must be \\...
sftimeValue ::=
double ;
sfvec2dValue ::=
double double ;
sfvec3dValue ::=
double double double ;
sfvec2fValue ::=
float float ;
sfvec3fValue ::=
float float float ;
sfvec4dValue ::=
double double double double ;
sfvec4fValue ::=
float float float float ;
mfboolValue ::=
sfboolValue |
[ ] |
[ sfboolValues ] ;
sfboolValues ::=
sfboolValue |
sfboolValue sfboolValues ;
mfcolorValue ::=
sfcolorValue |
[ ] |
[ sfcolorValues ] ;
sfcolorValues ::=
sfcolorValue |
sfcolorValue sfcolorValues ;
mfcolorRGBAValue ::=
sfcolorRGBAValue |
[ ] |
[ sfcolorRGBAValues ] ;
sfcolorRGBAValues ::=
sfcolorRGBAValue |
sfcolorRGBAValue sfcolorRGBAValues ;
mfdoubleValue ::=
sfdoubleValue |
[ ] |
[ sfdoubleValues ] ;
sfdoubleValues ::=
sfdoubleValue |
sfdoubleValue sfdoubleValues ;
mffloatValue ::=
sffloatValue |
[ ] |
[ sffloatValues ] ;
sffloatValues ::=
sffloatValue |
sffloatValue sffloatValues ;
mfimageValue ::=
sfimageValue |
[ ] |
[ sfimageValues ] ;
sfimageValues ::=
sfimageValue |
sfimageValue sfimageValues ;
sfint32Values ::=
sfint32Value |
sfint32Value sfint32Values ;
mfint32Value ::=
sfint32Value |
[ ] |
[ sfint32Values ] ;
nodeStatements ::=
nodeStatement |
nodeStatement nodeStatements ;
mfnodeValue ::=
nodeStatement |
[ ] |
[ nodeStatements ] ;
sfmatrix3dValues ::=
sfmatrix3dValue |
sfmatrix3dValue sfmatrix3dValues ;
mfmatrix3dValue ::=
sfmatrix3dValue |
[ ] |
[ sfmatrix3dValues ] ;
sfmatrix3fValues ::=
sfmatrix3fValue |
sfmatrix3fValue sfmatrix3fValues ;
mfmatrix3fValue ::=
sfmatrix3fValue |
[ ] |
[sfmatrix3fValues ] ;
sfmatrix4dValues ::=
sfmatrix4dValue |
sfmatrix4dValue sfmatrix4dValues ;
mfmatrix4dValue ::=
sfmatrix4dValue |
[ ] |
[ sfmatrix4dValues ] ;
sfmatrix4fValues ::=
sfmatrix4fValue |
sfmatrix4fValue sfmatrix4fValues ;
mfmatrix4fValue ::=
sfmatrix4fValue |
[ ] |
[ sfmatrix4fValues ] ;
mfrotationValue ::=
sfrotationValue |
[ ] |
[ sfrotationValues ] ;
sfrotationValues ::=
sfrotationValue |
sfrotationValue sfrotationValues ;
mfstringValue ::=
sfstringValue |
[ ] |
[ sfstringValues ] ;
sfstringValues ::=
sfstringValue |
sfstringValue sfstringValues ;
mftimeValue ::=
sftimeValue |
[ ] |
[ sftimeValues ] ;
sftimeValues ::=
sftimeValue |
sftimeValue sftimeValues ;
sfvec2dValues ::=
sfvec2dValue |
sfvec2dValue sfvec2dValues ;
mfvec2dValue ::=
sfvec2dValue |
[ ] |
[ sfvec2dValues ] ;
sfvec3dValues ::=
sfvec3dValue |
sfvec3dValue sfvec3dValues ;
mfvec3dValue ::=
sfvec3dValue |
[ ] |
[ sfvec3dValues ] ;
sfvec2fValues ::=
sfvec2fValue |
sfvec2fValue sfvec2fValues ;
mfvec2fValue ::=
sfvec2fValue |
[ ] |
[ sfvec2fValues ] ;
sfvec3fValues ::=
sfvec3fValue |
sfvec3fValue sfvec3fValues ;
mfvec3fValue ::=
sfvec3fValue |
[ ] |
[ sfvec3fValues ] ;
sfvec4dValues ::=
sfvec4dValue |
sfvec4dValue sfvec4dValues ;
mfvec4dValues ::=
sfvec4dValue |
[ ] |
[ sfvec4dvalues ] ;
sfvec4fValues ::=
sfvec4fValue |
sfvec4fValue sfvec4fValues ;
mfvec4fValues ::=
sfvec4fvalue |
[ ] |
[ sfvec4fvalues ] ;
--- X3D separator bar ---