OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_spec_parse.y versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_spec_parse.y 1.1 -> 1.2

--- 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  <chChannel> stream
-%type  <chChannel> streams
-%type  <chChannel> channel
-%type  <chChannel> channel_spec
-%type  <nLevels>   channel_mask
-%type  <nLevels>   channel_levels
+    /* assign YYSTYPE elements to parser rules */
+%type <chChannel> stream
+%type <chChannel> streams
+%type <chChannel> channel
+%type <chChannel> channel_spec
+%type <nLevels>   channel_mask
+%type <nLevels>   channel_levels
+
+    /* list of scanner tokens */
+%token <cpValue>  T_ID
+%token <cpValue>  T_STRING
+%token            T_OP_ARROW
 
-%token <cpValue>   T_ID
-%token <cpValue>   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
                  { 
-                     $$ = $<chChannel>2;
+                     $$ = $<chChannel>2; /* pass result */
                      CTX->chTmp = NULL;
                  }
                ;
 
+               /* channel parameters */
 channel_params : /* empty */
                | '(' channel_param_list ')'
                ;

CVSTrac 2.0.1