That's how it works at the moment, all the tree nodes are of type CommonTree from the ANTLR runtimes. I see two options here:

Leave the ANTLR parsing as-is (which means we can use the hql-sql.g tree-rewriting code, once ported from ANTLR2)
Override the CommonTreeAdapter in the parser to create nodes of our own

Option 2 is appealing *if* it still permits the use of hql-sql.g - there's a lot of logic in there, and being able to just port it is going to safe a load of time. If creating our own nodes removes that option, then I'd suggest just sticking with the ANTLR types.

When we get to the LINQ expression tree conversion, we clearly don't want to tie that code to the ANTLR implementation, so I'd look to put some form of factory between the LINQ code and the ANTLR trees, so that the LINQ code doesn't know what type is being constructed.

Once I'm happy that the port of hql.g is working (I've got a couple of areas in it that still need some work), then this is the area that I need to look at next.


On 3 Feb 2009, at 17:35, Fabio Maulo wrote:

Ok.
Now...
The HQL-AST you are creating inherit each class from an ANTLR class as H3 ?

(if you want add in in GTalk)

2009/2/3 Steve Strong <[email protected]>
Correct - I've ported the hql.g grammer from ANTLR2, which is what H3 are using over to ANTLR3. Although it's now obviously different (the tree-rewriting syntax in particular has completely changed), the overall grammar is identical. It should make it easier to pick up the second phase, which is where all the hard work is done.

On 3 Feb 2009, at 17:24, Fabio Maulo wrote:

So you have changed the grammar+lexer from H3 because H3 are using an old version of ANTLR, right ?

Do you want host the prj in uNhAddIns ?

2009/2/3 Steve Strong <[email protected]>
ANTLR 3.1

On 3 Feb 2009, at 17:13, Fabio Maulo wrote:

Which ANTLR version are you using ?

2009/2/3 Steve <[email protected]>

Hi All,

Thought you might appreciate a quick update on what I've been up to.
The last couple of weeks have been a pretty steep learning curve, and
although I'm sure there's a long way to go, I think I've also made
some progress.

As discussed a week or two back, I am going down the path of initially getting a robust AST implementation of the HQL parser. Once complete, the LINQ integration should be somewhat easier and cleaner, since it's just(!) a mapping from LINQ expressions to HQL ASTs. I've had a good
look at both the Artorius code and the original Hibernate
implementation, and before heading off down the Artorius route I
decided to have a go at porting the ANTLR code over from Hibernate to
C#.  If successful, this should mean that this area of NHibernate
would be closely in sync with Hibernate 3.1, and hence it should be
easier for us to pick up bug fixes, enhancements etc.

Hibernate has a two phase approach - the first is to parse to HQL
strings into an AST and the second is to do a transform of the HQL- AST
into a SQL-AST.  Right now, I'm just working on the first bit, and
although I've still got a bunch to do, it has started to come to
life.  For the simple query of "from Animal", I've now got the same
AST being created in C# as in Java :)

I'll keep you posted with further progress, and also let you know
where you can take a look at the code once I get it hosted somewhere.

Cheers,

Steve





--
Fabio Maulo




--
Fabio Maulo




--
Fabio Maulo

Reply via email to