monit-general
[Top][All Lists]
Advanced

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

Path and argument problem... solution?


From: Christian Hopp
Subject: Path and argument problem... solution?
Date: Tue, 27 Aug 2002 17:28:48 +0200 (CEST)

Hi!

I thought a bit about the thread flying around last month about
parsing paths and arguments.

Solution(?)... we use start conditions.

You set the exclusive condition <argument> (exclusive condition -> we
do not run in other tokens, not matching <argument>) to,

%x argument

When ever we return PATH, we do a BEGIN(argument), like

[/]{pstr} {
        BEGIN(argument);
        yylval.string= xstrdup(yytext);
        return PATH;
        }

and in all other matches for PATH.

We catch the arguments with,

<argument>\"[^\n"]*\" { /* double quoted strings and empty strings */
        yylval.string= func_trim_doubleq_and_dup(yytext);
        return ARGUMENT;
        }

<argument>\'[^\n']*\' { /* single quoted strings and empty strings */
        yylval.string= func_trim_singleq_and_dup(yytext);
        return ARGUMENT;
        }

<argument>[^ \t\n]+ { /* unquoted strings */
        yylval.string= xstrdup(yytext);
        return ARGUMENT;
        }

<argument>[\t ] /* Ignore separators */

<argument>[#].*[\n] { /* Comments */
        BEGIN(INITIAL); /* Stop being in <argument> condition */
        }

<argument>[\n] { /* End of line */
        BEGIN(INITIAL); /* Stop being in <argument> condition */
        }

Thus, we don't run into trouble when we have quoted arguments which
are actually no  paths.

So what do you think?  Btw... flex' info page about "Start conditions"
is filled with this lots of examples.  I think it would be even useful
to clean up the whole language a little, tiny bit. (-:

Christian


PS: Hauk, I hope you had a nice swim.

-- 
Christian Hopp                                email: address@hidden
Institut für Elektrische Informationstechnik             fon: +49-5323-72-2113
Technische Universität Clausthal                         fax: +49-5323-72-3197
  pgpkey: https://www.iei.tu-clausthal.de/pgp-keys/chopp.key.asc  (2001-11-22)





reply via email to

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