Index: ossp-pkg/l2/l2_spec_parse.y RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_spec_parse.y,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/l2/l2_spec_parse.y,v' 2>/dev/null --- l2_spec_parse.y 2001/11/07 16:17:09 1.1 +++ l2_spec_parse.y 2001/11/07 17:01:05 1.2 @@ -30,8 +30,7 @@ ** ATTENTION: This requires GNU Bison 1.30 or newer! */ -#include "l2.h" /* for l2_xxx() */ -#include "l2_p.h" /* for l2_channel_t and l2_env_t internals */ +#include "l2.h" /* for l2_xxx() API */ #include "l2_spec.h" /* for l2_spec_ctx_t */ /* make sure yyparse() accepts a context pointer and @@ -40,51 +39,59 @@ #define YYPARSE_PARAM ctx #define YYLEX_PARAM CTX->yyscan -/* provide an explicit prototype for the yylex() function */ +/* provide an explicit prototype for the yylex() function but use + "void *" instead of correct type because at this point in the + generation process we have the types still not available */ extern int yylex(/*YYSTYPE*/ void *lvalp, /*YYLTYPE*/ void *llocp, l2_spec_ctx_t *ctx); /* generate verbose error messages and remember them inside the context */ #undef yyerror #define yyerror(msg) \ - do { \ - l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", msg); \ - CTX->rv = L2_ERR_ARG; \ - } while (0) + do { l2_env_errorinfo(CTX->env, L2_ERR_ARG, "%s", msg); \ + CTX->rv = L2_ERR_ARG; } while (0) #define YYERROR_VERBOSE - -#define YYDEBUG 1 %} + /* parser options */ %pure_parser %locations %defines + /* the YYSTYPE: parser token value */ %union { char *cpValue; l2_channel_t *chChannel; unsigned int nLevels; } -%type stream -%type streams -%type channel -%type channel_spec -%type channel_mask -%type channel_levels + /* assign YYSTYPE elements to parser rules */ +%type stream +%type streams +%type channel +%type channel_spec +%type channel_mask +%type channel_levels + + /* list of scanner tokens */ +%token T_ID +%token T_STRING +%token T_OP_ARROW -%token T_ID -%token T_STRING + /* operator association */ +%right T_OP_ARROW -%token T_OP_ARROW -%left T_OP_ARROW + /* grammar start rule */ +%start tree %% -root : stream + /* channel tree */ +tree : stream { CTX->ch = $1; } ; + /* stream of channels */ stream : channel { $$ = $1; @@ -93,9 +100,7 @@ { $$ = $1; if ((CTX->rv = l2_channel_link($1, L2_LINK_CHILD, $3, NULL)) != L2_OK) { - l2_env_errorinfo(CTX->env, CTX->rv, - "unable to link parent '%s' with child '%s'", - $1->handler.name, $3->handler.name); + l2_env_errorinfo(CTX->env, CTX->rv, "unable to link parent with child"); YYERROR; } } @@ -103,20 +108,20 @@ { $$ = $1; if ((CTX->rv = l2_channel_link($1, L2_LINK_CHILD, $4, NULL)) != L2_OK) { - l2_env_errorinfo(CTX->env, CTX->rv, - "unable to link parent '%s' with child list", - $1->handler.name); + l2_env_errorinfo(CTX->env, CTX->rv, "unable to link parent with child list"); YYERROR; } } ; + /* list of sibling streams */ streams : stream { $$ = $1; } | stream ';' streams { $$ = $1; l2_channel_link($1, L2_LINK_SIBLING, $3, NULL); } ; + /* single channel */ channel : channel_mask '/' channel_mask ':' channel_spec { $$ = $5; l2_channel_levels($5, $1, $3); } | channel_mask ':' channel_spec @@ -125,6 +130,7 @@ { $$ = $1; } ; + /* channel write or flush mask */ channel_mask : T_ID { unsigned int levelmask; @@ -135,9 +141,12 @@ $$ = L2_LEVEL_UPTO(levelmask); } | '(' channel_levels ')' - { $$ = $2; } + { + $$ = $2; + } ; + /* list of channels in a mask */ channel_levels : T_ID { unsigned int levelmask; @@ -158,6 +167,7 @@ } ; + /* specifcation of a single channel */ channel_spec : T_ID { l2_channel_t *ch; @@ -175,11 +185,12 @@ } channel_params { - $$ = $2; + $$ = $2; /* pass result */ CTX->chTmp = NULL; } ; + /* channel parameters */ channel_params : /* empty */ | '(' channel_param_list ')' ;