This project has moved and is read-only. For the latest updates, please go here.

Newbe question regarding SearchGrammar

Feb 22, 2010 at 4:31 PM


I saw the article on SQL Server Central: A Google-like Full Text Search.

Of course I would like to use the newest version of irony available. So far so good, I use the SearchGrammar that can be found in the project 020.Irony.Samples.

Now the hardest part is transforming the searchquery into ParseTreeNode.

I use VB.Net because I have to but I don't think it wouldn't be any problem to understand it.

I saw some examples in the discussions and they all seem to use something that I cannot find in the library:  LanguageCompiler and also Compiler.

How can I transform the text in a textbox into a ParseTreeNode so I can use it in the function SearchGrammar.ConvertQuery?

Can anyone help me with a simple example?



A Google-like Full Text Search

Feb 22, 2010 at 5:11 PM

Look at SearchGrammar.RunSample method - it converts input string directly into SQL Query

Feb 22, 2010 at 5:27 PM

I can't get it to work.

I paste you the code that I have, I get System.ArgumentNullException: Value cannot be null. at System.String.IndexOfAny(Char[] anyOf, Int32 startIndex, Int32 count) at System.String.IndexOfAny(Char[] anyOf, Int32 startIndex) at Irony.Parsing.SourceStream.SetText(String text, Int32 offset, Boolean keepLineNumbering)

The problem occurs in the bold line.

        Private _grammar As Grammar
Private _parser As Irony.Parsing.Parser
Private _compilerContext As ParsingContext
Private _parseTree As ParseTree

Protected Sub QuickSearch()
_grammar = New Grammar()
_parser = New Parser(_grammar)
_compilerContext = New ParsingContext(_parser)
_parseTree = Nothing _parser.Context.SetOption(ParseOptions.TraceParser, True)

_parser.Parse(tbxSearch.Text.Trim().ToLower(), "<source>")

_parseTree = _parser.Context.CurrentParseTree

Exit Sub End Sub


Feb 22, 2010 at 5:43 PM

Well, the converter should be working in Grammar Explorer, step through with debugger and see what's different with your app. Are you passing a non-null string in txtSearch.Text?

Feb 22, 2010 at 6:34 PM

Yes, i am testing with the word 'test'


Feb 23, 2010 at 12:41 AM

Shouldn't it be

_grammar = new SearchGrammar();




Feb 23, 2010 at 9:31 AM

Yes, it should. For me it is

_grammar = New Com_FTSGrammar()

Because I changed the name after conversion to VB.NET.

Thanks a lot.