// ============================================================ // BusRoute.cd : Class dictionary for bus routes. // Written by Ali Ozmez for the COM3360 project. // Last update on Tue Nov 28 17:11:12 1995. // ============================================================ BusRoute = "BusRoute:" RouteName "total" "route" "length" ":" RouteLen "consisting" "of" "bus" "stops" ":" List(BusStop) "with" "assigned" "busses" ":" List(Bus). BusStop = StopId "at:" RouteLoc // clockwise dist. from origin "with" "waiting" "list" ":" List(Person). Bus = BusId "at:" RouteLoc // clockwise dist. from origin [ "currently" "at" "stop" ":" StopId] "capacity:" BusCapac "speed:" BusSpeed "carrying" "passenger(s)" ":" List(Person). Person = PersonId "destination:" StopId. // id of the dest. stop List(S) ~ "(" { S } ")". RouteName = String. RouteLen = Integer "ft". RouteLoc = Integer "ft". BusCapac = Integer "passengers". BusSpeed = Integer "ft/min". StopId = Ident. BusId = Ident. PersonId = Ident. --------------------------------------------------------------- Main { (@ static public void main(String args[]) throws Exception { BusRoute e = BusRoute.parse(System.in); } @) } BusRoute { traversal allBusRouteBuses() {to Bus;} } Bus { traversal allBusPersons() {to Person;} } --------------------------------------------------------------- // Here is a sample BusRoute object: BusRoute: "Ruggles / Harvard Square" total route length : 5000 ft consisting of bus stops : ( Stop0 at: 0 ft with waiting list : ( Person1 destination: Stop1 Person2 destination: Stop1 Person3 destination: Stop2 Person4 destination: Stop2 ) Stop1 at: 2000 ft with waiting list : ( Person10 destination: Stop0 Person11 destination: Stop0 Person12 destination: Stop0 Person13 destination: Stop2 ) Stop2 at: 3500 ft with waiting list : ( Person5 destination: Stop0 Person6 destination: Stop1 Person7 destination: Stop1 Person8 destination: Stop0 Person9 destination: Stop1 Person10 destination: Stop1 ) ) with assigned busses : ( Bus1 at: 0 ft currently at stop : Stop0 capacity: 5 passengers speed: 700 ft/min carrying passenger(s) : () )