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.

4. AN IMPLEMENTATION 4.4. Data Structures<br />

Listing 4.4: ExternalParser data structure<br />

interface ExternalParser {<br />

ExternalParserInterface getParseMethod();<br />

}<br />

interface Grammar {<br />

int getSerialNumber();<br />

String getGrammarID();<br />

byte[] getGrammarDefinition();<br />

}<br />

ExternalParser<br />

Listing 4.5: Grammar data structure<br />

ExternalParser objects are used to represent parsers built outsi<strong>de</strong> the tool. Since these<br />

parsers might not be built with the parser generator used by the tool, there is no knowledge of<br />

the content they produce when parsing a file. Therefore, an ExternalParser has an attribute<br />

of the ExternalParserInterface type, which contains the invocable method <strong>de</strong>clared in<br />

Listing 3.8 to parse a file and return the file in generic XML.<br />

4.4.2 Grammar<br />

Grammar objects (Listing 4.5) stand for tentative grammars. They are created in the User<br />

Interface and stored the Tentative Grammar Repository when a new grammar is built.<br />

A Grammar contains a serial number, which is used by the Tentative Grammar<br />

Repository to have a means of i<strong>de</strong>ntifying each grammar, since the name of all the tenta-<br />

tive grammars for a parser tends to be equal because it represents the name of the parser being<br />

built. In this impl<strong>em</strong>entation, the getGrammarID returns the grammar name in a String.<br />

The grammar name is used to name the Grammar, but also to name the parser which it was<br />

used to generate, as already mentioned. Finally, a Grammar also contains an attribute for the<br />

grammar <strong>de</strong>claration, accessible through the getGrammarDefinition method.<br />

4.4.3 ParsingData<br />

ParsingData objects (Listing 4.6) contain pieces of a configuration file, in generic syntax, and<br />

information regarding the parsing of that file with a parser and are returned by the<br />

Configuration File Parser.<br />

Although the ParsingData objects do not contain any reference to the corresponding<br />

parser, they always refer to the parsing result of a parser. This relation is explicit when the<br />

Configuration File Parser returns objects of this kind. When a single parser is tested,<br />

the return is a ParsingData object, obviously referring to the parse with the tested parser.<br />

41

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

Saved successfully!

Ooh no, something went wrong!