No parsing technique can by itself resolve ambiguous grammars.  Some sort of 
locale or preference setting is required.

That said, the pattern rule hash table initialization code should throw an 
exception if it detects an over loaded pattern.




On Sep 6, 2013, at 2:54 AM, Kjell Rilbe <kjell.ri...@datadia.se> wrote:

> Den 2013-09-06 00:29 skrev Jim Starkey såhär:
>> A couple of folks asked, so here it is.
>> 
>> The scheme centers around pattern strings.  A pattern string represents
>> one of any number of possible interpretations of a target string.  A
>> pattern string consists of punctuation characters and the characters A
>> and 9 representing consecutive sequences of alphabetical characters or
>> digits.  At initialization time, a hash table is generated containing
>> all possible legitimate target string patterns and respectiive rule codes.
>> 
>> At decode time, a target string is scanned constructing a) its pattern
>> string and b) a vector of <address, length> of all alphabetic or numeric
>> sequences found.  Since the max length of a legitimate pattern and the
>> maximum number of possible sequences, these can be statically allocated.
>> 
>> Some sample string and corresponding patterns:
>> 
>>          9/5/2013                    9/9/9    with segments 9 5 2013
>>          5.9.13                           9.9.9    with segments 5 9 13
>>          September 5, 2013    A9,9       with segments September 5 2013
>> 
>> After a target string is scanned the hash table is checked for a
>> matching pattern rule.  If found, resulting the rule is used as the
>> argument for a case statement to apply the rule to the vector of segments.
>> 
>> There is usually a little more work to be done.  For dates, for example,
>> it is necessary to validate day and month, look up alphabetic months,
>> and expand two digit years, etc.
> 
> Nice idea. What if there are multiple format strings that match the 
> decoded pattern? E.g. these formats will look alike:
> yy-mm-dd
> mm-dd-yy
> dd-mm-yy
> 
> All of these are in active use in various parts of the world. Throw an 
> error? Use some priority order? Based on... what?
> 
> Regards,
> Kjell
> 
> -- 
> --------------------------------------
> Kjell Rilbe
> DataDIA AB
> E-post: kj...@datadia.se
> Telefon: 08-761 06 55
> Mobil: 0733-44 24 64
> 
> 
> 
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
> Firebird-Devel mailing list, web interface at 
> https://lists.sourceforge.net/lists/listinfo/firebird-devel

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to