The Virtual Reality Modeling Language
Annex A
(normative)
Grammar definition
A.1 Table of contents and introduction
A.1.1 Table of contents
This annex provides a detailed description of the grammar for each syntactic
element in this part of ISO/IEC 14772. The following table of contents lists
the topics in this clause:
A.1 Table of contents and introduction
A.1.1 Table
of contents
A.1.2 Introduction
A.2 General
A.3 Nodes
A.4 Fields
A.1.2 Introduction
It is not possible to parse VRML files using a context-free grammar.
Semantic knowledge of the names and types of fields, eventIns, and eventOuts
for each node type (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.
The '#' (0x23) character begins a comment wherever it appears outside
of the first line of the VRML file or quoted SFString or MFString fields.
The '#' character and all characters until the next line terminator comprise
the comment and are treated as whitespace.
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
a VRML 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").
Clause 6, Nodes reference, contains a description
of the allowed fields, eventIns and eventOuts for all pre-defined node types.
The double, float, and int32 symbols are expressed
using Perl regular expression syntax; see E.[PERL]
for details. The IdFirstChar, IdRestChars, and string
symbols have not been formally specified; Clause 5,
Fields and events reference, contains a more complete description of
their syntax.
The following conventions are used in the semi-formal grammar specified
in this clause:
- Keywords and terminal symbols which appear literally in the VRML file,
are specified in bold.
- Nonterminal symbols used in the grammar are specified in italic.
- Production rules begin with a nonterminal symbol and the sequence of
characters "::=", and end with a semi-colon (";").
- Alternation for production rules is specified using the vertical-bar
symbol ("|").
Table A.1 contains the complete list of lexical
elements for the grammar in this part of ISO/IEC 14772.
Table A.1 -- VRML lexical elements
Keywords |
Terminal
symbols |
Other
symbols |
DEF
EXTERNPROTO
FALSE
IS
NULL
PROTO
ROUTE
TO
TRUE
USE
eventIn
eventOut
exposedField
field |
period (.)
open brace ({)
close brace (})
open bracket ([)
close bracket (]) |
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.
A.2 General
- vrmlScene ::=
- statements ;
- statements ::=
- statement |
- statement statements |
- empty ;
- statement ::=
- nodeStatement |
- 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 ::=
- eventIn fieldType eventInId |
- eventOut fieldType eventOutId |
- field fieldType fieldId fieldValue ;
- interfaceDeclaration ::=
- restrictedInterfaceDeclaration |
- exposedField fieldType fieldId fieldValue ;
- externproto ::=
- EXTERNPROTO nodeTypeId [ externInterfaceDeclarations
] URLList ;
- externInterfaceDeclarations ::=
- externInterfaceDeclaration |
- externInterfaceDeclaration externInterfaceDeclarations |
- empty ;
- externInterfaceDeclaration ::=
- eventIn fieldType eventInId |
- eventOut fieldType eventOutId |
- field fieldType fieldId |
- exposedField fieldType fieldId ;
- routeStatement ::=
- ROUTE nodeNameId . eventOutId TO
nodeNameId . eventInId ;
- URLList ::=
- mfstringValue ;
- empty ::=
- ;
A.3 Nodes
- node ::=
- nodeTypeId { nodeBody } |
- Script { scriptBody } ;
- nodeBody ::=
- nodeBodyElement |
- nodeBodyElement nodeBody |
- empty ;
- scriptBody ::=
- scriptBodyElement |
- scriptBodyElement scriptBody |
- empty ;
- scriptBodyElement ::=
- nodeBodyElement |
- restrictedInterfaceDeclaration |
- eventIn fieldType eventInId IS eventInId
|
- eventOut fieldType eventOutId IS eventOutId
|
- field fieldType fieldId IS fieldId ;
- nodeBodyElement ::=
- fieldId fieldValue |
- fieldId IS fieldId |
- eventInId IS eventInId |
- eventOutId IS eventOutId |
- routeStatement |
- protoStatement ;
- nodeNameId ::=
- Id ;
- nodeTypeId ::=
- Id ;
- fieldId ::=
- Id ;
- eventInId ::=
- Id ;
- eventOutId ::=
- Id ;
- Id ::=
- IdFirstChar |
- IdFirstChar IdRestChars ;
- IdFirstChar ::=
- Any ISO-10646 character encoded using UTF-8 except: 0x30-0x39, 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, 0x5b, 0x5c, 0x5d, 0x7b, 0x7d, 0x7f ;
A.4 Fields
- fieldType ::=
- MFColor |
- MFFloat |
- MFInt32 |
- MFNode |
- MFRotation |
- MFString |
- MFTime |
- MFVec2f |
- MFVec3f |
- SFBool |
- SFColor |
- SFFloat |
- SFImage |
- SFInt32 |
- SFNode |
- SFRotation |
- SFString |
- SFTime |
- SFVec2f |
- SFVec3f ;
- fieldValue ::=
- sfboolValue |
- sfcolorValue |
- sffloatValue |
- sfimageValue |
- sfint32Value |
- sfnodeValue |
- sfrotationValue |
- sfstringValue |
- sftimeValue |
- sfvec2fValue |
- sfvec3fValue |
- mfcolorValue |
- mffloatValue |
- mfint32Value |
- mfnodeValue |
- mfrotationValue |
- mfstringValue |
- mftimeValue |
- mfvec2fValue |
- mfvec3fValue ;
- sfboolValue ::=
- TRUE |
- FALSE ;
- sfcolorValue ::=
- float float float ;
- 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]+)))
- sfnodeValue ::=
- nodeStatement |
- NULL ;
- sfrotationValue ::=
- float float float float ;
- sfstringValue ::=
- string ;
- string ::=
- ".*" ... double-quotes must be \", backslashes
must be \\...
- sftimeValue ::=
- double ;
- double ::=
- ([+/-]?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+\-]?[0-9]+)?))
- mftimeValue ::=
- sftimeValue |
- [ ] |
- [ sftimeValues ] ;
- sftimeValues ::=
- sftimeValue |
- sftimeValue sftimeValues ;
- sfvec2fValue ::=
- float float ;
- sfvec3fValue ::=
- float float float ;
- mfcolorValue ::=
- sfcolorValue |
- [ ] |
- [ sfcolorValues ] ;
- sfcolorValues ::=
- sfcolorValue |
- sfcolorValue sfcolorValues ;
- mffloatValue ::=
- sffloatValue |
- [ ] |
- [ sffloatValues ] ;
- sffloatValues ::=
- sffloatValue |
- sffloatValue sffloatValues ;
- mfint32Value ::=
- sfint32Value |
- [ ] |
- [ sfint32Values ] ;
- sfint32Values ::=
- sfint32Value |
- sfint32Value sfint32Values ;
- mfnodeValue ::=
- nodeStatement |
- [ ] |
- [ nodeStatements ] ;
- nodeStatements ::=
- nodeStatement |
- nodeStatement nodeStatements ;
- mfrotationValue ::=
- sfrotationValue |
- [ ] |
- [ sfrotationValues ] ;
- sfrotationValues ::=
- sfrotationValue |
- sfrotationValue sfrotationValues ;
- mfstringValue ::=
- sfstringValue |
- [ ] |
- [ sfstringValues ] ;
- sfstringValues ::=
- sfstringValue |
- sfstringValue sfstringValues ;
- mfvec2fValue ::=
- sfvec2fValue |
- [ ] |
- [ sfvec2fValues] ;
- sfvec2fValues ::=
- sfvec2fValue |
- sfvec2fValue sfvec2fValues ;
- mfvec3fValue ::=
- sfvec3fValue |
- [ ] |
- [ sfvec3fValues ] ;
- sfvec3fValues ::=
- sfvec3fValue |
- sfvec3fValue sfvec3fValues ;
http://www.vrml.org/Specifications/VRML97/part1/grammar.html