Table of Contents
Stand-Alone
Because the only requirement to start a production statement is that the caller is able to create a Producer (which can be any type of Object in the java sense), any object can start a production. Within rules, after the query the query graph is responsible for creating the producer. In the case of RGG, it creates a RGGProducer.
Within normal statement blocks (in a java block), any Object can serve to create the “Producer”, there are not interface or class to extend. It only need to implements the required methods, which are retrieved at compile time.
As described in the production presentation, the only required methods are:
producer$begin: first method called when the production starts.producer$end: last method called when a production statement ends.
Any additional: operators, producer method (sub-tree, separate, …), custom methods, can be implemented to be used. By default, none is implemented. Thus, if the production statement contains anything, it will fail at compile time.
Example
Here is a minimal example, where the class AnyClass can starts a production using itself as producer. The operator space is also implemented.
class AnyClass { public AnyClass producer$begin() { // do smthg return this; } public AnyClass producer$end() { // do smthg return this; } public AnyClass operator$space(Node node) { // do smthg return this; } public AnyClass custoMethod(Node node) { // do smthg return this; } } public void java_method(){ AnyClass t = new AnyClass(); t ==> Node Node -custoMethod-> Node ; }
