On Fri, May 08, 2009 at 09:21:54AM +0200, Alexander Burger wrote:
> True. I'll better make it nesting, using a simple level counter.

Hm, thinking about it, I'm not so sure ...

A working solution would be

   static int skip(int c) {
      for (;;) {
         if (Chr < 0)
            return Chr;
         while (Chr <= ' ') {
            Env.get();
            if (Chr < 0)
               return Chr;
         }
         if (Chr != c)
            return Chr;
         Env.get();
         if (c != '#' || Chr != '{') {
            while (Chr != '\n') {
               if (Chr < 0)
                  return Chr;
               Env.get();
            }
         }
         else {
            int n = 1;

            for (;;) {  // #{block-comment}# from Kriangkrai Soatthiyanont
               Env.get();
               if (Chr < 0)
                  return Chr;
               if (Chr == '}'  &&  (Env.get(), Chr == '#')  && !--n)
                  break;
               if (Chr == '#'  &&  (Env.get(), Chr == '{'))
                  ++n;
            }
         }
         Env.get();
      }
   }

BUT, I think this is not wise.

Because: If the commented text contains the pattern "#{" or "}#" in a
context where it is not relevant as a comment (e.g. in a symbol name or
a string), the nesting will break.

Now I understand why "/*" and "*/" in C don't nest. Shouldn't we better
stay with non-nesting block comments?

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to