DESCRIPTION

Please consult the manual of Regexp::Common for a general description of the works of this interface.

Do not use this module directly, but load it via Regexp::Common.

This modules gives you regular expressions for comments in various languages.

THE LANGUAGES

Below, the comments of each of the languages are described. The patterns are available as $RE{comment}{LANG}, foreach language LANG. Some languages have variants; it's described at the individual languages how to get the patterns for the variants. Unless mentioned otherwise, {-keep} sets $1, $2, $3 and $4 to the entire comment, the opening marker, the content of the comment, and the closing marker (for many languages, the latter is a newline) respectively.

In Algol 68, comments are either delimited by #, or by one of the keywords co or comment. The keywords should not be part of another word. See http://westein.arb-phys.uni-dortmund.de/~wb/a68s.txt. With {-keep}, only $1 will be set, returning the entire comment.

ALPACA

The ALPACA language has comments starting with /* and ending with */.

awk

The awk programming language uses comments that start with # and end at the end of the line.

The esotoric language Beatnik only uses words consisting of letters. Words are scored according to the rules of Scrabble. Words scoring less than 5 points, or 18 points or more are considered comments (although the compiler might mock at you if you score less than 5 points). Regardless whether {-keep}, $1 will be set, and set to the entire comment. This pattern requires perl 5.8.0 or newer.

The C++ language has two forms of comments. Comments that start with // and last till the end of the line, and comments that start with /*, and end with */. If {-keep} is used, only $1 will be set, and set to the entire comment.

The Cg language has two forms of comments. Comments that start with // and last till the end of the line, and comments that start with /*, and end with */. If {-keep} is used, only $1 will be set, and set to the entire comment. See http://developer.nvidia.com/attach/3722.

Comments in the chess query language (CQL) start with a semi colon (;) and last till the end of the line. See http://www.rbnn.com/cql/.

Crystal Report

The formula editor in Crystal Reports uses comments that start with //, and end with the end of the line.

Dylan

There are two types of comments in Dylan. They either start with //, or are nested comments, delimited with /* and */. Under {-keep}, only $1 will be set, returning the entire comment. This pattern requires perl 5.6.0 or newer.

The FPL language has two forms of comments. Comments that start with // and last till the end of the line, and comments that start with /*, and end with */. If {-keep} is used, only $1 will be set, and set to the entire comment.

There are two forms of Fortran. There's free form Fortran, which has comments that start with !, and end at the end of the line. The pattern for this is given by $RE{Fortran}. Fixed form Fortran, which has been obsoleted, has comments that start with C, c or * in the first column, or with ! anywhere, but the sixth column. The pattern for this are given by $RE{Fortran}{fixed}.

There are two types of comments in Haskell. They either start with at least two dashes, or are nested comments, delimited with {- and -}. Under {-keep}, only $1 will be set, returning the entire comment. This pattern requires perl 5.6.0 or newer.

HTML

In HTML, comments only appear inside a comment declaration. A comment declaration starts with a <!, and ends with a >. Inside this declaration, we have zero or more comments. Comments starts with -- and end with --, and are optionally followed by whitespace. The pattern $RE{comment}{HTML} recognizes those comment declarations (and hence more than a comment). Note that this is not the same as something that starts with <!-- and ends with -->, because the following will be matched completely:

<!-- First Comment --
--> Second Comment <!--
-- Third Comment -->

Do not be fooled by what your favourite browser thinks is an HTML comment.

If {-keep} is used, the following are returned:

$1

captures the entire comment declaration.

$2

captures the MDO (markup declaration open), <!.

$3

captures the content between the MDO and the MDC.

$4

captures the (last) comment, without the surrounding dashes.

$5

captures the MDC (markup declaration close), >.

Hugo

There are two types of comments in Hugo. They either start with ! (which cannot be followed by a \), or are nested comments, delimited with !\ and \!. Under {-keep}, only $1 will be set, returning the entire comment. This pattern requires perl 5.6.0 or newer.

Comments in INTERCAL are single line comments. They start with one of the keywords NOT or N'T, and can optionally be preceded by the keywords DO and PLEASE. If both keywords are used, PLEASE precedes DO. Keywords are separated by whitespace.

The Java language has two forms of comments. Comments that start with // and last till the end of the line, and comments that start with /*, and end with */. If {-keep} is used, only $1 will be set, and set to the entire comment.

There are many implementations of Pascal. This modules provides pattern for comments of several implementations.

$RE{comment}{Pascal}

This is the pattern that recognizes comments according to the Pascal ISO standard. This standard says that comments start with either {, or (*, and end with } or *). This means that {*) and (*} are considered to be comments. Many Pascal applications don't allow this. See http://www.pascal-central.com/docs/iso10206.txt

The Delphi Pascal, Free Pascal and the Gnu Pascal Compiler implementations of Pascal all have comments that either start with // and last till the end of the line, are delimited with { and } or are delimited with (* and *). Patterns for those comments are given by $RE{comment}{Pascal}{Delphi}, $RE{comment}{Pascal}{Free} and $RE{comment}{Pascal}{GPC} respectively. These patterns only set $1 when {-keep} is used, which will then include the entire comment.

The Workshop Pascal compiler, from SUN Microsystems, allows comments that are delimited with either { and }, delimited with (*) and *), delimited with /*, and */, or starting and ending with a double quote ("). When {-keep} is used, only $1 is set, and returns the entire comment.

The SLIDE language has two froms of comments. First there is the line comment, which starts with a # and includes the rest of the line (just like Perl). Second, there is the multiline, nested comment, which are delimited by (* and *). Under C{-keep}>, only $1 is set, and is set to the entire comment. This pattern needs at least Perl version 5.6.0. See http://www.cs.berkeley.edu/~ug/slide/docs/slide/spec/spec_frame_intro.shtml.

slrn

Configuration files for slrn have comments starting with a % and lasting the rest of the line.

Smalltalk

Smalltalk uses comments that start and end with a double quote, ".

SMITH

Comments in the SMITH language start with ;, and last till the end of the line.

Squeak

In the Smalltalk variant Squeak, comments start and end with ". Double quotes can appear inside comments by doubling them.

SQL

Standard SQL uses comments starting with two or more dashes, and ending at the end of the line.

MySQL does not follow the standard. Instead, it allows comments that start with a # or -- (that's two dashes and a space) ending with the following newline, and comments starting with /*, and ending with the next ; or */ that isn't inside single or double quotes. A pattern for this is returned by $RE{comment}{SQL}{MySQL}. With {-keep}, only $1 will be set, and it returns the entire comment.

Tcl

In Tcl, comments start with # and continue till the end of the line.

TeX

The documentation language TeX uses comments starting with % and ending at the end of the line.

troff

The document formatting language troff uses comments starting with \", and continuing till the end of the line.

Ubercode

The Windows programming language Ubercode uses comments that start with // and continue to the end of the line. See http://www.ubercode.com.

vi

In configuration files for the editor vi, one can use comments starting with ", and ending at the end of the line.

*W

In the language *W, comments start with ||, and end with !!.

zonefile

Comments in DNS zonefiles start with ;, and continue till the end of the line.

LICENSE and COPYRIGHT

This module is free software, and maybe used under any of the following licenses:

1) The Perl Artistic License. See the file COPYRIGHT.AL.
2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
3) The BSD Licence. See the file COPYRIGHT.BSD.
4) The MIT Licence. See the file COPYRIGHT.MIT.

Module Install Instructions

To install Regexp::Common::comment, simply copy and paste either of the commands in to your terminal