Announcement

Collapse
No announcement yet.

Improved Perl grammar for String

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Improved Perl grammar for String

    Currently, BC3 doesn't highlight as strings regexps and quoted strings like these:

    s|foo|bar|;
    s#foo#bar#;
    s{foo}{bar};
    s(foo)(bar);
    s[foo][bar];
    print qw{a b};
    print qw[c d];
    print qw{e f};
    print qq(g h);
    print qq[i j];
    print qq{k l};
    print q(m n);
    print q[o p];
    print q{q r};
    Also, the pattern for matching a Perl match needs to ignore a backslash that might escape the '/'. The rules below are not perfect but it's the most I could do with the PCRE subset. Any chance for extended regexps? Negative look-behind and that sort of stuff. Note that using simply

    [^\\]/[^/]*/
    to take care of a potential backslash escaping an open regex delimiter '/', interferes with this rule:

    String=Text from ' to '
    because apparently the backslash rule is interpreted before the String=Text from ' to ' rule:

    my $path = '/'.$web.'/'.$topic;
    will be incorrectly highlighted because the character before a / is an apostrophe. Question to the developers: are the rules in the Grammar parsed in the order they show up there?

    Anyway, here are the improved Perl String grammar rules. Just cut and paste in place of the two lines that come by default.

    (s|tr)/([^/]*/){2}
    (s|tr)\|([^|]*\|){2}
    (s|tr)#([^#]*#){2}
    (s|tr)\(([^)]*\)){2}
    (s|tr)\[([^\]]*\]){2}
    (s|tr)\{([^}]*\}){2}
    (q|qq|qw)\([^)]+\)
    (q|qq|qw)\[[^\]]+]
    (q|qq|qw)\{[^}]+}
    Last edited by dandv; 17-Dec-2009, 12:52 AM. Reason: The backslahs-escaping rule broke string starting with a '/'

  • #2
    dandv,

    Thanks for the Perl format fix. We'll include the updated format in an upcoming release (probably 3.2).
    Chris K Scooter Software

    Comment

    Working...
    X