18.04.2013 Views

Dissertaç ˜ao de Mestrado Mestrado em Engenharia Informática Jo ...

Dissertaç ˜ao de Mestrado Mestrado em Engenharia Informática Jo ...

Dissertaç ˜ao de Mestrado Mestrado em Engenharia Informática Jo ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. AN APPLICATION RECONFIGURATION FRAMEWORK 3.3. Original to Generic syntax Converter<br />

Listing 3.4: Grammar Compiler proposed interface<br />

interface GC {<br />

CompilationData doCompile(byte[] grammar);<br />

}<br />

Listing 3.5: Parser Repository proposed interface<br />

interface PR {<br />

Parser storeParser(ParserID parserID, ParserInt parser, byte[]<br />

grammar);<br />

Parser importParser(ParserID parserID, ParserInt parser);<br />

Iterator getIterator();<br />

void <strong>de</strong>leteParser(String parserID);<br />

void saveState();<br />

}<br />

grammars. For this, CG may make use of an outsi<strong>de</strong> parser generator, such as Bison [FSF08],<br />

SableCC [GH98], JavaCC [Pro09], etc., by invoking it whenever a grammar is received. Also,<br />

when a grammar is not valid, CG must return an error message containing information about<br />

the probl<strong>em</strong>.<br />

Parser Repository<br />

The Parser Repository (PR, Listing 3.5) is a parser database which manages the parsers used<br />

by the tool to that date. It maintains a map of ParserID, which is the parser name and must<br />

uniquely i<strong>de</strong>ntify it, and Parser, used to call a given parser. PR provi<strong>de</strong>s a number of func-<br />

tionalities to the user. These functionalities are now enumerated.<br />

The parsers generated by the Grammar Compiler may be stored by the PR if the user has<br />

approved th<strong>em</strong>. The storeParser method saves a parser in the database, given its name,<br />

which uniquely i<strong>de</strong>ntifies it, the parser and its grammar <strong>de</strong>finition.<br />

If a user possesses an already built parser for a new configuration file, it is possible to im-<br />

port that parser into the tool. The importParser method saves an external parser in the<br />

database. The importation of external parsers is, nevertheless, conditioned by a pre-<strong>de</strong>fined in-<br />

terface which forces external parsers to impl<strong>em</strong>ent an invocable method. This matter is further<br />

discussed in Section 3.6.<br />

Besi<strong>de</strong>s inserting parsers into the database, it is also possible to obtain an iterator for the<br />

existing parsers in the parser repository through the getIterator method, to <strong>de</strong>lete a parser<br />

from the database with the <strong>de</strong>leteParser method and to save the state of the database by<br />

calling the saveState method.<br />

30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!