Listing 3 Partial grammar for a test specification file

// File:     DGEN.SYN
// Copyright Norman Wilde 1993
// AnaGram grammar for a test specification file
//  (partial)

grammar
 -> statement..., eof              =writeDriver();
statement
 -> embeddedBlock, space?...
 -> runStatement, space?...
 -> declaration, space?...
embeddedBlock
 -> block:eb                       =addBlock(eb);
runStatement
  -> runHeader, space..., testSpec
runHeader
  -> "runtest", space..., string:n =setRunName(n);
testSpec
  -> "combining", space...,
     variableList:vl, block:b     =makeComb(vl,b);
(struct STRLIST *) variableList
  -> variable:v, space...         =listNew(v,"");
  -> variableList:lst,
     variable:v, space...        =listAdd(lst,v,"");
declaration
 -> intDeclaration
 -> ItemDeclaration
 -> ClientDeclaration
 -> InvoiceDeclaration
// Declaration of a set of integers
intDeclaration
  -> "int", space...,
     variableList:vl, "{", space?...,
     initializorList:il, "}"
          =addTVars(vl,"int","int",il);
// Declaration of a set of Item objects
ItemDeclaration
 -> "Item", space...,
    variableList:vl, "{", space?...,
    initializorList:il, "}"
          =addTVars(vl,"Item","Item&",il);
// Declaration of a set of Client objects
ClientDeclaration
 -> "Client", space...,
    variableList:vl, "{", space?...,
    initializorList:il, "}"
          =addTVars(vl,"Client","Client&",il);
// Declaration of a set of Invoice objects
InvoiceDeclaration
 -> "Invoice", space...,
    variableList:vl, "{", space?...,
    initializorList:il, "}"
         =addTVars(vl,"Invoice","Invoice&",il);

// End of File