[antlr-interest] Custom object tree from tree parser?
Mari Matinlassi
mmatinlassi at icinetic.com
Mon Sep 26 05:55:40 PDT 2011
Jeremy,
Unfortunately - so far - no, not have got answer to this.
In reality, my problem is more challenging because I need relationships too
e.g. CustomerHasCars relationship where Customer object needs to have a list
of Cars inside. Further, Car can be defined before or after CustomerHasCars
relationship. So, building object tree with "actions embedded in rules"
approach does not seem to be powerful enough.
Besides, what to do with the AST created by parser if I would be
constructing another one next to it? Haloo (silly me)?!
It seems I need several (tree)parsers and custom tree adaptors (one for each
node type) and then yet another one to put everything together, right?
Anyone more experienced please confirm/reject?
While waiting, I have no choice but the good old trial-and-error method ;-)
Regards,
Mari
From: Jeremy Long [mailto:jeremy.long at gmail.com]
Sent: Sunday, September 25, 2011 3:32 PM
To: Mari Matinlassi
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Custom object tree from tree parser?
Mari,
Did you ever get an answer to this? I agree a pointer or example on this
would be extremely helpful. I will be doing something similar very soon for
a project where I will be generating different nodes/objects from the input.
Which is the better approach?
For my purposes I am planning on populating a Neo4J graph database and I've
been trying to figure out the best way to do this.
--Jeremy
On Fri, Sep 23, 2011 at 5:33 AM, Mari Matinlassi <mmatinlassi at icinetic.com>
wrote:
Hello,
I want to build custom object trees from text. As a simplified example,
parser input is
Car Seat;
Car Audi;
Customer John;
Parser output shall be an object tree where e.g. Car object is an
instantiation of a class below (Respectively, Customer class would be
something similar):
public class Car
{
private string brand;
public Car(string _brand)
{
this.brand = _brand;
}
public string Brand
{
get { return brand; }
}
}
What is the best way to do this? Custom AST node and custom TreeAdaptor?
Tree parser with actions embedded in rules? What about the problem that not
all the nodes are similar? Could you please give me some hint to the right
direction?
Kind regards,
Mari
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list