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 ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4. AN IMPLEMENTATION 4.4. Data Structures<br />
interface ParsingData {<br />
boolean wasParsed();<br />
int getParsingDone();<br />
List getParsedBlocks();<br />
void dump(String fileName);<br />
}<br />
Listing 4.6: ParsingData data structure<br />
ParsingData<br />
boolean<br />
parsed<br />
int<br />
parsePercentage<br />
List<br />
blocks<br />
Block<br />
int<br />
startPosition<br />
int<br />
endPosition<br />
XML block<br />
Figure 4.2: Graphical representation of ParsingData<br />
Whenever multiple parsers are tested, the return is a map of the tested parsers and their<br />
ParsingData.<br />
By having a ParsingData contain the parts of a file recognized by a parser, the case where<br />
a file is completely parsed is a special case of when a file is not totally parsed, consi<strong>de</strong>ring<br />
that in the first case, a ParsingData will only contain one part, which is the whole parsed file.<br />
However, a parser may return only one part of a file but not recognize it entirely. Therefore,<br />
additional control is required to check if a file was well parsed or not. The wasParsed method<br />
tells whether a file was entirely recognized, or not.<br />
In case a file was not completely parsed, its parsing statistics are logged. This is an indicator<br />
of how fit the parser was found to be with the given configuration file and can be measured in<br />
terms of percentage of parsed file.<br />
Additionally, the ParsingData objects also contain a list of Block objects. A Block object<br />
has no relation with the block pattern, but rather contains the generic syntax of a parsed file part<br />
as well as the positions of the first and last character that Block represents. The representation<br />
of a ParsingData object, and the contained Block object, is shown in Figure 4.2.<br />
Whenever the file is due to get modified in or<strong>de</strong>r to be configured, or the user halts the tool<br />
execution, the dump method is called in or<strong>de</strong>r to store the blocks in a given file in persistent<br />
storage.<br />
4.4.4 CompilationData<br />
CompilationData objects (Listing 4.7) are produced by the Grammar Compiler to send in-<br />
formation regarding the compilation of a grammar to the User Interface. A<br />
CompilationData object tells if a grammar was successfully compiled in the wasCompiled<br />
42