c++: coding style fixes

* data/lalr1.cc, tests/c++.at: Formatting changes.
This commit is contained in:
Akim Demaille
2012-09-20 17:16:36 +02:00
parent 0d43e6057b
commit 77a1a208a9
2 changed files with 36 additions and 36 deletions

View File

@@ -66,7 +66,7 @@ typedef std::list<std::string> strings_type;
operator<<(std::ostream& o, const strings_type& s) operator<<(std::ostream& o, const strings_type& s)
{ {
o << '('; o << '(';
for (strings_type::const_iterator i = s.begin(); i != s.end (); ++i) for (strings_type::const_iterator i = s.begin (); i != s.end (); ++i)
{ {
if (i != s.begin ()) if (i != s.begin ())
o << ", "; o << ", ";
@@ -84,7 +84,7 @@ typedef std::list<std::string> strings_type;
{ {
std::ostringstream o; std::ostringstream o;
o << t; o << t;
return o.str(); return o.str ();
} }
} }
@@ -98,7 +98,7 @@ typedef std::list<std::string> strings_type;
// digraph for the left square bracket. // digraph for the left square bracket.
%type <::std::list<std::string>> list result; %type <::std::list<std::string>> list result;
%printer { debug_stream() << $][$; } %printer { yyo << $][$; }
<int> <::std::string> <::std::list<std::string>>; <int> <::std::string> <::std::list<std::string>>;
%% %%
@@ -108,22 +108,22 @@ result:
list: list:
/* nothing */ { /* Generates an empty string list */ } /* nothing */ { /* Generates an empty string list */ }
| list item { std::swap($][$,$][1); $$.push_back($][2); } | list item { std::swap ($][$,$][1); $$.push_back ($][2); }
| list error { std::swap($][$,$][1); } | list error { std::swap ($][$,$][1); }
; ;
item: item:
TEXT { std::swap($][$,$][1); } TEXT { std::swap ($][$,$][1); }
| NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast($][1); } | NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast ($][1); }
; ;
%% %%
#define STAGE_MAX 5 #define STAGE_MAX 5
static static
#if defined USE_LEX_SYMBOL #if defined USE_LEX_SYMBOL
yy::parser::symbol_type yylex() yy::parser::symbol_type yylex ()
#else #else
yy::parser::token_type yylex(yy::parser::semantic_type* yylval, yy::parser::token_type yylex (yy::parser::semantic_type* yylval,
yy::parser::location_type* yylloc) yy::parser::location_type* yylloc)
#endif #endif
{ {
@@ -148,7 +148,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
return yy::parser::make_NUMBER (stage, location_type ()); return yy::parser::make_NUMBER (stage, location_type ());
#else #else
# if defined ONE_STAGE_BUILD # if defined ONE_STAGE_BUILD
yylval->build(stage); yylval->build (stage);
# else # else
yylval->build<int>() = stage; yylval->build<int>() = stage;
# endif # endif
@@ -170,11 +170,11 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
return token::TEXT; return token::TEXT;
#endif #endif
} }
abort(); abort ();
} }
void void
yy::parser::error(const yy::parser::location_type&, yy::parser::error (const yy::parser::location_type&,
const std::string& message) const std::string& message)
{ {
std::cerr << message << std::endl; std::cerr << message << std::endl;
@@ -184,8 +184,8 @@ int
main () main ()
{ {
yy::parser p; yy::parser p;
p.set_debug_level(!!getenv("YYDEBUG")); p.set_debug_level (!!getenv ("YYDEBUG"));
return p.parse(); return p.parse ();
} }
]]) ]])
@@ -487,7 +487,7 @@ item:
'a' 'a'
| 's' | 's'
{ {
throw yy::parser::syntax_error("invalid expression"); throw yy::parser::syntax_error ("invalid expression");
} }
%% %%
@@ -500,7 +500,7 @@ yylex (yy::parser::semantic_type *)
switch (int res = *input++) switch (int res = *input++)
{ {
case 'l': case 'l':
throw yy::parser::syntax_error("invalid character"); throw yy::parser::syntax_error ("invalid character");
default: default:
return res; return res;
} }
@@ -516,7 +516,7 @@ int
main () main ()
{ {
yy::parser parser; yy::parser parser;
parser.set_debug_level(!!getenv("YYDEBUG")); parser.set_debug_level (!!getenv ("YYDEBUG"));
return parser.parse (); return parser.parse ();
} }
]]) ]])