|
|
1.1 ! root 1: %{ ! 2: #ifndef lint ! 3: static char *rcsid = "$Header: /f/osi/others/quipu/uips/pod/RCS/conf_read.y,v 7.0 90/06/12 13:15:54 mrose Exp $"; ! 4: #endif ! 5: ! 6: /* ! 7: * $Header: /f/osi/others/quipu/uips/pod/RCS/conf_read.y,v 7.0 90/06/12 13:15:54 mrose Exp $ ! 8: */ ! 9: ! 10: /* ! 11: * $Log: conf_read.y,v $ ! 12: * Revision 7.0 90/06/12 13:15:54 mrose ! 13: * *** empty log message *** ! 14: * ! 15: * Revision 1.5 90/04/26 10:21:47 emsrdsm ! 16: * *** empty log message *** ! 17: * ! 18: * Revision 1.4 90/04/25 13:48:16 emsrdsm ! 19: * i) lint'ed ! 20: * ! 21: * Revision 1.3 90/04/20 10:31:36 emsrdsm ! 22: * *** empty log message *** ! 23: * ! 24: * Revision 1.2 90/04/20 10:31:23 emsrdsm ! 25: * *** empty log message *** ! 26: * ! 27: * Revision 1.1 90/04/10 16:46:39 emsrdsm ! 28: * Initial revision ! 29: * ! 30: */ ! 31: ! 32: #include <stdio.h> ! 33: #include <string.h> ! 34: #include <ctype.h> ! 35: #include "filt.h" ! 36: #include "symtab.h" ! 37: ! 38: extern make_type(); ! 39: extern filt_struct *make_item_filter(); ! 40: extern filt_struct *link_filters(); ! 41: extern filt_struct *make_parent_filter(); ! 42: extern put_symbol_value(); ! 43: ! 44: extern FILE *file; ! 45: extern int curr_filt; ! 46: extern char **file_names; ! 47: extern table_entry symtab; ! 48: %} ! 49: %start type_spec ! 50: ! 51: %union { ! 52: filt_struct *filt; ! 53: char strval[255]; ! 54: int symbol; ! 55: } ! 56: ! 57: %token NUMBER NAME DEFAULT STRING OID AND OR NOT APPROX EQUAL ITEM ! 58: ! 59: %type <filt> filter filter_list assertion filter_item ! 60: %type <symbol> filt_type match ! 61: %token <symbol> NOT AND OR APPROX EQUAL SUBSTRING ! 62: %token <symbol> '"' ':' '(' ')' ! 63: %token <strval> STRING OID ! 64: %type <strval> name default ! 65: ! 66: %% ! 67: type_spec : name filter {make_type($1, $2);} ! 68: ; ! 69: ! 70: name : NAME ':' STRING {(void) strcpy($$, $3);} ! 71: ; ! 72: ! 73: default : DEFAULT ':' STRING {(void) strcpy($$, $3);} ! 74: | {(void) strcpy($$, "\0");} ! 75: ; ! 76: ! 77: assertion : '(' filt_type filter filter filter_list ')' {$$ = make_parent_filter($2, $3, $4, $5);} ! 78: | '(' NOT filter ')' {$$ = make_parent_filter($2, $3, (filt_struct *) 0,(filt_struct *) 0);} ! 79: | filter_item {$$ = $1;} ! 80: ; ! 81: ! 82: filter_list : filter filter_list {$$ = link_filters($1, $2);} ! 83: | filter {$$ = $1;} ! 84: | {$$ = (filt_struct *) 0;} ! 85: ; ! 86: ! 87: filter : filter_item {$$ = $1;} ! 88: | assertion {$$ = $1;} ! 89: ; ! 90: ! 91: filter_item : '(' OID match STRING ')' {$$ = make_item_filter($2, $3, $4);} ! 92: ; ! 93: ! 94: match : APPROX {$$ = $1;} ! 95: | EQUAL {$$ = $1;} ! 96: | SUBSTRING {$$ = $1;} ! 97: ; ! 98: ! 99: filt_type : AND {$$ = $1;} ! 100: | OR {$$ = $1;} ! 101: ; ! 102: %% ! 103: ! 104: yylex() ! 105: { ! 106: int c, count = 0; ! 107: char lexeme[255]; ! 108: ! 109: while(iswspace(c = getc(file))) ! 110: if (c == EOF) return(0); ! 111: ! 112: lexeme[count++] = c; ! 113: ! 114: switch(c) { ! 115: case '#': ! 116: while (getc(file) != '\n'); ! 117: return(yylex()); ! 118: case '"': ! 119: count = 0; ! 120: while ((c = getc(file)) != '"') ! 121: lexeme[count++] = c; ! 122: lexeme[count] = '\0'; ! 123: (void) strcpy(yylval.strval, lexeme); ! 124: return STRING; ! 125: case '$': ! 126: while (!iswspace((c = getc(file))) && !issymbol(c)) ! 127: lexeme[count++] = c; ! 128: lexeme[count] = '\0'; ! 129: put_symbol_value(symtab, lexeme+1, (char *) 0); ! 130: (void) strcpy(yylval.strval, lexeme); ! 131: return STRING; ! 132: case '(': ! 133: return (int) c; ! 134: case ')': ! 135: return (int) c; ! 136: case ':': ! 137: return (int) c; ! 138: case '&': ! 139: yylval.symbol = AND; ! 140: return AND; ! 141: case '|': ! 142: yylval.symbol = OR; ! 143: return OR; ! 144: case '!': ! 145: yylval.symbol = NOT; ! 146: return NOT; ! 147: case '*': ! 148: lexeme[count] = '\0'; ! 149: (void) strcpy(yylval.strval, lexeme); ! 150: return STRING; ! 151: case '~': ! 152: if((lexeme[count] = getc(file)) == '=') { ! 153: yylval.symbol = APPROX; ! 154: return APPROX; ! 155: } ! 156: break; ! 157: case '%': ! 158: if((lexeme[count] = getc(file)) == '=') { ! 159: yylval.symbol = SUBSTRING; ! 160: return SUBSTRING; ! 161: } ! 162: break; ! 163: case '=': ! 164: yylval.symbol = EQUAL; ! 165: return EQUAL; ! 166: } ! 167: ! 168: while(!iswspace(c = getc(file)) && c != '\0' && !issymbol(c)) ! 169: if (c != EOF) ! 170: lexeme[count++] = c; ! 171: else ! 172: return(0); ! 173: ! 174: (void) fseek(file,(long) -1, 1); ! 175: ! 176: lexeme[count] = '\0'; ! 177: switch(*lexeme) { ! 178: case 'd': ! 179: case 'D': ! 180: if(!strcmp(lexeme, "default") || !strcmp(lexeme, "DEFAULT")) ! 181: return DEFAULT; ! 182: else { ! 183: (void) strcpy(yylval.strval, lexeme); ! 184: return STRING; ! 185: } ! 186: case 'n': ! 187: case 'N': ! 188: if(!strcmp(lexeme, "name") || !strcmp(lexeme, "NAME")) ! 189: return NAME; ! 190: else { ! 191: (void) strcpy(yylval.strval, lexeme); ! 192: return STRING; ! 193: } ! 194: case '0': ! 195: case '1': ! 196: case '2': ! 197: case '3': ! 198: case '4': ! 199: case '5': ! 200: case '6': ! 201: case '7': ! 202: case '8': ! 203: case '9': ! 204: count = 0; ! 205: while (isdigit(lexeme[count]) || lexeme[count] == '.') count++; ! 206: if (lexeme[count] == '\0') { ! 207: (void) strcpy(yylval.strval, lexeme); ! 208: return OID; ! 209: } else { ! 210: (void) strcpy(yylval.strval, lexeme); ! 211: return STRING; ! 212: } ! 213: default: ! 214: (void) strcpy(yylval.strval, lexeme); ! 215: return STRING; ! 216: } ! 217: } ! 218: ! 219: yyerror(err) ! 220: char *err; ! 221: { ! 222: /* Sorry */ ! 223: (void) fprintf(stderr, "Parse error: "); ! 224: (void) fprintf(stderr, err); ! 225: (void) fprintf(stderr, "\n"); ! 226: } ! 227: ! 228: int ! 229: issymbol(c) ! 230: char c; ! 231: { ! 232: switch(c) { ! 233: case '#': ! 234: return 1; ! 235: case '"': ! 236: return 1; ! 237: case '(': ! 238: return 1; ! 239: case ')': ! 240: return 1; ! 241: case ':': ! 242: return 1; ! 243: case '&': ! 244: return 1; ! 245: case '|': ! 246: return 1; ! 247: case '!': ! 248: return 1; ! 249: case '*': ! 250: return 1; ! 251: case '~': ! 252: return 1; ! 253: case '=': ! 254: return 1; ! 255: case '$': ! 256: return 1; ! 257: case '%': ! 258: return 1; ! 259: } ! 260: return 0; ! 261: } ! 262: ! 263: int ! 264: iswspace(c) ! 265: char c; ! 266: { ! 267: switch(c) { ! 268: case ' ': ! 269: return 1; ! 270: case '\n': ! 271: return 1; ! 272: case '\t': ! 273: return 1; ! 274: } ! 275: return 0; ! 276: } ! 277: ! 278: ! 279:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.