Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/sd/conf_read.y, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.