package gen; import edu.neu.ccs.demeterf.demfgen.lib.*; import edu.neu.ccs.demeterf.*; nogen Option(X): Some(X) | None(X). nogen Some(X) = <just> X. nogen None(X) = . nogen List(X) : Cons(X) | Empty(X). nogen Cons(X) = <first> X <rest> List(X). nogen Empty(X) = . // for Map extern interface Comparable(X):. nogen Entry(K:Comparable(K),V) = "(" <key> K *s "->" *s <val> 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 <map> 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 <color> RBColor *s <data> X *s <left> RBTree(X) *s <right> RBTree(X) . nogen RBLeaf(X:Comparable(X)) = . // illustrate MapReduce //Start = <documents> List(Document) EOF. //Document = "(" // // document names don't appear in the output // <documentName> DocumentName ":" // <words> List(Word) ")". //Word = <id> ident. //DocumentName = <id> ident. RawMaterial = <constraints> List(Constraint) "pred" <pred> Option(List(RelationNr)) "nested" <nested> Option(Option(String)) "not" "nested" <not> Option(String) EOF. Constraint = <w> Weight <r> RelationNr <cs> List(Variable) *l. Weight = <v> int ":" *s. RelationNr = <v> int *s. Variable = <v> ident *s. // Main = .