[Aeditor-talk] Regexp assertions

Mark msparshatt at yahoo.co.uk
Sat Dec 13 12:10:02 EST 2003


On Saturday 13 Dec 2003 10:38 am, Simon Strandgaard wrote:
> On Fri, 2003-12-12 at 21:46, Mark wrote:
> > the [...] format is now working for non capturing grouping
>
> Add this illegal testcase, it may surprise you.
>
> compile("a[xy)b")   #  compiles fine, shouldn't it fail?
>

good point. I'll add some tests for cases like this and a fix right away

> > I've almost finished working on assertions with the following working
> > <1,5>	repeat
>
> I think I read that perl6 also has inverse ranges, so that ATOM<!3,5>
> are equal to  ( ATOM<0,2> | ATOM<6,> )     not sure though
>

Yes negated ranges are allowed.

> > <digit>	named character class
> > <[0-9]>	explicit character class
> > <-[0-9]> inverse character class
> >
> > I still need to work on more complicated assertions such as
> > < <digit> - [0-2] > which would match all digits except 0,1 and 2, and
> > code assertions.
>
> Yes thats not trivial. the #parse_charclass will require some rewrite.
>

Actually I've moved the handling for <...> into a seperate parse_assertion 
function. most of the complexity is in there. Parse Character class (which 
now just handles any cases of [...] within an assertion) hasn't had to change 
very much.

> The variable 'symbols' (also 'inverse_symbols'), are an Array
> containing either
> A) letter        'Y'
> B) letter-range  'X'..'Z'
>
> Some sort of add/subtract for this array seems to be necessary.
>

I agree that will be the best way

> > I have a couple of questions
> >
> > I want to add some new classes for code assertions and closures,
> >
> > CodeBlock
> > 	CodeAssertion
> > 	Closure
>
> From my brief understanding of perl6, the only thing which are the
> difference on {closure} and <codeassertion>, are that codeassert ignores
> the result ?   Is that correct?
>
Actually closures ignore the result.

> If this is the case, then I would join the 2 classes. Perhaps call the
> class 'InlineCode'... and have a boolean which indicates weather the
> result should be ignored or not.
>

One problem is after rereading the docs I've found a third type of code block, 
created using <{...}>. this executes the code and adds the result to the 
regexp.

The types are
Closure 			{...}		Fails the match if the code raises an exception
Code assertion	<(...)>	Fails the match if the code returns false
Regexp code		<{...}>	Inserts the return value into the regexp

There are two ways to handle these
1: use a single class, storing the type of code block as a flag within the 
class
2: use a class for each type of code block

Personally I'd prefer to go the second route. Most of the code would be within 
the base class with each subclass overriding the call method to do the right 
thing.

> > am I right in thinking that abstractsyntax.rb is the best place to put
> > them?
>
> Exactly.
>
> > Also I'm making a list of features that I still need. Would it be best to
> > put it in the TODO file or to set up a seperate TODO file for Perl6
> > features?
>
> make it separate, 'TODO.perl6', 'README.perl6' ... etc.
>

Okay, will do

> except for 'CHANGES'.
>
>
> The last week I have been sick.. now my headache are gone, and I am
> ready to work again. I will focus on implementing a better
> scanner-routine for Repeat.
>

I'm glad you're feeling better

Best Regards

Mark Sparshatt



More information about the Aeditor-talk mailing list