Just for fun, I tried to implement your "grammar" within PEG.js
Go there http://pegjs.majda.cz/online and paste the following grammar on the grammar part (1).
start
= fruits
fruits
= ft:fruit "@" fts:fruits {fts[ft[0]] = ft[1]; return fts;}
/ ft:fruit {var fruits = {}; fruits[ft[0]] = ft[1]; return fruits;}
fruit
= name:word "-" flavs:flavors {var ft = []; ft.push(name); ft.push(flavs); return ft;}
/ name:word {var ft = []; ft.push(name); ft.push([]); return ft;}
flavors
= flavor:word "#" flavs:flavors {flavs.unshift(flavor); return flavs;}
/ flavor:word { var tab = []; tab.push(flavor); return tab;}
word
= value:[a-zA-Z/]+ {return value.join("");}
Then put the sentence in the input section (2)
Apple-sweet#tangy@Bannana@Orange-citrusy@Pear-crispy#green/yellow
And here comes the result :
{
"Pear": [
"crispy",
"green/yellow"
],
"Orange": [
"citrusy"
],
"Bannana": [],
"Apple": [
"sweet",
"tangy"
]
}
Then embed the resulting javascript parser into a file you won't have to bother about the lexical/syntaxic analysis job. Better maintenability to come only working at semantic level IMHO :)
Quite powerful API, although in this particular case it is a bit overkill ;)