Nicholas Clark <[EMAIL PROTECTED]> wrote:

 > On Sun, Dec 17, 2000 at 12:43:15PM +0000, Simon Cozens wrote:
 > > On Sun, Dec 17, 2000 at 01:20:07AM +0000, Nicholas Clark wrote:
 > > > I'm assuming we're all sort of thinking that input is certainly
 > > > [good stuff]
 >
 > Thanks, but you were supposed to tell me what I'd missed :-)
 >

[snip]

 > I had a hairier thought last night.
 > Lots of people (well, certainly at least me and the person who wrote
it)
 > use syntax highlighting editors.
 > The remarks I've seen in comments in several syntax highlighting modes
for
 > perl say that is that perl is pretty much the hardest language to
parse.
 > For example, the syntax highlighter I find myself using at the moment
 > doesn't like:
 >
 >     $foo = \"abc";
 >
 > It thinks that \" escapes that ". Oops.
 > Other nice things like s###; pod, __DATA__, here docs, not needed to
escape
 > some otherwise "interesting" characters inside regexps all seem to be
prone
 > to confusion. So one gets irritated, and either spend time trying to
fix
 > the mode, or "fix" your perl to make the mode happy.
 > Neither of which is getting your real job done (or letting you use your
 > spare time to fix perl instead of the mode)
 > There's only 1 thing that really knows how to parse perl - perl  :-)
 >
 > Would it be sane to get the parser to return suitable information on
the
 > source to let a syntax analyser (such as a highlighting editor) know
that
 > character positions 5123 to 5146 are a qq() string (So it can change
the
 > font or the colour or whatever)

[snip]

As the maker of such an editor, I wouldn't mind getting any help from perl
that can be gotten in this area. It's not really the rules that are
gotchas, but the exceptions to the rules. The elements that you mentioned
(strings and regexen) are extremely difficult to find, especially in odd
contexts like grep {/[^.]/} where there's no leading =~ or !~ and in s///
where there's not a single ending but two, each with its own rules.

I'm not sure this is a parser issue, at least not when it comes to the
internal parsing of Perl for perl's sake. However, putting in db-like
(debug module) hooks that I can grab onto somewhere in the mix might be
helpful.


Reply via email to