0

I am totally new to bison an I am confused on many parts but when I tried compiling my code it gave me the error

bison -d Compiler/grammar.y
("Compiler/grammar.y", line 9) error: unrecognized: %define
("Compiler/grammar.y", line 9) error:    Skipping to next %

This is the code:

%{
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int yylex (void);
void yyerror (char const *);
%}

%define api.value.type {double}

%token NAME COLON RIGHT_ARROW LEFT_BRACE RIGHT_BRACE

%start input

%%

input:
    NAME COLON RIGHT_ARROW LEFT_BRACE RIGHT_BRACE

%%

void yyerror(char const *x)
{
    printf("Error %s\n",x)
    exit(1);
}

I checked the documentation and nothing seemed wrong. I am writing in c and using bison version 3.0.4 and flex 2.5.6.

rici
  • 234,347
  • 28
  • 237
  • 341
  • 1
    Are you sure you're using bison 3.0.4? What does `bison --version` print? – rici Mar 14 '17 at 21:06
  • I ask the above because I have the source code for that version of bison handy, and afaics there is nowhere that it generates an error message which looks like that. So I suspect that you are running some other yacc lookalike. – rici Mar 14 '17 at 21:33
  • It prints `GNU Bison version 1.25`. I made sure to delete the folder I made in downloads that stored before installing 3.0.4. Is there anything else I need to change before doing that? – TooBoredToWriteAName Mar 15 '17 at 13:30
  • Far too little information :) I don't even know what OS you are using. Isn't there some prebuilt package for bison? Anyway, I suggest you ask a new question about how to install bison, providing enough information that someone can answer it. – rici Mar 15 '17 at 14:15
  • I am running on windows 10. I have downloaded the .tar.gz version and used 7-zip to extract it onto a folder in my downloads. Upon reinstallation, I deleted the old folder and then downloaded 3.0.4 and repeated the process. – TooBoredToWriteAName Mar 15 '17 at 14:37
  • Sorry, I really know nothing about installing bison on windows, particularly windows 10 which I have never used for any purpose. See my suggestion in the previous comment. – rici Mar 15 '17 at 16:28
  • I looked it up and found this tutorial vid https://www.youtube.com/watch?v=9Y6O5_jsVSQ – TooBoredToWriteAName Mar 17 '17 at 00:29

0 Answers0