Bringing an end to the posts on decompositions of numeric ranges into validating regular expressions.

I've posted quite a few items covering the process of decomposition.  Most of the examinations are textual only and cover the process of generating decompositions by hand.  I've since issued a challenge for the creation of an algorithm that would automatically handle a given range and return the decomposition in regular expression format that could be used to validate input in the range.  I talked through a sample algorithm that had some issued, then covered these issues, and finally posted my own algorithm in C# that creates a matching alternation group that isn't minimally sized, but works for the give range.  Have a look.

The Beginning: Value range parsing using Regular Expressions. Breaking down the dotted decimal IP byte processing.
Follow-up on ranges: 0 through N ranges are interesting, but what about M through N ranges.
Some Oddities that are hard to handle: That range algorithm was more difficult than I originally pointed out due to some strange oddities.
The post reference the article and algorithm: An Algorithm has been prepared, I'm linking it into an article so you don't have to look at it if you don't want. It is a spoiler.

Published Tuesday, May 25, 2004 12:50 AM by Justin Rogers

Comments

Tuesday, June 01, 2004 6:41 PM by William Stacey

# re: Bringing an end to the posts on decompositions of numeric ranges into validating regular expressions.

Just curious if you checked out any of these lexers and what your thought about them?

Grammatica
http://www.nongnu.org/grammatica/index.html
ANTLR
http://www.antlr.org/grammar/list
csLex
http://www.cybercom.net/~zbrad/DotNet/Lex/Lex.htm
Tuesday, June 01, 2004 7:04 PM by Justin Rogers

# re: Bringing an end to the posts on decompositions of numeric ranges into validating regular expressions.

I've looked at pretty much all of the lexical analyzers out there. I really only have one problem with them in general, and that is the initial complexity involved. They assume that you can easily define your grammar in some abstract format, and most people, until they've actually written their own lexical analzyer won't fully understand that abstract format or how to find issues with it.

I guess I'd say that creating your own lexer/parser is an exercise that gives you access to knowledge you'll need later when you implement whatever your lexer/parser was creating. In your case you were trying to read bind-logs. The lexical analysis file for bind logs is actually fairly complex with lots of optionals and this/thats, but just looking at the stream of values it appears fairly simple. It really is, but you have to go through the exercise of processing that data before you gain an understanding of it.
Thursday, June 03, 2004 10:52 PM by William Stacey

# re: Bringing an end to the posts on decompositions of numeric ranges into validating regular expressions.

I agree fully. I looked at them, but did not want to speed the hours needed to figure them out. I probably will at some point, but was looking for something I could quickly wrap my arms around and go. Guess that is not possible and just need to roll the sleeves up or use xml for now. Cheers!

Leave a Comment

(required) 
(required) 
(optional)
(required)