/[anubis]/anubis/src/rcfile.y
ViewVC logotype

Diff of /anubis/src/rcfile.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by gray, Mon Mar 3 07:42:49 2003 UTC revision 1.10 by gray, Thu Mar 6 18:48:35 2003 UTC
# Line 78  static int debug_level; Line 78  static int debug_level;
78                  int part;                  int part;
79                  char *key;                  char *key;
80          } msgpart;          } msgpart;
81            struct list *list;
82  };  };
83    
84  %token EOL T_BEGIN T_END AND OR  %token EOL T_BEGIN T_END AND OR
# Line 90  static int debug_level; Line 91  static int debug_level;
91  %left AND  %left AND
92  %left NOT  %left NOT
93    
94  %type <string> begin keyword string option opt_key  %type <string> begin keyword string option opt_key arg
95  %type <section> section seclist  %type <section> section seclist
96  %type <stmtlist> stmtlist  %type <stmtlist> stmtlist
97  %type <stmt> stmt asgn_stmt cond_stmt rule_stmt inst_stmt  %type <stmt> stmt asgn_stmt cond_stmt rule_stmt inst_stmt
98  %type <num> optlist  %type <num> optlist
99  %type <node> rule_start cond expr  %type <node> rule_start cond expr
100  %type <msgpart> msgpart  %type <msgpart> msgpart
101    %type <list> arglist
102    
103  %%  %%
104    
# Line 134  section  : /* empty */ EOL Line 136  section  : /* empty */ EOL
136             }             }
137           ;           ;
138    
139  begin    : T_BEGIN { verbatim(); } STRING EOL  begin    : T_BEGIN { verbatim(); } string EOL
140             {             {
141                     $$ = $3;                     $$ = $3;
142             }             }
# Line 171  stmt     : /* empty */ EOL Line 173  stmt     : /* empty */ EOL
173           | inst_stmt EOL           | inst_stmt EOL
174           ;           ;
175    
176  asgn_stmt: keyword '=' { verbatim(); } STRING  asgn_stmt: keyword meq { verbatim(); } arglist
177             {             {
178                     $$ = rc_stmt_create(rc_stmt_asgn);                     $$ = rc_stmt_create(rc_stmt_asgn);
179                     $$->v.asgn.lhs = $1;                     $$->v.asgn.lhs = $1;
# Line 182  asgn_stmt: keyword '=' { verbatim(); } S Line 184  asgn_stmt: keyword '=' { verbatim(); } S
184  keyword  : IDENT  keyword  : IDENT
185           ;           ;
186    
187    arglist  : arg
188               {
189                       $$ = list_create();
190                       list_append($$, $1);
191               }
192             | arglist arg
193               {
194                       list_append($1, $2);
195                       $$ = $1;
196               }
197             ;
198    
199    arg      : string
200             ;
201    
202  cond_stmt: if cond stmtlist fi  cond_stmt: if cond stmtlist fi
203             {             {
204                     $$ = rc_stmt_create(rc_stmt_cond);                     $$ = rc_stmt_create(rc_stmt_cond);
# Line 374  yyerror(char *s) Line 391  yyerror(char *s)
391  {  {
392          anubis_error(SOFT, "%s:%d: %s",          anubis_error(SOFT, "%s:%d: %s",
393                       cfg_file, cfg_line_num, s);                       cfg_file, cfg_line_num, s);
394            return 0;
395  }  }
396    
397  RC_SECTION *  RC_SECTION *
# Line 467  rc_section_link(RC_SECTION **ap, RC_SECT Line 485  rc_section_link(RC_SECTION **ap, RC_SECT
485  }  }
486    
487  /* Assignment manipulations */  /* Assignment manipulations */
488    
489    static int
490    _free_mem(void *item, void *data)
491    {
492            free(item);
493            return 0;
494    }
495    
496  void  void
497  rc_asgn_destroy(RC_ASGN *asgn)  rc_asgn_destroy(RC_ASGN *asgn)
498  {  {
499          xfree(asgn->lhs);          xfree(asgn->lhs);
500          xfree(asgn->rhs);          list_destroy(&asgn->rhs, _free_mem, NULL);
501  }  }
502    
503  /* Bools */  /* Bools */
# Line 687  rc_level_print(int level, char *str) Line 713  rc_level_print(int level, char *str)
713          printf("%s", str);          printf("%s", str);
714  }  }
715    
716    static int
717    _print_str(void *item, void *data)
718    {
719            printf(" %s", (char*)item);
720            return 0;
721    }
722    
723  void  void
724  rc_stmt_print(RC_STMT *stmt, int level)  rc_stmt_print(RC_STMT *stmt, int level)
725  {  {
# Line 694  rc_stmt_print(RC_STMT *stmt, int level) Line 727  rc_stmt_print(RC_STMT *stmt, int level)
727                  switch (stmt->type) {                  switch (stmt->type) {
728                  case rc_stmt_asgn:                  case rc_stmt_asgn:
729                          rc_level_print(level, "ASGN: ");                          rc_level_print(level, "ASGN: ");
730                          printf("%s = %s",                          printf("%s =", stmt->v.asgn.lhs);
731                                 stmt->v.asgn.lhs, stmt->v.asgn.rhs);                          list_iterate(stmt->v.asgn.rhs, _print_str, NULL);
732                          break;                          break;
733                                                    
734                  case rc_stmt_cond:                  case rc_stmt_cond:
# Line 861  void Line 894  void
894  asgn_eval(struct eval_env *env, RC_ASGN *asgn)  asgn_eval(struct eval_env *env, RC_ASGN *asgn)
895  {  {
896          int key;          int key;
         char *str;  
897          struct rc_secdef_child *p = rc_child_lookup(env->child, asgn->lhs,          struct rc_secdef_child *p = rc_child_lookup(env->child, asgn->lhs,
898                                                      env->method, &key);                                                      env->method, &key);
899          if (!p)          if (!p)
900                  return;                  return;
901          if (env->refstr)  
902                  str = substitute(asgn->rhs, env->refstr);          if (env->refstr) {
903          else                  char *s;
904                  str = asgn->rhs;                  struct list *arg = list_create();
905          p->parser(env->method, key, str, p->data, env->data, env->msg);                  for (s = list_first(asgn->rhs); s; s = list_next(asgn->rhs)) {
906                            char *str = substitute(s, env->refstr);
907                            list_append(arg, str);
908                    }
909                    p->parser(env->method, key, arg, p->data, env->data, env->msg);
910                    list_destroy(&arg, _free_mem, NULL);
911            } else
912                    p->parser(env->method, key, asgn->rhs, p->data, env->data,
913                              env->msg);
914  }  }
915    
916    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26