Download inCode.Rules Language - LOOSE Research Group
Transcript
5.3. RULE EVALUATION 51 AbstractContentProposalProvider AbstractJavaBasedContentProposalProvider AbstractTerminalsProposalProvider TerminalsProposalProvider AbstractDSLProposalProvider DSLProposalProvider Figure 5.5: Proposal Hierachy 5.3 Rule Evaluation Once the abstract syntax tree has been created, we can now start evaluating rules. Why do we need the abstract syntax trees to evaluate the rules ? We could try to evaluate them just by ”reading” the rules as strings considering the fact that the grammar itself is not that complicated. We can not however implement this using only the rules written as strings. First, because the grammar is recursive, even though it is simple, the user can create some pretty complicated rules, this would make interpreting the rules directly as Strings extremely difficult if not impossible. Second because the use of abstract syntax trees and the Visitor Pattern makes it a lot easier to write extendable code. The rules are interpreted by a group of visitors that delegate the visiting operation from one to another in order to visit different sections of the tree. In order to interpret the rules it is not enough to just visit the abstract syntax trees, as the Visitor Pattern’s [GHJV94] intended goal suggests: ”represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates”, we will perform operations using the nodes of the abstract syntax trees. However, these operations, cannot be explained without an introduction to the mechanisms behind the inCode plugin. We will first go through mechanisms and then proceed to explain the visiting process. 5.3.1 inCode metamodel inCode is the plugin the inCode.Rules language relies on most. In this subsection it is explained what parts of the inCode plugin inCode.Rules uses. We start with the description of the meta-model used by inCode to model the java elements and the relations among them.