Try fast search NHibernate

12 December 2008

Artorius

A week ago I started a new project in uNhAddIns; the code-name is Artorius.

The base target of Artorius is the HQL-AST (perhaps is better to think about it as nHQL-AST).

The picture

ArtoriusStruct

The Story

The port of the string-AST-parser is an old task in NHibernate (perhaps one of my first occupation). Hibernate are using an old version of ANTLR Parser Generator and more than one year ago Ayende and I had tried the port of that code, in two different ways, but without a usable result. After that work I found GOLD and Diego Jancic (aka “The economist”) had begin a work to implement an string-AST-parser based on GOLD; unfortunately the work on OSS is hard to maintain and perhaps the state of NHibernate code-base, at that moment, was not ready to receive the new parser.

In uNhAddIns , after a request of my friend and after implement DetachedQuery, in a weekend born something like a game, named: DetachedDynQuery

The first time I think about Artorius was as an evolution of DetachedDynQuery; a real AST representation of an HQL query. I must admit that was a loooong thinking, without touch my keyboard, for various reason (the first is that now we have LINQ).

The Situation

To have a better idea about what nHQL-AST must support, I have begun the work from the string-AST-parser based on GOLD. The actual parser are passing the test available here (basically to test the grammar).

Browsing the code you can see that there are some other incomplete work but before start the real implementation of the nHQL-AST I prefer to complete the grammar. If you want navigate the BNF, of the actual grammar, you can download the HQL.htm file from here.

10 comments:

  1. Great work.
    What tool did you use for that amazing diagram?

    ReplyDelete
  2. Hello.
    First test in GrammarFixture throws:

    TestCase 'NUnit v2.5.0.8332/Artorius.Tests/GrammarFixture' failed:
    System.ArgumentException : Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
    at System.IO.BinaryReader.Read(Byte[] buffer, Int32 index, Int32 count)
    D:\temp\unhaddins\Artorius\GoldParsing.Engine\Config\CompiledGrammarReader.cs(97,0): at GoldParsing.Engine.Config.CompiledGrammarReader.ReadString()
    D:\temp\unhaddins\Artorius\GoldParsing.Engine\Config\CompiledGrammarReader.cs(86,0): at GoldParsing.Engine.Config.CompiledGrammarReader.HasValidHeader()
    D:\temp\unhaddins\Artorius\GoldParsing.Engine\Config\CompiledGrammarReader.cs(33,0): at GoldParsing.Engine.Config.CompiledGrammarReader..ctor(String filePath)
    D:\temp\unhaddins\Artorius\GoldParsing.Engine\Config\CompiledGrammarLoader.cs(23,0): at GoldParsing.Engine.Config.CompiledGrammarLoader.Load()
    D:\temp\unhaddins\Artorius\Artorius.Tests\Parsing\GrammarFixture.cs(19,0): at Artorius.Tests.Parsing.GrammarFixture..ctor()

    and grammar definition file has "grm" extension instead of "cgt" which is expecting in test's set up method.

    ReplyDelete
  3. Hi Nikita.
    Take a look to Artorius\Grammar\readme.txt

    ReplyDelete
  4. Ooh, sorry, I get it. Can I use builder from "unhaddins\Artorius\Tools" to compile grammar?

    ReplyDelete
  5. No problem.
    Yes you can use it but if you want play with the existing code and understand some part is better to download the "Gold parser builder" from here
    http://www.devincook.com/GOLDParser/builder/index.htm

    ReplyDelete
  6. I read the developerNotes.txt:

    "(This feature give us the opportunity to create an HQL-AST from multiple source including criteria-API or
    any other OO query system ( ;) )"

    ...and now I can see a big difference with what I made. Really good work!

    ReplyDelete