Package edu.neu.ccs.demeterf.demfgen.dgp

DemeterF datatype generic programming classes and interfaces.

See:
          Description

Class Summary
Concrete  
DGPFunc The base class of Data-Generic Function generation objects.
Display  
DisplayToString  
Flds  
Flds.P Represnets a pair of Type/FieldName
HashCode  
ParStaticTrav Generate CD specific traversal code that statically distinguishes traversable types and calls to DemeterF dispatch functions when all child results have returned.
Print  
PrintHeap  
PrintHeapToString  
PrintIter Print using an iterator when possible...
PrintToString  
StaticBc Generate a CD specific TU for the given CD
StaticTrav Generate CD specific traversal code that statically distinguishes traversable types and calls to DemeterF dispatch functions when all child results have returned.
StaticTravCtx Generate CD specific traversal code statically with a traversal Context.
StaticTU Generate a CD specific Bc for the given CD
ToStr  
ToString  
ToXML  
TravGeneric  
 

Package edu.neu.ccs.demeterf.demfgen.dgp Description

DemeterF datatype generic programming classes and interfaces.

The class DGPFunc can be extended to implement functionality over all the classes in a given CD. This is done with a DemeterF traversal over all TypeDefs in the CD. The structures involved are defined in the demfgen CD file:
   edu/neu/ccs/demeterf/demfgen/demfgen.cd

DGPFunc implements the default usage, which introduces a no argument method with the same name as the class name in C#; when generating Java the first letter of the name is in lowercase. (e.g., Print -> public String print(){...}). Various methods in the base class affect how the methods are generated and how the CD-of-CDs is traversed. See the source for classes Concrete/Print/Display/ToStr and others for details.

There are multiple examples of useful functions including Print, ToStr, and Display, which are almost exactly the same as the corresponding visitors in DemeterJ. The provided DGP functions are as follows:

The functions to be generated are specified as an argument to DemeterF with the option: --dgp: immediately followed by a list of DGPFunc class names separated by colons (":").

Example:

CD: main.cd
        MainC = <a> A.
        A = "(" + *l <b> B *l <c> C - *l ")".
        B = "Bee" *s <i> int.
        C = "Cee" *s <s> String.
      

BEH (Java): main.beh
 
        MainC{{
          public static void main(String[] s) throws Exception{
            MainC m = MainC.parse("(Bee -54 Cee \"Test\")");
            System.out.println("\nPrint:\n"+m.print());
            System.out.println("\nDisplay:\n"+m.display());
          }
        }}
      

BEH (C#): main.cs.beh
 
        MainC{{
          public static void Main(String[] s){
            MainC m = MainC.parse("(Bee -54 Cee \"Test\")");
            Console.WriteLine("\nPrint:\n"+m.Print());
            Console.WriteLine("\nDisplay:\n"+m.Display());
          }
        }}
     

Build With:
        Java:  java demeterf main.cd main.beh ./ --build --dgp:Print:Display
          C#:  java demeterfcs main.cd main.cs.beh ./ --build --dgp:Print:Display
     

Run With:
        Java:  java MainC
          C#:  ./MAIN.exe
     

Output (For Both):
 
   Print:
   (
      Bee -54
      Cee "Test"
   )

   Display:
   : MainC (
      <a> : A (
        <b> : B (
            <i> : int "-54" )
        <c> : C (
            <s> : String "Test" ) ) )
  

See individual source files for more details.