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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Listing 3.1: User Interface proposed interface<br />

interface UI {<br />

void processFiles(String[] fileNames);<br />

void submitGrammar();<br />

byte[] getTentativeGrammar();<br />

void approveParser();<br />

boolean importParser();<br />

void haltSession();<br />

void recoverSession();<br />

}<br />

<strong>de</strong>scribed. The interfaces that every component should impl<strong>em</strong>ent are also presented, in a<br />

Java-like syntax. Enforcing every component to impl<strong>em</strong>ent an interface not only allows any<br />

component to be completely r<strong>em</strong>a<strong>de</strong> without having any effect on other components, it also<br />

aids the integration process of SmART with other tools.<br />

User Interface<br />

The User Interface (UI, Listing 3.1) is the tool’s front-end, through which the user interacts with<br />

the tool. It is invoked by the user and receives an array of configuration file locations at boot<br />

time, although it only processes one at a time.<br />

For each file, UI summons the Configuration File Parser to make an att<strong>em</strong>pt at<br />

parsing a configuration file with the parsers in the Parser Repository. Two outcomes are<br />

possible: either a parser manages to recognize the totality of a file or none does.<br />

The first case is the i<strong>de</strong>al case, where at least one of the parsers in the Parser Repository<br />

manages to fully recognize the configuration file. In this situation, UI displays the representa-<br />

tion of the generic syntax, as returned by the Configuration File Parser, to let the user<br />

validate the generated structure. At this point, the configuration file in generic syntax is stored<br />

in m<strong>em</strong>ory, so UI must save it to a file to let file modification take place.<br />

The second case, where the configuration file was not completely parsed by any available<br />

parser, requires user intervention. If the file could not be totally recognized by any parser,<br />

another parser which recognizes this new language must be generated. For this en<strong>de</strong>avour,<br />

UI provi<strong>de</strong>s the user with a friendly interface which allows him to <strong>de</strong>fine a new grammar<br />

that recognizes the configuration file language. The user must also be allowed to build a new<br />

grammar from an existing one. This is useful in the case where a parser managed to parse a<br />

configuration file almost entirely. In this case, the new parser might be ready just by tuning an<br />

existing one, instead of having to build it from scratch.<br />

As soon as a grammar is <strong>de</strong>fined, the user triggers its compilation with the Grammar<br />

Compiler’s submitGrammar call. Any grammar compilation errors should be displayed to<br />

the user. To ease parser generation, the user must have access to the previously tested gram-<br />

mars. This allows for the rollback of changes in grammars in an easy way. To accomplish<br />

this, every time the user submits a new grammar, UI sends it to the Tentative Grammar<br />

27

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

Saved successfully!

Ooh no, something went wrong!