Templates for the SEDRIS DRM

Annex A

Abstract scripting language grammar

A.1 Introduction

A.1.1 Topics

This annex provides a specification of a portion of this part of ISO/IEC 18023 in the form of UML diagrams that illustrate the relationships among the various DRM classes. Table A.1 lists the topics in this annex:

Table A.1 — Topics

Annex A Abstract scripting language grammar

A.1 Introduction

A.1.1 Topics

A.1.2 Overview

A.2 General

A.3 Data types

A.4 Statements

A.1.2 Overview

It is not possible to parse abstract scripting language scripts using a context-free grammar. Semantic knowledge of the names and  data types 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 X3D 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 String values. Any number of whitespace characters and comments may be used to separate the syntactic entities of a SEDRIS Templates abstract script. All reserved keywords are displayed in boldface type.

Any characters (including linefeed and '#') may appear within the quotes of String values. 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 Abstract scripting language contains a description of the allowed data types. The IdFirstChar, IdRestChars, and string symbols have not been formally specified.

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

1. Keywords and terminal symbols that appear literally in the script 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 technical report.

Table A.2 — SEDRIS Templates abstract scripting language encoding lexical elements

Keywords Terminal
symbols
Other
symbols
DO
ELSE
enum
FALSE
IF
record
TRUE
VOID
WHILE
semicolon (;)
open brace ({)
close brace (})
open bracket ([)
close bracket (])
open parenthesis (()
close parenthesis ())
Boolean
Float
Handle
Integer
String

Terminal symbols may be separated by one or more whitespace characters. Keywords and the other symbols shall be separated by one or more whitespace characters.

A.2 General

script ::= statements ;
statements ::=
statement |
statement statements |
empty ;
empty ::=
;
--- X3D separator bar ---

A.3 Data types

dataType ::=
VOID |
simpleDataType |
arrayDataType ;
simpleDataType ::=
String |
enumeratedDataTypeName |
Boolean |
Handle |
Integer |
Float |
recordDataTypeName
;
arrayDataType ::=
simpleDataType[[0-9]+] ;
--- X3D separator bar ---

A.4 Statements

statement ::=
assignmentStatement |
blockStatement |
functionStatement |
IFELSEStatement |
WHILEDOStatement |
functionDeclaration |
enumeratedDataTypeDeclaration |
recordDataTypeDeclaration |
variableDeclaration;
assignmentStatement ::=
variable := expression;;
blockStatement ::=
{statements};;
functionStatement ::=
functionReference;;
functionReference ::=
functionName (expressionList);;
IFELSEStatement ::=
if (booleanExpression) statement |
if (booleanExpression) statement else statement;;
WHILEDOStatement ::=
while (booleanExpression) do statement;;
expressionList ::=
expression |
expressions, expressionList |
empty ;
expression ::=
arithmeticExpression |
relationalExpression |
logicalExpression;
arithmeticExpression ::=
number |
number arithmeticOperator arithmeticExpression ;
arithmeticOperator ::=
+ | - | * | / ;
number ::=
integer |
float ;
integer ::=
+ | -[0-9]+ ;
float ::=
([+-][0-9]+.[0-9]+) |
([+-][0-9]+.[0-9]+[eE][+-][0-9]+) ;
relationalExpression ::=
arithmeticExpression relationalOperator arithmeticExpression |
enumeratedValueName equalityOperator enumeratedValueName |
logicalExpression equalityOperator logicalExpression ;
relationalOperator ::=
< | | = | | | > ;
equalityOperator ::=
= | ;
enumeratedValueName ::=
Id ; (see 6.2.2.4 Enumerated for restrictions)
logicalExpression ::=
booleanValue |
!booleanValue |
booleanValue logicalOperator logicalExpression ;
booleanValue ::=
TRUE |
FALSE |
variableName | (shall be of data type Boolean)
relationalExpression ;
logicalOperator ::=
& | | ;
booleanExpression ::=
relationalExpression |
logicalExpression
;
handleValue ::=
[0-9]+ ;
enumeratedDataTypeDeclaration ::=
enum enumeratedDataTypeName : enumeratedValueList; ;
enumeratedDataTypeName ::=
Id ; (see 6.2.2.4 Enumerated for restrictions)
enumeratedValueList ::=
enumeratedValueName |
enumeratedValueName, enumeratedValueList ;
recordDataTypeDeclaration ::=
record recordDataTypeName recordPart ; ;
recordDataTypeName ::=
Id ; (see 6.2.2.9.1 Introduction for restrictions)
recordPart ::=
fixedRecordPart |
variableRecordPart ;
fixedRecordPart ::=
{ listOfFields } ;
listOfFields ::=
field |
field
, listOfFields ;
field ::=
simpleDataType fieldName ;
fieldName ::=
Id ; (see 6.2.2.9.2 Fields for restrictions)
variantRecordPart :==
( discriminantField ) { discriminantListOfFields } ;
discriminantField ::=
enumeratedDataTypeName  fieldName |
Integer fieldName ;
discriminantListOfFields ::=
discriminantListOfFieldsElement |
discriminantListOfFieldsElement , discriminantListOfFields ;
discriminantListOfFieldsElement ::=
( discriminantValue : listOfFields ) ;
discriminantValue ::=
enumeratedValueName |
Integer ;
variableDeclaration ::=
dataType variableName; ;
variableName ::=
Id ; (see 6.2.3 Variables for restrictions)
functionDeclaration ::=
functionReturnDataType functionName (dataTypeList); ;
functionReturnDataType ::=
VOID |
dataType ;
functionName ::=
Id ; (see 6.2.5 Functions for restrictions)
dataTypeList ::=
dataType |
dataType, dataTypeList |
empty ;
Id ::=
IdFirstChar |
IdFirstChar IdRestChars ;
IdFirstChar ::=
Any ISO/IEC 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 ;

http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_TR_24788_Ed1.html