help-bison
[Top][All Lists]
Advanced

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

Re: Visual C++


From: Hozefa_Botee
Subject: Re: Visual C++
Date: Thu, 25 Oct 2001 10:24:37 -0700

i think you have to #define MSDOS for the windows port.
otherwise the correct headers don't get included.
H




"Stark Mathews" <address@hidden>@gnu.org on 10/25/2001 08:52:59 AM

Sent by:  address@hidden


To:   <address@hidden>
cc:
Subject:  Visual C++

Okay. To start, I am using a Win32 port of Bison, which when run with
the --version flag returns

GNU Bison version 1.24

For simplicity's sake I have made a small test program, which is very
similar to the Infix Notation Calculator example in the bison.texinfo file.
Here is the original file before it is parsed. Is it possible to find my
error from this?

                                                              Thank you for
your time.

/*BEGIN BISON PARSER SECTION */

%{
  #define YYSTYPE int

  #include <math.h>
%}

%token NUM
%left '+' '-'
%left '*' '/'
%left NEGATE
%right '^'

%%
exp: NUM                                  { $$ = $1; };
exp: exp '+' exp            { $$ = $1 + $3; };
exp: exp '-' exp                    { $$ = $1 - $3; };
exp: exp '*' exp                                     { $$ = $1 * $3; };
exp: exp '/' exp                                     { $$ = $1 / $3; };
exp: '-' exp %prec NEGATE   { $$ = -$1; };
exp: exp '^' exp            { $$ = pow($1, $3); };
%%

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <MALLOC.h>
#include <ctype.h>
#include <conio.h>

yylex(){
  char result;

  while (result == ' ' || result == '\t') result = getch();

  if (isdigit(result)){
    ungetch(result);
    scanf("%d", &yylval);
    return NUM;
  }

  if (result == '^') return 0;

  return result;
};

void yyerror(char *error){
  printf(error);
};


/*END BISON PARSER SECTION*/

void main(void){
  yyparse();
};


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







reply via email to

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