Syntax Grammar

A section of a Shape Script can be quite complex, containing a number of commands and parameters. The table below provides a breakdown of the Shape Script structure, illustrating how commands and parameters are constructed. The first entry is the top-level declaration, and subsequent entries show the composition of successively more detailed components.

Grammar symbols

*  =  zero or more
+  =  one or more
|  =  or
;  =  terminator
 
 

ShapeScript

::=

<Shape>*;

 

Shape

::=

<ShapeDeclaration> <ShapeBody>;

 

ShapeDeclaration

::=

<ShapeType> <ShapeName>;

 

ShapeType

::=

"shape" | "decoration" | "label";

 

ShapeName

::=

<ReservedShapeName> | <stringliteral>;

 

ReservedShapeName

::=

See Reserved Names for full reserved shape listing.

 

ShapeBody

::=

"{" <InitialisationAttributeAssignment>* <DrawingStatement>* <SubShape>* "}";

 

InitialisationAttributeAssignment

::=

<Attribute> "=" <Value> ";";

 

Attribute

::=

See Shape Attributes for full listing of attribute names.

 

DrawingStatement

::=

<IfElseSection> | <Method>;

 

IfElseSection

::=

"if" "(" <QueryExpression> ")" <TrueSection> ( <ElseSection> ) ;

 

QueryExpression

::=

<QueryName> "(" <ParameterList> ")";

See Query Methods for descriptions of the queries and their parameters.

 

QueryName

::=

See Query Methods for the possible Query names.

 

TrueSection

::=

"{" <DrawingStatement>* "}"

 

ElseSection

::=

"else" "{" <DrawingStatement>* "}"

 

Method

::=

<MethodName> "(" <ParameterList> ")" ";";

 

MethodName

::=

See Drawing Methods for a full listing of method names.