bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

assert failure at line 1896


From: Derek M Jones
Subject: assert failure at line 1896
Date: Sat, 20 May 2006 20:53:52 +0100
User-agent: Thunderbird 1.5 (Windows/20051201)

All,

Using Bison 2.2 the grammar below generates an assert failure at
line 1896 of the generated .tab.c file.  There are also various
warnings about argument 3 being an incompatible pointer type (the
more obvious fix).

%glr-parser

%token
INT
ID

%{
#include <ctype.h>
#include <stdio.h>

static const char *input = "a b c (( d ));";

#define YYSTYPE char *
#define YYDEBUG 1


static void yyerror (const char *s)
{
  printf ("%s\n", s);
}

static int yylex (void);
%}

%%

TU:
        translation_unit
        { }                   ;

translation_unit:
              external_declaration  %dprec 1
              { }        ;

declaration:
              declaration_specifiers                      ';' %dprec 1
              { }                                           |
              declaration_specifiers init_declarator_list ';' %dprec 2
              { }                                           ;

decl_specifier:
              typedef_name
              { }            ;

declaration_specifiers:
              decl_specifier
              { }            |
              declaration_specifiers decl_specifier
              { }            ;

init_declarator_list:
              declarator
              { }                    ;

pointer_opt:
              { }          |
              '*'
              { } ;
declarator:
              pointer_opt direct_declarator
              { } ;

direct_declarator:
              ID       %dprec 2
              { }                |
              '(' declarator ')'
              { }                |
              direct_declarator '(' parameter_type_list ')' %dprec 2
              { }                |
              direct_declarator '(' '(' parameter_type_list ')' ')'
              { }                ;

parameter_type_list:
              declaration_specifiers declarator          %dprec 2
              { }              |
              declaration_specifiers                     %dprec 1
              { }              ;

typedef_name:
              ID
              { } ;

external_declaration:
              declaration
              { }     ;

%%

static int yylex (void)
{
char c;

c = (*input ? *input++ : 0);

while (isspace(c))
   c = *input++;

asprintf (&yylval, "%c", c);
printf("> %c\n",  c);
return (c == 'I') ? INT : (isalpha(c) ? ID : c);
}

int main (void)
{
yydebug=1;

printf ("%i\n", yyparse ());
}

--
Derek M. Jones                              tel: +44 (0) 1252 520 667
Knowledge Software Ltd                      mailto:address@hidden
Applications Standards Conformance Testing    http://www.knosof.co.uk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]