Analyze lists using bash scrip

Completado Publicado Feb 18, 2013 Pagado a la entrega
Completado Pagado a la entrega

I Need a bash script that does the following:

step 1: parse

You are given 2 lists of strings.

In the first list each entry has the following format:

@protocol protocolName

we will define a hashmap

var protocolToSuperProtocols = new hashmap<string, set>

protocolToSuperProtocols should contain all protocolNames as keys, and a list of implementedProtocol as the values.

* Ignore any trailing spaces

* if an implementedProtocol appears more than once, add it only one

Example:

@protocol p1

@protocol p2

@protocol p4

will output:

protocolToSuperProtocols='([p1]="p2,p3" , [p2]="", [p4]="p5" )'

The second list contains the following entries:

@interface className : superClass

the entries must have className but superClass and implementedProtocol list are optional.

lets define two hashMaps:

var classToSuperClass = new hashmap

var classToProtocols = new hashmap<string, set>

classToSuperClass will contain className as key and superClass as value

* if a class does not have a superclass, ignore the entry

* a class will have only one superclass

* ignore spaces

classToProtocols will contain className as key and the list of implementedProtocol as value

* if a class has implementedProtocol it will always have a super class

* if a class does not have implementedProtocol list, leave blank

* if a value repeats itself in implementedProtocol list, add it only once

* ignore spaces

example:

@interface A : B

@interface B : C

@interface D

@interface C : D

will output:

classToSuperClass ='([A]="B" , [B]="C", [C]="D", [D]="" )'

classToProtocols ='([A]="" , [B]="p1,p2,p3", [C]="p1,p4", [D]="" )'

step 2: processing

we will define our result datastructure:

var protocolToImps = new hashmap<string, set >

do the following:

for (classToSuperClass as (className => superClass)) {

travereOverClassHierarchAndAct(className);

}

echo protocolToImps;

function travereOverClassHierarchAndAct(className) {

if (className == null) return;

implementingProtocols = classToProtocols[className];

addBindToResultList(className, implementingProtocols);

superClass = classToSuperClass[className];

travereOverClassHierarchAndAct(superClass)

}

function addBindToResultList(classname, protocolList) {

if (protocolList == null) return;

for (implementingProtocols as protocol) {

protocolToImps[protocol] += className;

addBindToResult(className, protocolToSuperProtocols[protocol] );

}

}

the following should output (for the above dataset):

protocolToImps ='([p1]="A,B,C",[p2]="A,B,C",[p3]="A,B,C",[p4]="A,B,C",[p5]="A,B,C")'

*Please not that == null means empty list or undefined key

*There should be not circular dependencies in the data set

*Please use bash 4 with associative arrays and test for bash script version in the beginning of the script

SO Mac Shell Script

Nº del proyecto: #4256753

Sobre el proyecto

5 propuestas Proyecto remoto Activo Feb 27, 2013

Adjudicado a:

kaloyan13

Bash programmer.

$40 USD en 2 días
(6 comentarios)
2.7

5 freelancers están ofertando un promedio de $50 por este trabajo

linuxfreak1985

Hi there, i am very interested to complete this project. please see my past reviews lets complete this project

$50 USD en 3 días
(10 comentarios)
3.9
srinichal

Ready to discuss further

$80 USD en 3 días
(3 comentarios)
3.6
necloli

Hi! Please, read a private message! Thanks!

$30 USD en 0 días
(2 comentarios)
1.0
mantzoun

I've been using bash scripts in my work extensively for the past 6 years, so this project shouldn't be any problem. However I will need additional clarifications, because it is not clear to me in the examples you pr Más

$50 USD en 3 días
(0 comentarios)
0.0