On Jun 30, Steve Fink said:
>On Jun-27, Jeff 'japhy' Pinyan wrote:
>
>> It creates a tree structure, not identical but similar to the array of
>> nodes Perl uses internally.
>
>Ah, good. Then I am interested. When I manage to find some time for
>hacking again, I'll graft it onto languages/regex as a replacement for
>the ridiculous parser I have there now.
>I should just look at the code, but I'm wondering what you do with
>language-specific constructs. Embedded code, for example. How do you
>find the end of it?
Use The Source, Luke. I do exactly what Perl's regex compiler does:
/* right after matching "(?{" */
while (count && (c = *RExC_parse)) {
if (c == '\\' && RExC_parse[1]) RExC_parse++;
else if (c == '{') count++;
else if (c == '}') count--;
RExC_parse++;
}
if (*RExC_parse != ')') {
vFAIL("Sequence (?{...}) not terminated or not {}-balanced");
}
Granted, I do it with a recursive regex, not character-by-character, but
that's how I do it. I don't parse the expression, I just make sure it's
properly balanced.
>And will you be supporting things like Perl6's
>
> / $x := (a*b) /
>
>where '$x' is a language-dependent variable name syntax?
If I have a means for matching variable names, then that's not a problem.
I assume my first version of the Perl 6 regex parser will only match
simple variables, like $foo and @bar and %blat. Baby steps.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.