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.

2. STATE OF THE ART AND RELATED WORK 2.4. Representation of Configuration Files in a Generic Syntax<br />

2.3.2 JavaCC<br />

The Java Compiler Compiler (JavaCC) [Pro09] is a tool that reads a grammar specification and<br />

converts it to a Java program that can recognize matches to the grammar. In addition to the<br />

parser generator itself, JavaCC provi<strong>de</strong>s other standard capabilities related to parser generation<br />

such as tree building, actions, <strong>de</strong>bugging, etc.<br />

JavaCC generates top-down parsers (i.e., start at the root of the <strong>de</strong>rivation tree, picks a pro-<br />

duction and tries to match the input tokens [oM]), <strong>de</strong>clares the lexical and grammar specifica-<br />

tions in one file, making grammars easier to read and maintain, supports s<strong>em</strong>antic lookahead,<br />

uses the Exten<strong>de</strong>d Backus-Naur Form (i.e., operators *, + and ?) and supports error recovery in<br />

two forms: shallow recovery and <strong>de</strong>ep recovery. In shallow recovery, if an input token does not<br />

match any production, it is possible to move to the next <strong>de</strong>sired token (e.g., s<strong>em</strong>icolon). Deep<br />

recovery is similar to the shallow recovery, but also allows to recover from an error insi<strong>de</strong> a<br />

production, which is impossible resorting to shallow recovery alone.<br />

2.4 Representation of Configuration Files in a Generic Syntax<br />

The concept of generic syntax refers to a language-in<strong>de</strong>pen<strong>de</strong>nt syntax used in the process of<br />

automatic application configuration. The generic syntax is used to abstract the configuration<br />

files from their original languages. When a configuration file is represented in a generic syntax,<br />

another in<strong>de</strong>pen<strong>de</strong>nt entity which recognizes that syntax is able to manipulate the file without<br />

having knowledge of what the original syntax was, or what application uses that file. The cho-<br />

sen generic syntax must provi<strong>de</strong> a practical way to traverse and manipulate files. Furthermore,<br />

it must be wi<strong>de</strong>ly supported and well documented. Its software license must also allow it to be<br />

used freely.<br />

Consi<strong>de</strong>ring the prievous requir<strong>em</strong>ents, the chosen syntax was the eXtensible Markup Lan-<br />

guage (XML) since it is a broadly adopted and supported standard. XML allows for the struc-<br />

turing of configuration files in a way that makes th<strong>em</strong> easily manipulable and traversable.<br />

Some available impl<strong>em</strong>entations of XML parsers were i<strong>de</strong>ntified in many programming<br />

languages. The criteria to choose from an XML parser impl<strong>em</strong>entation inclu<strong>de</strong>s factors such as<br />

the programming languages it is available on and what it allows the user to do resulting data<br />

structure from the parse.<br />

Since the programming language used to <strong>de</strong>velop the tool is going to be Java, two major<br />

XML parser impl<strong>em</strong>entations in Java were consi<strong>de</strong>red: the Simple API for XML (SAX) and the<br />

Domain Object Mo<strong>de</strong>l (DOM). Following is a brief <strong>de</strong>scription of both.<br />

Simple API for XML<br />

The Simple API for XML (SAX) is an Application Programming Interface (API) for XML in Java,<br />

although it is available in many other programming languages. It is event-driven: it reads from<br />

a stream and reacts when processing instructions, el<strong>em</strong>ents, comments and text.<br />

18

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

Saved successfully!

Ooh no, something went wrong!