[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yacc compatibility bug
From: |
Vol Litwr |
Subject: |
Re: yacc compatibility bug |
Date: |
Wed, 2 Nov 2011 11:21:58 +0300 |
Thank you! I use yacc - 1.9 20090221 (this is shown with -V option). I
find the behaviors of *my* ;-) yacc more convinient than bison. Bison
behaviours also cause stupid problem of necessity of forward
declaration of the function like yylex or yyerror between %{ %} if
code is compiled with g++. IMHO It is much better to put generated
code of yyparse to the end of text... Does it conflict with POSIX?
%{
#include <cctype>
#include <iostream>
//int yylex(), yyerror(); //necessity for bison & c++
%}
%token DIGIT
%left '+'
%%
list:
| list '\n'
| list expr '\n' {cout << $2 << endl;}
;
expr: DIGIT
| expr '+' expr {$$ = $1 + $3;}
;
%%
int yylex () {
int c;
if (isdigit(c)) {
yylval = c - '0';
return DIGIT;
}
return c;
}
int yyerror() {}
main () {
yyparse();
}
- Re: yacc compatibility bug,
Vol Litwr <=