Language

The script syntax has similarities to JavaScript as well as several other scripting languages. VRMLScript was designed to be parsed by YACC and is therefore an LALR(1) grammar.

1.1 BNF of script syntax

script :
functions
NULL
functions:
functions function
function
function:
function beginFunction ( args ) statementBlock
beginFunction:
identifier
args:
args , identifier
identifier
NULL
stmntblk:
{ statements }
{ }
statement
statements :
statements statement
statement
statement :
ifStatement
forStatement
whileStatement
returnStatement ;
breakStatement ;
continueStatement ;
compoundExpression ;
ifStatement :
if ( compoundExpression ) statementBlock
if ( compoundExpression ) statementBlock else statementBlock
forStatement :
for ( optionalExpression ; optionalExpression ; optionalExpression ) statementBlock
whileStatement :
while ( compoundExpression ) statementBlock
returnStatement :
return compoundExpression
return
breakStatement :
break
continueStatement :
continue
compoundExpression :
expression , compoundExpression
expression
optionalExpression:
compoundExpression
NULL
expression : ( compoundExpression )
expression
! expression
~ expression
leftVariable = expression
leftVariable += expression
leftVariable -= expression
leftVariable *= expression
leftVariable /= expression
leftVariable %= expression
leftVariable &= expression
leftVariable |= expression
leftVariable ^= expression
leftVariable <<= expression
leftVariable >>= expression
leftVariable >>>= expression
++ expression
expression
expression ++
expression
expression ? expression : expression
expression == expression
expression != expression
expression < expression
expression <= expression
expression >= expression
expression > expression
expression + expression
expression expression
expression * expression
expression / expression
expression % expression
expression && expression
expression || expression
expression & expression
expression | expression
expression ^ expression
expression << expression
expression >> expression
expression >>> expression
string
number
objectMethodCall
objectMemberAccess
functionCall
new constructor
arrayDereference
variable
functionCall :
identifier ( params )
constructor :
identifier ( params )
objectMethodCall :
expression . identifier ( params )
objectMethodAccess :
expression . identifier
params :
params , expression
expression
NULL
arrayDereference :
expression [ compoundExpression ]
leftVariable :
objectMethodAccess
arrayDereference
variable
variable :
identifier
string:
utf8
number:
0{0-7}+
… ANSI C floating point number …
0X{ 0-9 }+
0x{ 0-9 }+
TRUE
true
FALSE
false
identifier:
utf8Character { utf8 }*
utf8Character:
… any legal UTF8 character except 0-9 …
utf8:
utf8Character
0-9

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*