vile
[Top][All Lists]
Advanced

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

Re: [vile] bug in the TCL filter


From: Wayne Cuddy
Subject: Re: [vile] bug in the TCL filter
Date: Thu, 16 Oct 2014 12:28:09 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Oct 15, 2014 at 08:36:39PM -0400, Thomas Dickey wrote:
> On Wed, Oct 15, 2014 at 03:36:10PM -0400, Wayne Cuddy wrote:
> > 
> > This code:
> > 
> > proc ProcessFile {date chan} {
> >         
> >     while {[gets $chan line] >= 0} {
> >                 
> >         if {! [string match {*] rcvd frame, fifos *} $line]} {
> >             continue
> >         }
> >          
> >     }
> > }
> > 
> > Will cause all highlighting following the final '}' of the ProcessFile
> > function to stop. The cause is the ']' in the curly brace pattern arg
> > to [string match]. It works if I change the pattern to "*\] ..." but I
> > tend to use cutely brace strings so I don't have to clutter the string
> > with escape sequences.
> 
> I see.  I'm looking at something like this (but can see that I have a
> different test-case which isn't working yet for the "}" recovery:
> 
> diff -u -r1.46 tcl-filt.l
> --- tcl-filt.l        2013/12/02 01:32:53     1.46
> +++ tcl-filt.l        2014/10/16 00:25:22
> @@ -19,6 +19,8 @@
>   */
>  
>  #include <filters.h>
> +
> +#define FLTSTACK_EXTRA int square;
>  #include <fltstack.h>
>  
>  DefineFilter(tcl);
> @@ -67,8 +69,25 @@
>  %%
>  
>  <VERB,ARGS,DATA>"{"{SPACE}*"}"       { WriteToken(Braces_attr); }
> -<VERB,ARGS,DATA>("{*}")?[{]  { WriteToken(Braces_attr); push_state(VERB); }
> -<VERB,ARGS,DATA>[}]          { WriteToken(Braces_attr); pop_state(); }
> +<VERB,ARGS,DATA>("{*}")?[{]  { WriteToken(Braces_attr);
> +                               push_state(VERB);
> +                               FLTSTACK_THIS.square = 0;
> +                             }
> +<VERB,ARGS,DATA>[}]          {
> +                               if (stk_level >= 0) {
> +                                 int matched = (FLTSTACK_THIS.square == 0);
> +                                 WriteToken(Braces_attr);
> +                                 pop_state();
> +                                 if (!matched) {
> +                                   while (stk_level >= 0 && 
> FLTSTACK_THIS.square) {
> +                                     pop_state();
> +                                   }
> +                                 }
> +                               } else {
> +                                 flt_error("unexpected right-brace");
> +                                 WriteToken(Error_attr);
> +                               }
> +                             }
>  
>  <VERB>{IDENT}                        {
>                                 const char *attr = get_keyword_attr(yytext);
> @@ -105,15 +124,21 @@
>                         flt_bfr_finish();
>                         WriteToken(Braces_attr);
>                         push_state(VERB);
> +                       FLTSTACK_THIS.square = 1;
>                       }
>  <VERB,ARGS,DATA>[\[] {
>                         WriteToken(Braces_attr);
>                         push_state(VERB);
> +                       FLTSTACK_THIS.square = 1;
>                       }
>  <VERB,ARGS,DATA>[\]] {
>                         if (stk_level > 0) {
> -                         WriteToken(Braces_attr);
> -                         pop_state();
> +                         if (FLTSTACK_THIS.square) {
> +                             WriteToken(Braces_attr);
> +                             pop_state();
> +                         } else {
> +                             WriteToken("RU");
> +                         }
>                         } else {
>                           flt_error("unexpected right-bracket");
>                           WriteToken(Error_attr);
>

For some reason I'm having trouble using patch to apply that. My file
is versioned at 1.46 so I don't know why. Can you post the entire lex
file please?

On a related note... I'm working on a filter for a rather uncommon file
format that I work with frequently. What's the best way to integrate
*-filt.l files into the build? I'm no expert with autoconf :( I placed
my file the filters directory and I see that genmake.sh updated
genmake.mak. Now I'm able to use the new target in filters/makefile to
produce an external filter. Is there a way to do that without having to
run the configure?

I may bother you in the future with some mundane lex questions if
that's ok?

Thanks once again,
Wayne



reply via email to

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