[lbtt] Adjust parser to Bison 2.4.1.

This commit is contained in:
Alexandre Duret-Lutz 2009-05-31 21:26:25 +02:00
parent 352984293a
commit 2cc7c253f1
2 changed files with 76 additions and 66 deletions

View file

@ -1,3 +1,13 @@
2009-05-31 Alexandre Duret-Lutz <adl@gnu.org>
Adjust parser to Bison 2.4.1.
* src/Config-parse.yy (yyerror): Move to the end of the file, to
please newer versions of Bison. With Bison 2.4.1 the various
token used by yyerror() are now defined only after the first
%{...%} block has been emitted (in which yyerror() was previously
defined).
2008-03-13 Alexandre Duret-Lutz <adl@lrde.epita.fr> 2008-03-13 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/main.cc: Include <climits> for LONG_MAX. lbtt won't * src/main.cc: Include <climits> for LONG_MAX. lbtt won't

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009
* Heikki Tauriainen <Heikki.Tauriainen@tkk.fi> * Heikki Tauriainen <Heikki.Tauriainen@tkk.fi>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -94,58 +94,7 @@ extern int yylex(); /* Reads the next token
* the lexer). * the lexer).
*/ */
void yyerror(const char* error_message); /* Fwd. definition. See below. */
/******************************************************************************
*
* Function for reporting parse errors.
*
*****************************************************************************/
/* ========================================================================= */
void yyerror(const char* error_message)
/* ----------------------------------------------------------------------------
*
* Description: Function for reporting parse errors.
*
* Arguments: error_message -- An error message.
*
* Returns: Nothing. Instead, throws a
* Configuration::ConfigurationException initialized with the
* given error message.
*
* ------------------------------------------------------------------------- */
{
const string unknown_token(yytext);
string msg;
switch (expected_token)
{
case CFG_BLOCK_ID :
msg = "`" + unknown_token + "' is not a valid block identifier";
break;
case CFG_OPTION_ID :
if (!unknown_token.empty())
msg = "`" + unknown_token + "' is not a valid option identifier";
else
msg = "'}' expected at the end of block";
break;
case CFG_LBRACE :
msg = "`{' expected after block identifier";
break;
case CFG_EQUALS :
msg = "`=' expected after option identifier";
break;
case CFG_VALUE :
msg = "value for option expected";
break;
default :
msg = error_message;
break;
}
throw Configuration::ConfigurationException(config_file_line_number, msg);
}
%} %}
@ -632,6 +581,57 @@ formula_option: CFG_ABBREVIATEDOPERATORS equals_value
/******************************************************************************
*
* Function for reporting parse errors.
*
*****************************************************************************/
/* ========================================================================= */
void yyerror(const char* error_message)
/* ----------------------------------------------------------------------------
*
* Description: Function for reporting parse errors.
*
* Arguments: error_message -- An error message.
*
* Returns: Nothing. Instead, throws a
* Configuration::ConfigurationException initialized with the
* given error message.
*
* ------------------------------------------------------------------------- */
{
const string unknown_token(yytext);
string msg;
switch (expected_token)
{
case CFG_BLOCK_ID :
msg = "`" + unknown_token + "' is not a valid block identifier";
break;
case CFG_OPTION_ID :
if (!unknown_token.empty())
msg = "`" + unknown_token + "' is not a valid option identifier";
else
msg = "'}' expected at the end of block";
break;
case CFG_LBRACE :
msg = "`{' expected after block identifier";
break;
case CFG_EQUALS :
msg = "`=' expected after option identifier";
break;
case CFG_VALUE :
msg = "value for option expected";
break;
default :
msg = error_message;
break;
}
throw Configuration::ConfigurationException(config_file_line_number, msg);
}
/****************************************************************************** /******************************************************************************
* *
* Main interface to the parser. * Main interface to the parser.