help-bison
[Top][All Lists]
Advanced

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

Re: $1 of 'whatever' has no declared type


From: Philip Herron
Subject: Re: $1 of 'whatever' has no declared type
Date: Sun, 22 Nov 2009 12:07:35 +0000
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)



Joel E. Denny wrote:
On Sat, 21 Nov 2009, brad wrote:

I have a Bison grammar that I've been working on for a while now, and I never had this problem until I recently upgraded Ubuntu. Now when I try to run the grammar through Bison I get loads of "$1 of 'whatever' has no declared type" errors. Has something recently changed in Bison that breaks old grammars?

You can see my grammar here:
http://gk3tools.svn.sourceforge.net/viewvc/gk3tools/trunk/sheep/sheepParser.y?revision=232&view=markup

I haven't taken the time to try out your grammar, but I took a quick glance and spotted a problem that's been reported before.

You have this:

  #define YYSTYPE SheepCodeTreeNode*

When you set YYSTYPE to a single type as above, then it doesn't make sense to declare semantic types, which are fields of a union YYSTYPE. However, you have this:

%token <id> IDENTIFIER <id> LOCALIDENTIFIER <intVal> INTEGER <floatVal> FLOAT <stringVal> STRING

Bison 2.3 ignored this. Bison 2.3a and later logically assume you want a union when you use a <...> construct. Moreover, POSIX requires the corrected behavior as discussed in the NEWS entry for Bison 2.3a.

You should remove the redundant <...> constructs.

Hey guys,

Chukcing in my $0.02, but i have always found using a:

%union{
char *id;
...
}

Then:

%token <id> IDENTIFIER

or

%type <id> rule_names

So then you don't have to go through your non-terminals or productions assigning types on the fly because it should already be resolved :).

But really its the same idea just different way, though doing #define YYSTYPE is only really ok if you only have one rule return type, but it kind of sucks when you want rules to return different types. But i guess it depends what you want :)

--Phil




reply via email to

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