Quantcast

Parsing a object tree

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Parsing a object tree

Maurice
Dear community,

i am looking for a framework that supports me in validating complex object trees.
The way i imagine to do this with parboiled goes as follows:

Every object in the tree has a toValidation(), equal with toString().
This returns a string representation of the Tree with known keywords and is offered to parboiled as the syntax.
Within the Parser i will use the actions for declaring and testing of the symantics.
The syntactical parsing works well already, meaning the structure of the tree is being validated.
I am having some difficulties with the symantical part where there are sequences of nodes to be validated.
Does anybody already use parboiled with this kind of  "reverse parsing"? Or are there better solutions?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parsing a object tree

macdonald.rich
Can you modify the tree objects and inspect all their properties? If so, I'd add a Visitor pattern for this. Have multiple Visitor objects that traverse the tree and validate the rules. Easier to validate objects than strings.

On Fri, Sep 26, 2014 at 12:32 PM, Maurice [via parboiled users] <[hidden email]> wrote:
Dear community,

i am looking for a framework that supports me in validating complex object trees.
The way i imagine to do this with parboiled goes as follows:

Every object in the tree has a toValidation(), equal with toString().
This returns a string representation of the Tree with known keywords and is offered to parboiled as the syntax.
Within the Parser i will use the actions for declaring and testing of the symantics.
The syntactical parsing works well already, meaning the structure of the tree is being validated.
I am having some difficulties with the symantical part where there are sequences of nodes to be validated.
Does anybody already use parboiled with this kind of  "reverse parsing"? Or are there better solutions?


If you reply to this email, your message will be added to the discussion below:
http://users.parboiled.org/Parsing-a-object-tree-tp4024345.html
To start a new topic under parboiled users, email [hidden email]
To unsubscribe from parboiled users, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parsing a object tree

Maurice
I have full control of the tree objects, except for the sequence in which they occur. This depends on external input. Access to these objects is not the problem, validating the object sequence in combination with internal state is. I am looking for a easier and less brittle way of defining such rules without having to write something like complex loops.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parsing a object tree

mathias
Administrator
I’d agree with Rich in that serialising the tree into a string only to then feed this string into a parser afterwards appears to be somewhat clunky as well as inefficient.
If you already have the tree objects in memory I would advise as well to use some kind of tree traversal/inspection/transformation technique, rather than a text-based parser.

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 29.9.2014, at 10:17, Maurice [via parboiled users] <[hidden email]> wrote:

> I have full control of the tree objects, except for the sequence in which they occur. This depends on external input. Access to these objects is not the problem, validating the object sequence in combination with internal state is. I am looking for a easier and less brittle way of defining such rules without having to write something like complex loops.
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/Parsing-a-object-tree-tp4024345p4024347.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parsing a object tree

Maurice
Maybe i should refurbisch parboiled to except objects instead of strings.
I like the way of how Rules get defined, and the elegant way i can add actions for further descission making.
Moving something like Drools or even jBPM seems to me like shooting with cannons on a small bird.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parsing a object tree

Maurice
So i decided to take on Drools. It was a bitch installing it on Karaf, but playing the rules has shown me this is the best way to handle this kind of 'expert' problem. Thx for the advice.
Loading...