/* * Copyright (c) Members of the EGEE Collaboration. 2004. * See http://eu-egee.org/partners/ for details on the copyright holders. * For license conditions see the license file or * http://eu-egee.org/license.html */ /* * Copyright (c) 2003 EU DataGrid http://www.eu-datagrid.org/ * * $Id: pdl_yacc.y,v 1.12 2004/10/13 16:37:58 msteenba Exp $ * * Copyright (c) 2003 by * G.M. Venekamp * NIKHEF Amsterdam, the Netherlands * * This software is distributed under a BSD-style open source * licence. For a complete description of the licence take a look * at: http://eu-datagrid.web.cern.ch/eu-datagrid/license.html * */ %{ /* * Copyright (c) 2002 EU DataGrid http://www.eu-datagrid.org/ * * * Author: G.M. Venekamp (venekamp@nikhef.nl) * * * This software is distributed under a BSD-style open source * licence. For a complete description of the licence take a look * at: http://eu-datagrid.web.cern.ch/eu-datagrid/license.html * */ #include #include #include #include #include "pdl.h" #include "ng_log.h" %} %union { record_t* record; rule_t* rule; }; %token LABEL TERM TRANS EMPTYLINE COMMENT PVAR PATH STRING %type config var_list var path policy_list string %type policy rule; %token_table %nonassoc LABEL %% config: /* empty */ { ng_log(LOG_WARNING, "Config file is empty."); } | var_list policy_list | policy_list | var_list { ng_log(LOG_ERR, "Config file contains no policy rules."); yyerror("Empty config file"); } ; var_list: var | var_list var ; var: TERM '=' string { add_variable($1, $3); } | TERM '=' TERM { add_variable($1, $3); } | PVAR '=' path '\n' { set_path($3); } | PVAR '=' { ng_log(LOG_ERR, "No value assigned to path. Using %s as path instead.", pdl_path()); } /* | TERM '=' { ng_log(LOG_ERR, "No value assigned to %s.", $1->string); } | TERM { ng_log(LOG_ERR, "Found a non classified term: %s.", $1->string); } */ ; string: STRING { $$ = $1; } | string STRING { $$ = concat_strings($1, $2); } ; path: PATH { $$ = $1; } | path PATH { $$ = concat_strings($1, $2); } ; policy_list: LABEL policy { add_policy($1, $2); } | policy_list LABEL policy { add_policy($2, $3); } | policy_list LABEL { ng_log(LOG_WARNING, "expecting rule definitions."); ng_log(LOG_WARNING, "no rules specified for policy: '%s' at line %d.", $2->string, $2->lineno); remove_policy($2); } | LABEL { ng_log(LOG_WARNING, "expecting rule definitions."); ng_log(LOG_WARNING, "no rules specified for policy: '%s' at line %d.", $1->string, $1->lineno); remove_policy($1); } ; policy: rule { $$ = $1; } | policy rule { $$ = $1; } ; rule: TERM TRANS TERM { $$ = add_rule($1, $3, 0); } | TERM TRANS TERM '|' TERM { $$ = add_rule($1, $3, $5); } | '~' TERM TRANS TERM { $$ = add_rule($2, 0, $4); } ; %% void set_yylval(record_t* r) { yylval.record = r; }