home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / backups / parser.y < prev    next >
Encoding:
Lex Description  |  1988-01-31  |  1.5 KB  |  90 lines

  1. %{
  2. static char rcsid[] = "$Header: parser.y,v 1.2 85/04/05 17:15:02 scooter Exp $";
  3.  
  4. #include    "backup.h"
  5.  
  6. %}
  7.  
  8. %start pgm
  9.  
  10. %token COMMENT DAY STRING NUM FILESYS STAR DASH NEWLINE MONTH COMMA
  11.  
  12. %%
  13.  
  14. pgm    : COMMENT NEWLINE
  15.                 { ignore = YES; YYACCEPT; }
  16.     | day_spec week_spec month_spec level filesys end_spec NEWLINE
  17.                 { ignore = NO; YYACCEPT; }
  18.     | error '\n'
  19.                 { yyerrok; }
  20.     ;
  21.  
  22. level:    NUM
  23.                 { level = $1; }
  24.     ;
  25.  
  26. filesys: FILESYS
  27.                 { strcpy(filesys,yytext); }
  28.     ;
  29.  
  30. day_spec: STAR
  31.                 { days = ALL; }
  32.     | day_list
  33.                 { days = LIST; }
  34.     | DAY DASH DAY
  35.                 { days = RANGE; day_lst[0] = $1; 
  36.                   day_lst[1] = $3; day_ptr = 2;}
  37.     ;
  38.  
  39. day_list: DAY
  40.                 { day_ptr = 0; day_lst[day_ptr++] = $1; }
  41.     | day_list COMMA DAY
  42.                 { day_lst[day_ptr++] = $3; }
  43.     ;
  44.  
  45. week_spec:STAR
  46.                 { weeks = ALL; }
  47.     | num_list
  48.                 { weeks = LIST; }
  49.     | NUM DASH NUM
  50.                 { weeks = RANGE; week_lst[0] = $1; 
  51.                   week_lst[1] = $3; week_ptr = 2;}
  52.     ;
  53.  
  54. num_list: NUM
  55.                 { week_ptr = 0; week_lst[week_ptr++] = $1; }
  56.     | num_list COMMA NUM
  57.                 { week_lst[week_ptr++] = $3; }
  58.     ;
  59.  
  60. month_spec: STAR
  61.                 { months = ALL; }
  62.     | month_list
  63.                 { months = LIST; }
  64.     | MONTH DASH MONTH
  65.                 { months = RANGE; month_lst[0] = $1; 
  66.                   month_lst[1] = $3; month_ptr = 2;}
  67.     ;
  68.  
  69. month_list: MONTH
  70.                 { month_ptr = 0; month_lst[month_ptr++] = $1; }
  71.     | month_list COMMA MONTH
  72.                 { month_lst[month_ptr++] = $3; }
  73.     ;
  74.  
  75. end_spec:    /* empty */
  76.     | STRING
  77.     | STRING COMMENT
  78.     | COMMENT
  79.     ;
  80.  
  81. %%
  82.  
  83. #include "lex.yy.c"
  84.  
  85. yyerror(s)
  86. char *s;
  87. {
  88.     fprintf(stderr,"%s:line = %d, char = %d\n",s,line_count,lineptr);
  89. }
  90.