Yacc entry for crontab , accepting negative entry how ?

Yacc entry for crontab , accepting negative entry how ?

Post by Hiren Hindo » Wed, 22 Sep 1993 05:17:05



I'm trying to write a cron like program which accepts crontab like
input except the day of the month entry can also hold negative entries

How can I modify the following rule to accept negative entries ?

dm:             dm ',' dm     |
                DIGITS '-' DIGITS  
                {
                int i;
                for (i=$1;i<= $3;i++)
                        FD_SET(i,&day_of_month);
                }
                |
                DIGITS   { FD_SET($1,&day_of_month); }
                |
                '-' DIGITS     /* doesn't work*/
                {
                $$ = -$2;
/*              printf("%d",$$);*/
                }
                |
                ASTERISK    
                {
                int i;
                for(i=1;i<31;i++)
                  FD_SET(i,&day_of_month);
                }
                ;

Ideally I want to recognize the following entry for the day-of-month
-9--5
as 9 nine days before the end of the month to 5 days before the end of
the month.

If anyone of you has  an idea or suggestions please let me know
please email (it would be faster) your answer.
Thanks in advance
Hiren