[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] lalr1.cc: factor the yytranslate_ invocation in make_SYMBOLS.
From: |
Akim Demaille |
Subject: |
[PATCH] lalr1.cc: factor the yytranslate_ invocation in make_SYMBOLS. |
Date: |
Wed, 16 Sep 2009 17:50:06 +0200 |
* data/c++.m4, data/lalr1.cc (parser::symbol_type): Change the
constructor to take a token_type instead of the (internal) symbol
number.
Call yytranslate_.
* data/variant.hh (b4_symbol_constructor_define_): Therefore,
don't call yytranslate_ here.
This factors loads of repeated code. In my case for instance, I have,
in the generated parser:
// Implementation of make_symbol for each symbol type.
parser::symbol_type
parser::make_EOF (const location_type& l)
{
return symbol_type (yytranslate_ (token::TOK_EOF), l);
}
parser::symbol_type
parser::make___HERE__ (const location_type& l)
{
return symbol_type (yytranslate_ (token::TOK___HERE__), l);
}
parser::symbol_type
parser::make_EQ (const location_type& l)
{
return symbol_type (yytranslate_ (token::TOK_EQ), l);
}
parser::symbol_type
parser::make_BREAK (const location_type& l)
{
return symbol_type (yytranslate_ (token::TOK_BREAK), l);
}
parser::symbol_type
parser::make_CASE (const location_type& l)
{
return symbol_type (yytranslate_ (token::TOK_CASE), l);
}
it now reads:
// Implementation of make_symbol for each symbol type.
parser::symbol_type
parser::make_EOF (const location_type& l)
{
return symbol_type (token::TOK_EOF, l);
}
parser::symbol_type
parser::make___HERE__ (const location_type& l)
{
return symbol_type (token::TOK___HERE__, l);
}
parser::symbol_type
parser::make_EQ (const location_type& l)
{
return symbol_type (token::TOK_EQ, l);
}
parser::symbol_type
parser::make_BREAK (const location_type& l)
{
return symbol_type (token::TOK_BREAK, l);
}
parser::symbol_type
parser::make_CASE (const location_type& l)
{
return symbol_type (token::TOK_CASE, l);
}
I suppose it does have an impact of the object file, but I have not
checked.
0001-lalr1.cc-factor-the-yytranslate_-invocation-in-make_.txt
Description: Text document
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] lalr1.cc: factor the yytranslate_ invocation in make_SYMBOLS.,
Akim Demaille <=