Template regexes, version 2

Craig Black cblack at ara.com
Wed Feb 22 11:19:02 PST 2006


"Ivan Senji" <ivan.senji_REMOVE_ at _THIS__gmail.com> wrote in message 
news:dtg4am$2si9$1 at digitaldaemon.com...
> Craig Black wrote:
>>>That looks scary :)
>>
>>
>> Probably you are joking
>
> I was joking (but it does look scary)
>
>> , but I feel the need to defend my code anyway.  To someone who doesn't 
>> know the syntax it is not going to be very readable. <g> However, my code 
>> is way more readable than a lot of the regular expressions
>
> I guess i'll believe you.
>
>> that I've seen.  If you don't believe me, google for regular expressions 
>> that can be used to parse C++.
>
> Well I would be surprised to find that because C++ grammar isn't regular, 
> it isn't even LR, it is something awfull.

No, the regular expression doesn't actually parse C++, but it helps to parse 
it.  A friend of mine was writing a C++ parser and he showed me a regular 
expression he found on the internet (I would show you, but I just looked but 
couldn't find it.)  It was hideously long because it has a lot of repetitous 
stuff.

When you add subroutines to the syntax, the repetition disappears.

>> One benefit of my language over regular expressions is that you can 
>> define subroutines.
>
> Interesting? What class of languages can it parse?

Theoretically it can parse anything.  It includes syntax for pushing and 
poping text on a stack and populating text values in a simple parse tree 
format.

>> Thus, it's not all one big mess.  It's a bunch of smaller, little messes. 
>> This makes a long regular expression much more managable.
>> 





More information about the Digitalmars-d mailing list