[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problems with bison-flex
From: |
Jim Michaels |
Subject: |
problems with bison-flex |
Date: |
Fri, 10 Oct 2008 20:18:24 -0700 (PDT) |
am using bison 2.1, flex version 2.5.4 - I have no choice about using anything
newer for now (using gnuwin32), but it would be nice to know if a bug is fixed
in a newer version.
flex is hitting end of file and yyparse always returns 1, error in input.
The last strings in the file is always
0
EOF
which is the tokens ZERO T_EOF. they are expected in the parser.
I even tried returning 0 in yylex when it saw "EOF". no difference.
what do I do?
that covers non-C++ parsing problems I have questions with. I suppose I'll have
the same problems with C++.
do I always need to write a driver for a C++ parser/lexer combo?
I haven't gotten a C++ version of the parser to successfully compile yet. am
using version 2.1 bison.
in the lexer,
%option noyywrap batch yylineno c++
in the .y file,
%locations
%skeleton "lalr1.cc"
do I need to write a C++ driver?
they do that in the C++ example in the bison manual, but I do not know if it is
actually required or not.
you were right environment variable BISON_PKGDATADIR must be set to where the
those m4 files are - this does not appear to be in the documentation.
would appreciate a win32-buildable bison & flex & M4 source using Borland C++
5.5.1 (free) on the Win32 platform or using the Microsoft Visual C++ 2008
compiler *without* using configure scripts, autoconf, and makefile.in, and
possibly without GNU make or other UNIX utilities. there is however, microsoft
and borland versions of make and link, both are named different and either acts
differently than GNU make.
I am a wee bit confused by the code generated way below starting at namespace
yy. maybe it is just old and experimental (2.1).
I am wondering how I can access what used to be yylval. I think it is now
semantic_type.
and what holds the integer token value itself? token_number_type?
how do I call the parser? the parser class is named parser. am I correct in
assuming it's something like
#include "parser.tab.hpp"
int main(void) {
yy:parser p;
int returnValue = p.parse();
}
?
namespace yy
{
class parser;
template <typename P>
struct traits
{
};
template <>
struct traits<parser>
{
typedef unsigned short int token_number_type;
typedef short int rhs_number_type;
typedef int state_type;
typedef YYSTYPE semantic_type;
typedef location location_type;
};
}
namespace yy
{
/// A Bison parser.
class parser
{
/// Symbol semantic values.
typedef traits<parser>::semantic_type semantic_type;
/// Symbol locations.
typedef traits<parser>::location_type location_type;
public:
/// Build a parser object.
parser () :
yydebug_ (false),
yycdebug_ (&std::cerr)
{
}
virtual ~parser ()
{
}
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
#if YYDEBUG
/// A type to store symbol numbers and -1.
typedef traits<parser>::rhs_number_type rhs_number_type;
...
Jim Michaels
address@hidden
http://JesusnJim.com
- problems with bison-flex,
Jim Michaels <=