|
|
BSD 4.3reno
%{
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/conf_read.y,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/conf_read.y,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*/
/*
* $Log: conf_read.y,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.0 90/06/12 13:15:54 mrose
* *** empty log message ***
*
* Revision 1.5 90/04/26 10:21:47 emsrdsm
* *** empty log message ***
*
* Revision 1.4 90/04/25 13:48:16 emsrdsm
* i) lint'ed
*
* Revision 1.3 90/04/20 10:31:36 emsrdsm
* *** empty log message ***
*
* Revision 1.2 90/04/20 10:31:23 emsrdsm
* *** empty log message ***
*
* Revision 1.1 90/04/10 16:46:39 emsrdsm
* Initial revision
*
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "filt.h"
#include "symtab.h"
extern make_type();
extern filt_struct *make_item_filter();
extern filt_struct *link_filters();
extern filt_struct *make_parent_filter();
extern put_symbol_value();
extern FILE *file;
extern int curr_filt;
extern char **file_names;
extern table_entry symtab;
%}
%start type_spec
%union {
filt_struct *filt;
char strval[255];
int symbol;
}
%token NUMBER NAME DEFAULT STRING OID AND OR NOT APPROX EQUAL ITEM
%type <filt> filter filter_list assertion filter_item
%type <symbol> filt_type match
%token <symbol> NOT AND OR APPROX EQUAL SUBSTRING
%token <symbol> '"' ':' '(' ')'
%token <strval> STRING OID
%type <strval> name default
%%
type_spec : name filter {make_type($1, $2);}
;
name : NAME ':' STRING {(void) strcpy($$, $3);}
;
default : DEFAULT ':' STRING {(void) strcpy($$, $3);}
| {(void) strcpy($$, "\0");}
;
assertion : '(' filt_type filter filter filter_list ')' {$$ = make_parent_filter($2, $3, $4, $5);}
| '(' NOT filter ')' {$$ = make_parent_filter($2, $3, (filt_struct *) 0,(filt_struct *) 0);}
| filter_item {$$ = $1;}
;
filter_list : filter filter_list {$$ = link_filters($1, $2);}
| filter {$$ = $1;}
| {$$ = (filt_struct *) 0;}
;
filter : filter_item {$$ = $1;}
| assertion {$$ = $1;}
;
filter_item : '(' OID match STRING ')' {$$ = make_item_filter($2, $3, $4);}
;
match : APPROX {$$ = $1;}
| EQUAL {$$ = $1;}
| SUBSTRING {$$ = $1;}
;
filt_type : AND {$$ = $1;}
| OR {$$ = $1;}
;
%%
yylex()
{
int c, count = 0;
char lexeme[255];
while(iswspace(c = getc(file)))
if (c == EOF) return(0);
lexeme[count++] = c;
switch(c) {
case '#':
while (getc(file) != '\n');
return(yylex());
case '"':
count = 0;
while ((c = getc(file)) != '"')
lexeme[count++] = c;
lexeme[count] = '\0';
(void) strcpy(yylval.strval, lexeme);
return STRING;
case '$':
while (!iswspace((c = getc(file))) && !issymbol(c))
lexeme[count++] = c;
lexeme[count] = '\0';
put_symbol_value(symtab, lexeme+1, (char *) 0);
(void) strcpy(yylval.strval, lexeme);
return STRING;
case '(':
return (int) c;
case ')':
return (int) c;
case ':':
return (int) c;
case '&':
yylval.symbol = AND;
return AND;
case '|':
yylval.symbol = OR;
return OR;
case '!':
yylval.symbol = NOT;
return NOT;
case '*':
lexeme[count] = '\0';
(void) strcpy(yylval.strval, lexeme);
return STRING;
case '~':
if((lexeme[count] = getc(file)) == '=') {
yylval.symbol = APPROX;
return APPROX;
}
break;
case '%':
if((lexeme[count] = getc(file)) == '=') {
yylval.symbol = SUBSTRING;
return SUBSTRING;
}
break;
case '=':
yylval.symbol = EQUAL;
return EQUAL;
}
while(!iswspace(c = getc(file)) && c != '\0' && !issymbol(c))
if (c != EOF)
lexeme[count++] = c;
else
return(0);
(void) fseek(file,(long) -1, 1);
lexeme[count] = '\0';
switch(*lexeme) {
case 'd':
case 'D':
if(!strcmp(lexeme, "default") || !strcmp(lexeme, "DEFAULT"))
return DEFAULT;
else {
(void) strcpy(yylval.strval, lexeme);
return STRING;
}
case 'n':
case 'N':
if(!strcmp(lexeme, "name") || !strcmp(lexeme, "NAME"))
return NAME;
else {
(void) strcpy(yylval.strval, lexeme);
return STRING;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
count = 0;
while (isdigit(lexeme[count]) || lexeme[count] == '.') count++;
if (lexeme[count] == '\0') {
(void) strcpy(yylval.strval, lexeme);
return OID;
} else {
(void) strcpy(yylval.strval, lexeme);
return STRING;
}
default:
(void) strcpy(yylval.strval, lexeme);
return STRING;
}
}
yyerror(err)
char *err;
{
/* Sorry */
(void) fprintf(stderr, "Parse error: ");
(void) fprintf(stderr, err);
(void) fprintf(stderr, "\n");
}
int
issymbol(c)
char c;
{
switch(c) {
case '#':
return 1;
case '"':
return 1;
case '(':
return 1;
case ')':
return 1;
case ':':
return 1;
case '&':
return 1;
case '|':
return 1;
case '!':
return 1;
case '*':
return 1;
case '~':
return 1;
case '=':
return 1;
case '$':
return 1;
case '%':
return 1;
}
return 0;
}
int
iswspace(c)
char c;
{
switch(c) {
case ' ':
return 1;
case '\n':
return 1;
case '\t':
return 1;
}
return 0;
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.