[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Python filter: incomplete triple-quoted string support
From: |
Thomas Dickey |
Subject: |
Re: Python filter: incomplete triple-quoted string support |
Date: |
Wed, 5 Feb 2020 16:19:01 -0500 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Tue, Feb 04, 2020 at 08:55:55PM -0800, Marc Simpson wrote:
> The current filter (py-filt.l) only supports triple-quoted strings
> formed with double quotes; single quote multi-line literals are
> incorrectly highlighted, e.g.
hmm - I overlooked that (when I wrote it in 1999).
> '''
> 'foo'
> bar
> '''
>
> Naive patch: declare QUOTE4, duplicate and adapt the existing QUOTE3
> block:
>
> %s NORMAL QUOTE1 QUOTE2 QUOTE3 QUOTE4
>
> ...
>
> <NORMAL>\'\'\' { BeginQuote(QUOTE4, String_attr); }
> <QUOTE4>\'\'\' { FinishQuote(NORMAL); }
> <QUOTE4>(\\.|.) { flt_bfr_append(yytext, yyleng); }
> <QUOTE4>[\n] { flt_bfr_append(yytext, yyleng); }
>
> (This can surely be simplified.)
Only a little.
The last two lines can be combined with the similar QUOTE3 ones,
like this:
<QUOTE3,QUOTE4>(\\.|.) { flt_bfr_append(yytext, yyleng); }
<QUOTE3,QUOTE4>[\n] { flt_bfr_append(yytext, yyleng); }
lex doesn't have macros, or something analogous, so the other two
lines in each chunk can't be merged.
--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: PGP signature