rkrzewski / bindex

OSGi Bundle Repository Indexer
Apache License 2.0
1 stars 1 forks source link

replace naive regex based filter parsers in RFC112IndexWriter with a more robust solution #7

Open rkrzewski opened 11 years ago

rkrzewski commented 11 years ago

I've encountered an unwelcome complication with implementation of osgi.ee and osgi.wiring.host requirements. I had to parse and filter directives and rewrite them into other forms. You can see the unwieldy and brittle solution here

It would be much better if the analyzers stored the filters in an object form, and writers converted them to just before writing them out. Unfortunately filters are directives and Capability/Requirement store directives as Map<String,String>, so I don't see a way of fixing it from this end without introducing additional internal API beyond org.osgi.resource

An alternative would be writing a proper parser for filters with AST and Visitor pattern. The grammar is very simple so this should be easy.

rkrzewski commented 11 years ago

I have built a lexical analyzer using JFlex and right now it's able to distinguish well formed and malformed filter expressions. Now I need to augment it with AST building.

Filter parsing is needed in osg.osgi.service.respository implementations. Maybe it would good idea to expose it in Bindex API somehow? OTOH I don't want to make it a kitchen sink...