Grammar

Following is the grammar for the WDL. Upper-case symbols (e.g., ROOM, NAME, PLUS) refer to either lexical tokens (Section 4.2.2.1) or literals (Section 4.2.2.2). Symbols that begin with a lower-case letter (e.g., room, condstatement, orExpr, worldDescr) are non-terminals, defined in terms of other grammatical rules. Note, also, that whitespace in the following rules is purely for readability - the grammar itself is insensitive to whitespace (as whitespace is consumed by the lexer).


// This is the start rule: an entire description file  

worldDescr := ( room | object | action )+ EOF

room := ROOMREF LPAREN NAME RPAREN
|
ROOM ( LPAREN NAME RPAREN ) LBRACE
description SEMI
objset
moveset
RBRACE

variable := VARIABLE LPAREN NAME RPAREN LBRACE
VALUES EQ LBRACE
( NAME ( COMMA NAME )* )?
RBRACE
INITVAL EQ NAME SEMI
RBRACE

object := OBJREF LPAREN NAME RPAREN
|
OBJECT LPAREN NAME RPAREN LBRACE
description SEMI
motility SEMI
( varset )?
RBRACE

action := ACTION LPAREN NAME COMMA INT RPAREN LBRACE
condstatement
RBRACE

description := DESCRIPTION EQ string

objset := OBJECTS EQ LBRACE
( object ( COMMA object )* )?
RBRACE

moveset := MOVEMENTS EQ LBRACE
( movedef )*
RBRACE

motility := MOTILITY EQ ( SESSILE | MOBILE )

varset := VARS EQ LBRACE
( variable ( COMMA variable )* )?
RBRACE

condstatement := COND LBRACE
( ( LPAREN orExpr RPAREN | DEFAULT ) LBRACE
( statement )* RBRACE )+
RBRACE

// String concatenation. All of the STRING arguments should be
// concatenated together, without introducing or deleting
// extra characters.
string := STRING ( PLUS STRING )*

movedef := MOVE LPAREN NAME RPAREN LBRACE
condstatement
RBRACE

orExpr := andExpr ( OR andExpr )*

andExpr := notExpr ( AND notExpr )*

notExpr := ( BANG )? eqExpr

eqExpr := lval EQ ( NAME | lval | MOBILE | SESSILE )
|
LPAREN orExpr RPAREN

lval := ( DOLLAR INT | NAME ) DOT ( NAME | MOTILITY )

statement := ( assignment | special ) SEMI

assignment := lval EQ ( NAME | room | lval )

special := print | error | warning | END

print := PRINT LPAREN string RPAREN

error := ERROR LPAREN string RPAREN

warning := WARN LPAREN string RPAREN

For semantics of this grammar, please refer to Section 4.2.5.

The designer MAY choose to provide extensions to this language, but those extensions MUST NOT interfere with the parser's ability to recognize this language. All such extensions MUST be documented in the User Documentation.

NOTE: As specified, WDL will require more than one token of lookahead in some places to distinguish possible alternatives.

Terran Lane 2005-02-28