\begin{V Kamakhya}
> How do I implement recursive definitions in regex
> for 'c' functions?
> 
> For e.g
> KEY    "DELETED|SINCE "date"|"FROM "string
>         "|NOT "KEY"|"OR "KEY" "KEY"|
>         ("KEY"( "KEY")* )"
> 
> I cannot use recursive definitions when using a #define
> 
> I defined it in the following manner(without much success!)
> 
> #define KEY_ALONE  "DELETED|SINCE "date"|"FROM "string
> #define KEY_SET     "NOT "KEY_ALONE"| OR "KEY_ALONE"
> "KEY_ALONE"|"KEY_ALONE"("KEY_ALONE")*"
> 
> However, this code does not run for combinations like
> 
> 1.  NOT NOT DELETED
> 2.  NOT OR DELETED FROM "xyz"
> 3.  OR OR DELETED FROM "xyz" SINCE "5-01-01"
> 4.  OR OR NOT DELETED FROM "xyz" NOT SINCE "5-01-01"
> 5.  OR DELETED OR FROM "xyz" SINCE "5-01-01"

err.. you don't.

what are you trying to do? (the bigger picture)


if you are trying to write a parser, then try using a parser
generator, like "yacc" (the gnu version is called "bison"). cpp is
most certainly not up to the job.

if you are just trying to pregenerate some exotic combinations of
code, then you may have to use a better preprocessor, like m4 or a
perl/sh/awk/whatever script of your own devising and run that on your
.c files before passing them off to the compiler.

-- 
 - Gus

  (notes lex/yacc for inclusion in upcoming february codefest)


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to