// Course: CSU670 // Date: 2/26/2004 // Assignment: Part 1 of Project // sg.cd -- class dictionary for strategy graphs // $Id: sg.cd,v 1.12 2003/01/30 02:26:05 dougo Exp $ package edu.neu.ccs.demeter.aplib.sg; import java.util.*; import java.io.*; import edu.neu.ccs.demeter.aplib.*; Main = . // testing stub //--begin Kevin/David part // w/o "selector: ns1" part before Class Dictionary and no Class Dictionary // part SelectorLanguage = "strategies" "(" StrategyLanguage ")" "node" "sets" "(" NodeSubsetLanguage ")". StrategyLanguage = NPList(StrategyDef). NodeSubsetLanguage = NodeSetSpec. StrategyDef = StrategyName "=" StrategyExpression ";". StrategyName = Ident . //--end Kevin/David part StrategyExpression = Strategy. public Strategy : SimpleStrategy | StrategyCombination | StrategyReference implements StrategyI. public SimpleStrategy : StrategyGraph | PathDirective common [ "with" *s NameMap ]. public StrategyGraph = "{" *l + SList(SGEdge) - *l "}" implements SimpleStrategyI, StrategyGraphI, ConstraintMapI. SGEdge = [ SourceMarker *s ] GlobSpec *s "->" *s [ TargetMarker *s ] GlobSpec [ *s NegativeConstraint ] implements Cloneable. SourceMarker = "source:". TargetMarker = "target:". public PathDirective = SourceDirective [ *s NegativeConstraint ] List(PathSegment) *s TargetDirective. SourceDirective : From common *s ClassGlobSpec. From = "from". PathSegment = PositiveConstraint [ *s NegativeConstraint ]. Constraint : PositiveConstraint | NegativeConstraint common *s GlobSpec. PositiveConstraint : Through | Via. // synonyms Through = "through". Via = "via". NegativeConstraint : Bypassing | OnlyThrough. // antonyms Bypassing = "bypassing". OnlyThrough = "only-through". TargetDirective : To | ToStop common *s ClassGlobSpec. To = "to". ToStop = "to-stop". public StrategyCombination : Join | Merge | Intersect common "(" Strategy "," *s Commalist(Strategy) ")" implements StrategyCombinationI, Cloneable. Join = "join". Merge = "merge". Intersect = "intersect". public StrategyReference = Ident. SymbolicNameMap : NameMap implements SymbolicNameMapI. NameMap = "{" *s [ Commalist(NameBinding) *s ] "}". NameBinding = Name "=" ClassGlobSpec. GlobSpec : OneGlob | GlobSet. OneGlob = Glob. GlobSet = "{" *s [ Commalist(Glob) *s ] "}". Glob : ClassGlob | EdgeGlob. EdgeGlob : PartGlob | SubclassGlob | SuperclassGlob. ClassGlob = ClassNameGlob. PartGlob = "->" *s SourceGlob "," PartNameGlob "," TargetGlob. SubclassGlob = "=>" *s SourceGlob "," TargetGlob. SuperclassGlob = ":>" *s SourceGlob "," TargetGlob. SourceGlob = ClassNameGlob. TargetGlob = ClassNameGlob. ClassNameGlob : ClassNameExact | AnyClass. ClassNameExact = ClassName. AnyClass = "*". PartNameGlob : PartNameExact | AnyPart. PartNameExact = PartName. AnyPart = "*". ClassGlobSpec : OneClassGlob | ClassGlobSet. OneClassGlob = ClassGlob. ClassGlobSet = "{" *s Commalist(ClassGlob) *s "}". ClassName = Name. PartName = Ident. Name ~ Ident { "." Ident }. // Parameterized class definitions. List(S) ~ {*s S}. SList(S) ~ S { *l S } . Commalist(S) ~ S {"," *s S}. //--begin new part NodeSetSpec = PList(Node) . Node = NodeName "=" NodeDef ";" . NodeDef: SetNode | FuncNode . SetNode = "{" SetNodeDef "}" . SetNodeDef = ClassesNode . ClassesNode = CommaList(ClassName) . FuncNode = "(" FuncNodeDef ")" . FuncNodeDef: RegexNode | Nodes | OrNode | AndNode | NotNode . RegexNode = "regexp" Regex . Nodes = "nodes" StrategyName . OrNode = "||" NodeRef NPList(NodeRef) . AndNode = "&&" NodeRef NPList(NodeRef) . NotNode = "!" NodeRef . NodeRef: NodeName | NodeDef . NodeName = Ident . Regex: Term | Star | Question | EmptyRegex . Term = Ident Regex . Star = "*" Regex . Question = "?" Regex . EmptyRegex = . CommaList(S) ~ S {"," S}. RList(S) ~ S {S}. NPList(S) ~ S {S}. PList(S) ~ {S}. //--end new part noparse interface SymbolicNameMapI = extends NameMapI. visitors GlobVisitor : .