/[bison]/bison/src/scan-gram.l
ViewVC logotype

Diff of /bison/src/scan-gram.l

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

revision 1.13 by akim, Thu Jun 20 07:19:13 2002 UTC revision 1.14 by akim, Thu Jun 20 09:08:37 2002 UTC
# Line 136  blanks   [ \t\f]+ Line 136  blanks   [ \t\f]+
136    "%nterm"                return PERCENT_NTERM;    "%nterm"                return PERCENT_NTERM;
137    "%output"               return PERCENT_OUTPUT;    "%output"               return PERCENT_OUTPUT;
138    "%prec"                 return PERCENT_PREC;    "%prec"                 return PERCENT_PREC;
139      "%printer"              return PERCENT_PRINTER;
140    "%pure"[-_]"parser"     return PERCENT_PURE_PARSER;    "%pure"[-_]"parser"     return PERCENT_PURE_PARSER;
141    "%right"                return PERCENT_RIGHT;    "%right"                return PERCENT_RIGHT;
142    "%skeleton"             return PERCENT_SKELETON;    "%skeleton"             return PERCENT_SKELETON;
# Line 524  blanks   [ \t\f]+ Line 525  blanks   [ \t\f]+
525  %%  %%
526    
527  /*------------------------------------------------------------------.  /*------------------------------------------------------------------.
528  | CP is pointing to a wannabee semantic value (i.e., a `$').        |  | TEXT is pointing to a wannabee semantic value (i.e., a `$').      |
529  |                                                                   |  |                                                                   |
530  | Possible inputs: $[<TYPENAME>]($|integer)                         |  | Possible inputs: $[<TYPENAME>]($|integer)                         |
531  |                                                                   |  |                                                                   |
# Line 532  blanks   [ \t\f]+ Line 533  blanks   [ \t\f]+
533  `------------------------------------------------------------------*/  `------------------------------------------------------------------*/
534    
535  static inline void  static inline void
536  handle_action_dollar (char *cp, location_t location)  handle_action_dollar (char *text, location_t location)
537  {  {
538    const char *type_name = NULL;    const char *type_name = NULL;
539      char *cp = text + 1;
   ++cp;  
540    
541    /* Get the type name if explicit. */    /* Get the type name if explicit. */
542    if (*cp == '<')    if (*cp == '<')
# Line 588  handle_action_dollar (char *cp, location Line 588  handle_action_dollar (char *cp, location
588      }      }
589    else    else
590      {      {
591        char buf[] = "$c";        complain_at (location, _("%s is invalid"), quote (text));
       buf[1] = *cp;  
       complain_at (location, _("%s is invalid"), quote (buf));  
592      }      }
593  }  }
594    
595    
596  /*---------------------------------------.  /*---------------------------------------------------------------.
597  | CP is pointing to $$ in a destructor.  |  | TEXT is expexted tp be $$ in some code associated to a symbol: |
598  `---------------------------------------*/  | destructor or printer.                                         |
599    `---------------------------------------------------------------*/
600    
601  static inline void  static inline void
602  handle_destructor_dollar (char *cp, location_t location)  handle_symbol_code_dollar (char *text, location_t location)
603  {  {
604    ++cp;    char *cp = text + 1;
605    if (*cp == '$')    if (*cp == '$')
606      {      obstack_sgrow (&string_obstack, "]b4_dollar_dollar[");
       obstack_sgrow (&string_obstack, "]b4_dollar_dollar[");  
     }  
607    else    else
608      {      complain_at (location, _("%s is invalid"), quote (text));
       char buf[] = "$c";  
       buf[1] = *cp;  
       complain_at (location, _("%s is invalid"), quote (buf));  
     }  
609  }  }
610    
611    
# Line 632  handle_dollar (braced_code_t braced_code Line 625  handle_dollar (braced_code_t braced_code
625        break;        break;
626    
627      case destructor_braced_code:      case destructor_braced_code:
628        handle_destructor_dollar (text, location);      case printer_braced_code:
629          handle_symbol_code_dollar (text, location);
630        break;        break;
631      }      }
632  }  }
# Line 646  handle_dollar (braced_code_t braced_code Line 640  handle_dollar (braced_code_t braced_code
640  static inline void  static inline void
641  handle_action_at (char *text, location_t location)  handle_action_at (char *text, location_t location)
642  {  {
643      char *cp = text + 1;
644    locations_flag = 1;    locations_flag = 1;
   ++text;  
645    
646    if (*text == '$')    if (*cp == '$')
647      {      {
648        obstack_sgrow (&string_obstack, "]b4_lhs_location[");        obstack_sgrow (&string_obstack, "]b4_lhs_location[");
649      }      }
650    else if (isdigit (*text) || *text == '-')    else if (isdigit (*cp) || *cp == '-')
651      {      {
652        /* RULE_LENGTH is the number of values in the current rule so        /* RULE_LENGTH is the number of values in the current rule so
653           far, which says where to find `$0' with respect to the top of           far, which says where to find `$0' with respect to the top of
654           the stack.  It is not the same as the rule->length in the           the stack.  It is not the same as the rule->length in the
655           case of mid rule actions.  */           case of mid rule actions.  */
656        int rule_length = symbol_list_length (current_rule->next);        int rule_length = symbol_list_length (current_rule->next);
657        int n = strtol (text, &text, 10);        int n = strtol (cp, &cp, 10);
658    
659        if (n > rule_length)        if (n > rule_length)
660          complain_at (location, _("invalid value: %s%d"), "@", n);          complain_at (location, _("invalid value: %s%d"), "@", n);
# Line 670  handle_action_at (char *text, location_t Line 664  handle_action_at (char *text, location_t
664      }      }
665    else    else
666      {      {
667        char buf[] = "@c";        complain_at (location, _("%s is invalid"), quote (text));
       buf[1] = *text;  
       complain_at (location, _("%s is invalid"), quote (buf));  
668      }      }
669  }  }
670    
671    
672  /*--------------------------------------------.  /*---------------------------------------------------------------.
673  | TEXT is expexted tp be @$ in a destructor.  |  | TEXT is expexted tp be @$ in some code associated to a symbol: |
674  `--------------------------------------------*/  | destructor or printer.                                         |
675    `---------------------------------------------------------------*/
676    
677  static inline void  static inline void
678  handle_destructor_at (char *text, location_t location)  handle_symbol_code_at (char *text, location_t location)
679  {  {
680    ++text;    char *cp = text + 1;
681    if (*text == '$')    if (*cp == '$')
682      {      obstack_sgrow (&string_obstack, "]b4_at_dollar[");
       obstack_sgrow (&string_obstack, "]b4_at_dollar[");  
     }  
683    else    else
684      {      complain_at (location, _("%s is invalid"), quote (text));
       char buf[] = "$c";  
       buf[1] = *text;  
       complain_at (location, _("%s is invalid"), quote (buf));  
     }  
685  }  }
686    
687    
# Line 714  handle_at (braced_code_t braced_code_kin Line 701  handle_at (braced_code_t braced_code_kin
701        break;        break;
702    
703      case destructor_braced_code:      case destructor_braced_code:
704        handle_destructor_at (text, location);      case printer_braced_code:
705          handle_symbol_code_at (text, location);
706        break;        break;
707      }      }
708  }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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