[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Visual C++ update
From: |
Stark Mathews |
Subject: |
Visual C++ update |
Date: |
Thu, 25 Oct 2001 21:45:45 -0400 |
Here is the new code. Sorry about spamming like this:
/*BEGIN BISON PARSER SECTION */
%{
#define YYSTYPE int
int yylex();
void yyerror(char *error);
#include <math.h>
#include <MALLOC.h>
%}
%token NUM
%left '+' '-'
%left '*' '/'
%left NEGATE
%right '^'
%%
input: /* empty */;
input: input line;
line: '\n' { printf("ping.\n"); };
line: exp '\n' { printf("result: %d\n", $1); };
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 { $$ = (int)pow($1, $3); };
%%
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <conio.h>
int yylex(){
int result = ' ';
while (result == ' ' || result == '\t') result = getchar();
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();
};
I have gotten this to compile and run, but nothing is printed to the screen
except what I type. Why is this process so easy for Linux users?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Visual C++ update,
Stark Mathews <=