Am I in the right place?

50 views
Skip to first unread message

Simon Boddy

unread,
Mar 29, 2017, 8:22:04 AM3/29/17
to Eto.Parse
Hello groovers !

My winding path has led me to a place where I want to tokenize a SQL declare statement. I've just stumbled on the notion of recursive descent parsers. Am I in the right place?

my string can have n DECLARE statements, starting with DECLARE,  ending with a semi-colon
a DECLARE statement can have n declarations, separated by commas
a declaration contains a name, a datatype, that might itself have commas inside brackets (this is where my regex imagination runs out)
a declaration might be of type TABLE, in which case it will contain a comma separated list of names and datatypes (which might contain brackets and commas)

For example...

declare @id int;
declare @name string, @telephone string, @salary decimal(4,4);
declare @children table(id int identity(1,1), name string, salary decimal(4,4));

I need to do all this in a C# application. Is Eto the tool for the job? Do I write my own grammar? What are the key notions to get started?

Thanks
Simon Boddy

Curtis Wensley

unread,
Apr 7, 2017, 12:53:53 PM4/7/17
to Eto.Parse
Hi Simon,

Yes, you're in the right place!  Eto.Parse would work perfectly for something like that.

You can either write your grammar in C# or ebnf (there are other options but these are the most robust).

There's not too much documentation on Eto.Parse yet, but you can use the Samples and even the Grammars for more complex scenarios.

Hope this helps!
Curtis.
Reply all
Reply to author
Forward
0 new messages