package gen; import edu.neu.ccs.demeterf.demfgen.lib.*; import edu.neu.ccs.demeterf.*; nogen List(X) : Cons(X) | Empty(X). nogen Cons(X) = X List(X). nogen Empty(X) = . // for Map extern interface Comparable(X):. nogen Entry(K:Comparable(K),V) = "(" K *s "->" *s V ")". // This doesn't match the real structure of a Map... but it's fine // for Parsing them, as long as the Key is Comparable (Java) // or IComparable (C#) nogen Map(K:Comparable(K),V) = "[" *s RBTree(Entry(K,V)) *s "]". nogen RBColor: RED | BLACK. nogen RED = . nogen BLACK = . nogen RBTree(X:Comparable(X)) : RBNode(X) | RBLeaf(X). nogen RBNode(X:Comparable(X)) = *s RBColor *s X *s RBTree(X) *s RBTree(X) . nogen RBLeaf(X:Comparable(X)) = . // illustrate MapReduce Start = List(Document) EOF. Document = "(" // document names don't appear in the output DocumentName ":" List(Word) ")". Word = ident. DocumentName = ident. // IntermediateResult = List(Pair). //Pair.c.v=1 // with DemeterF this class is not needed // the (w,1) pairs "hang" in the object and are collected // Pair = Word Count. // Count = int. // FinalResult = Map(Word,Integer). Main = .