help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (cperl-mode) Problems with syntax highlighting after __DATA__ !


From: Ted Zlatanov
Subject: Re: (cperl-mode) Problems with syntax highlighting after __DATA__ !
Date: Wed, 08 Dec 2010 15:32:57 -0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

On Thu, 21 Oct 2010 04:43:43 -0700 (PDT) LanX <rolf.langsdorf@googlemail.com> 
wrote: 

>> I think it's not that bad.  __DATA__ is the same content (semantically)
>> as a here-file,

L> or a POD-section , i.e. natural solution would be comment-face.
L> (like most other editors I tested do, just check vim)

L> __END__ is practically the same as __DATA__ and Ilya is right those
L> sections are terminated only by EOF.

Theoretically they are practically the same, but in practice they are not.

__DATA__ begins a section that can be used through the DATA filehandle.
It's a true here-file without interpolation and has no syntax.

__END__ ends the Perl program and any __DATA__ effects.  Usually POD
will follow but the Perl parser doesn't care (unlike =cut markers, which
do matter to the Perl parser).  The POD extractor, usually `perldoc',
will care.  So it's nice to the user to highlight it as POD.

On Wed, 20 Oct 2010 19:40:30 +0000 (UTC) Ilya Zakharevich 
<nospam-abuse@ilyaz.org> wrote: 

IZ> On 2010-10-19, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> I think it's not that bad.  __DATA__ is the same content (semantically)
>> as a here-file, which perl-mode and cperl-mode can handle.

IZ> Are you sure?  I think if one would put the same breaks-CPerl content
IZ> inside a here-doc, CPerl would slow down as well.  AFAIK, here-docs
IZ> are still facified; the result is just ignored.

Well, you could try it...  I will not presume to know the cperl-mode
internals, I was just talking about parsing the sections when I said
"it's not that bad."

IZ> Hmm, on the other hand, if it is syntaxification which is slowed down,
IZ> then yes - it should not be a lot of problem to skip stuff after
IZ> __DATA__, since CPerl does syntaxification in one pass.

Right.  Perl won't parse after __DATA__ or __END__ no matter what.

>> It always ends with EOF or with another __X__ marker on a new line.

IZ> Eh???  AFAIK, it ends with EOF period.

IZ>   (The code to parse <DATA> may have some special logic to find your
IZ>    __X__; but it may look for whatever it wants as well...)

There are at least a few CPAN modules that care, e.g. Inline::Files and
company.  So I think it's nice to highlight every __X__ marker instead
of special-casing __DATA__ (__END__ has to be special because it means
POD will start, usually).

Ted


reply via email to

[Prev in Thread] Current Thread [Next in Thread]