help-bison
[Top][All Lists]
Advanced

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

RE: Bison error on yacc code


From: Olivier Nallet
Subject: RE: Bison error on yacc code
Date: Wed, 19 Nov 2003 20:18:54 -0500

It seems that the default action { $$ = $1; } was not executed in the old
version.

$$ is replace by the rule, in your case Code. And $1 is replaced by the
first input rule.

%token <token> ENDTOKEN
        Implies that ENDTOKEN is type 'token'.

But as you can see, there is no %token <token> Code     so Code is not typed.
So you got type incompatibility between '' and 'token'.

It seems that the best thing to do here is just modify to:

Code:   Label Instruction  ENDTOKEN
        { Wrap_instr(); }
        | Instruction ENDTOKEN
        { Wrap_instr(); }
        | ENDTOKEN
        {}      //      Added an empty action
        ;

You'll certainly have this kind of error in a lot of place in your old
grammar. ;)

Cheers,
Olivier

-----Message d'origine-----
De : address@hidden
[mailto:address@hidden la part de
Gordon (Jake) Jacobs
Envoye : mercredi 19 novembre 2003 14:13
A : address@hidden
Cc : Jacobs, Gordon
Objet : Bison error on yacc code


Hi,
  I'm trying to port some 10-year-old code to a RedHat Linux8
machine. The code compiles fine on SUN using lex/yacc. I get
many compile errors on the Linux machine so I thought I would try
flex/bison. When running bison 1.35 on my yacc code, I get the following
error:
ndwi 715 % bison asmYacc.y
asmYacc.y:46: type clash (`' `token') on default action

The top of the yacc code is included below and the error is very
near the top (highlighted) on a very basic rule. Can anyone explain the
error message in a little more detail or see why it would occur?
The same error occurs on the SUN machine using bison 1.28 too by the
way,
so it is not a platform issue, but rather a yacc compatibility issue.

Any help appreciated.
Regards,
Gordon Jacobs
Oakland, CA

/*
 *      @(#)asmYacc.y   1.6
 *      Date: 94/05/04   Time: 15:17:29
 *      Version: 1.6
 *
 */

%{

#include "asm.h"
static int panic,error;
extern int encode_keyword();

%}
%token <token> INTTOKEN KEYWORD SUBTOKEN SHFTTOKEN ENDTOKEN
%token <character> CHARTOKEN LABELTOKEN

%type <character> Destinations

%start Asm

%union {
    int token;
    char *character;
}

%%

Asm:    Codes
        {
          Reconcile_labels();
          Print_table(lookup, fpout);
          Print_table(lookup, fplst);
          Print_program();
          Print_ROM_CODE();
        }
        ;
Codes:  Code
        | Codes Code
        ;
Code:   Label Instruction  ENDTOKEN
        { Wrap_instr(); }
        | Instruction ENDTOKEN
        { Wrap_instr(); }
        | ENDTOKEN
        ;                 <- error occurs here, line 46
Label:  LABELTOKEN
        {  etc....


_______________________________________________
address@hidden http://mail.gnu.org/mailman/listinfo/help-bison





reply via email to

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