c++: style: remove useless "inline" and fix space issues

* data/lalr1.cc, data/c++.m4: Formatting changes.
* data/stack.hh: Remove useless "inline".
Add documentation.
* data/location.cc: Prefer {} for empty bodies.
This commit is contained in:
Akim Demaille
2015-08-11 11:18:46 +02:00
parent 009285d20a
commit b809770efb
4 changed files with 19 additions and 25 deletions

View File

@@ -304,7 +304,6 @@ m4_define([b4_public_types_define],
[value = other.value;])[ [value = other.value;])[
} }
template <typename Base> template <typename Base>
inline inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(

View File

@@ -827,7 +827,7 @@ b4_dollar_popdef])[]dnl
yylen = yyr2_[yyn]; yylen = yyr2_[yyn];
{ {
stack_symbol_type yylhs; stack_symbol_type yylhs;
yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([
/* Variants are always initialized to an empty instance of the /* Variants are always initialized to an empty instance of the
correct type. The default '$$ = $1' action is NOT applied correct type. The default '$$ = $1' action is NOT applied
when using variants. */ when using variants. */
@@ -1091,12 +1091,12 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
case N: \ case N: \
yyformat = S; \ yyformat = S; \
break break
YYCASE_(0, YY_("syntax error")); YYCASE_ (0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_ (1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_ #undef YYCASE_
} }

View File

@@ -33,8 +33,7 @@ m4_define([b4_position_define],
: filename (f) : filename (f)
, line (l) , line (l)
, column (c) , column (c)
{ {}
}
]])[ ]])[
/// Initialization. /// Initialization.
@@ -157,15 +156,13 @@ m4_define([b4_location_define],
location (const position& b, const position& e) location (const position& b, const position& e)
: begin (b) : begin (b)
, end (e) , end (e)
{ {}
}
/// Construct a 0-width location in \a p. /// Construct a 0-width location in \a p.
explicit location (const position& p = position ()) explicit location (const position& p = position ())
: begin (p) : begin (p)
, end (p) , end (p)
{ {}
}
/// Construct a 0-width location in \a f, \a l, \a c. /// Construct a 0-width location in \a f, \a l, \a c.
explicit location (]b4_percent_define_get([[filename_type]])[* f, explicit location (]b4_percent_define_get([[filename_type]])[* f,
@@ -173,8 +170,7 @@ m4_define([b4_location_define],
unsigned int c = ]b4_location_initial_column[u) unsigned int c = ]b4_location_initial_column[u)
: begin (f, l, c) : begin (f, l, c)
, end (f, l, c) , end (f, l, c)
{ {}
}
])[ ])[
/// Initialization. /// Initialization.

View File

@@ -21,7 +21,8 @@ m4_pushdef([b4_copyright_years],
# b4_stack_define # b4_stack_define
# --------------- # ---------------
m4_define([b4_stack_define], m4_define([b4_stack_define],
[[ template <class T, class S = std::vector<T> > [[ /// A stack with random access from its top.
template <class T, class S = std::vector<T> >
class stack class stack
{ {
public: public:
@@ -39,14 +40,18 @@ m4_define([b4_stack_define],
: seq_ (n) : seq_ (n)
{} {}
inline /// Random access.
///
/// Index 0 returns the topmost element.
T& T&
operator[] (unsigned int i) operator[] (unsigned int i)
{ {
return seq_[seq_.size () - 1 - i]; return seq_[seq_.size () - 1 - i];
} }
inline /// Random access.
///
/// Index 0 returns the topmost element.
const T& const T&
operator[] (unsigned int i) const operator[] (unsigned int i) const
{ {
@@ -56,7 +61,6 @@ m4_define([b4_stack_define],
/// Steal the contents of \a t. /// Steal the contents of \a t.
/// ///
/// Close to move-semantics. /// Close to move-semantics.
inline
void void
push (T& t) push (T& t)
{ {
@@ -64,7 +68,6 @@ m4_define([b4_stack_define],
operator[](0).move (t); operator[](0).move (t);
} }
inline
void void
pop (unsigned int n = 1) pop (unsigned int n = 1)
{ {
@@ -78,21 +81,18 @@ m4_define([b4_stack_define],
seq_.clear (); seq_.clear ();
} }
inline
typename S::size_type typename S::size_type
size () const size () const
{ {
return seq_.size (); return seq_.size ();
} }
inline
const_iterator const_iterator
begin () const begin () const
{ {
return seq_.rbegin (); return seq_.rbegin ();
} }
inline
const_iterator const_iterator
end () const end () const
{ {
@@ -116,7 +116,6 @@ m4_define([b4_stack_define],
, range_ (range) , range_ (range)
{} {}
inline
const T& const T&
operator [] (unsigned int i) const operator [] (unsigned int i) const
{ {