/[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.8 by akim, Sat Jun 15 18:21:46 2002 UTC revision 1.9 by akim, Mon Jun 17 07:04:49 2002 UTC
# Line 80  scanner_last_string_free (void) Line 80  scanner_last_string_free (void)
80  static int braces_level = 0;  static int braces_level = 0;
81  static int percent_percent_count = 0;  static int percent_percent_count = 0;
82    
83  static void handle_dollar PARAMS ((char *cp));  static void handle_dollar PARAMS ((char *cp, location_t location));
84  static void handle_at PARAMS ((char *cp));  static void handle_at PARAMS ((char *cp));
85    
86  %}  %}
# Line 441  blanks   [ \t\f]+ Line 441  blanks   [ \t\f]+
441    
442    "{"           YY_OBS_GROW; braces_level++;    "{"           YY_OBS_GROW; braces_level++;
443    
444    "$"("<"[^>]+">")?(-?[0-9]+|"$") { handle_dollar (yytext); }    "$"("<"[^>]+">")?(-?[0-9]+|"$") { handle_dollar (yytext, *yylloc); }
445    "@"(-?[0-9]+|"$")            { handle_at (yytext); }    "@"(-?[0-9]+|"$")            { handle_at (yytext); }
446    
447    [^$@\[\]/\'\"\{\}\n\r]+ YY_OBS_GROW;    [^$@\[\]/\'\"\{\}\n\r]+ YY_OBS_GROW;
# Line 520  blanks   [ \t\f]+ Line 520  blanks   [ \t\f]+
520  `------------------------------------------------------------------*/  `------------------------------------------------------------------*/
521    
522  static void  static void
523  handle_dollar (char *cp)  handle_dollar (char *cp, location_t location)
524  {  {
525    const char *type_name = NULL;    const char *type_name = NULL;
526    
# Line 529  handle_dollar (char *cp) Line 529  handle_dollar (char *cp)
529       stack.  It is not the same as the rule->length in the case of mid       stack.  It is not the same as the rule->length in the case of mid
530       rule actions.  */       rule actions.  */
531    int rule_length = 0;    int rule_length = 0;
532    symbol_list *rhs;    symbol_list_t *rhs;
533    for (rhs = current_rule->next; rhs; rhs = rhs->next)    for (rhs = current_rule->next; rhs; rhs = rhs->next)
534      ++rule_length;      ++rule_length;
535    
# Line 548  handle_dollar (char *cp) Line 548  handle_dollar (char *cp)
548    if (*cp == '$')    if (*cp == '$')
549      {      {
550        if (!type_name)        if (!type_name)
551          type_name = get_type_name (0, current_rule);          type_name = symbol_list_n_type_name_get (current_rule, location, 0);
552        if (!type_name && typed)        if (!type_name && typed)
553          complain (_("$$ of `%s' has no declared type"),          complain_at (location, _("$$ of `%s' has no declared type"),
554                    current_rule->sym->tag);                       current_rule->sym->tag);
555        if (!type_name)        if (!type_name)
556          type_name = "";          type_name = "";
557        obstack_fgrow1 (&string_obstack,        obstack_fgrow1 (&string_obstack,
# Line 562  handle_dollar (char *cp) Line 562  handle_dollar (char *cp)
562        int n = strtol (cp, &cp, 10);        int n = strtol (cp, &cp, 10);
563    
564        if (n > rule_length)        if (n > rule_length)
565          complain (_("invalid value: %s%d"), "$", n);          complain_at (location, _("invalid value: %s%d"), "$", n);
566        else        else
567          {          {
568            if (!type_name && n > 0)            if (!type_name && n > 0)
569              type_name = get_type_name (n, current_rule);              type_name = symbol_list_n_type_name_get (current_rule, location,
570                                                         n);
571            if (!type_name && typed)            if (!type_name && typed)
572              complain (_("$%d of `%s' has no declared type"),              complain_at (location, _("$%d of `%s' has no declared type"),
573                        n, current_rule->sym->tag);                        n, current_rule->sym->tag);
574            if (!type_name)            if (!type_name)
575              type_name = "";              type_name = "";
# Line 598  handle_at (char *cp) Line 599  handle_at (char *cp)
599       stack.  It is not the same as the rule->length in the case of mid       stack.  It is not the same as the rule->length in the case of mid
600       rule actions.  */       rule actions.  */
601    int rule_length = 0;    int rule_length = 0;
602    symbol_list *rhs;    symbol_list_t *rhs;
603    for (rhs = current_rule->next; rhs; rhs = rhs->next)    for (rhs = current_rule->next; rhs; rhs = rhs->next)
604      ++rule_length;      ++rule_length;
605    

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

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