bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] c++: coding style fixes


From: Akim Demaille
Subject: [PATCH 1/2] c++: coding style fixes
Date: Fri, 21 Sep 2012 09:50:29 +0200

* data/lalr1.cc, tests/c++.at: Formatting changes.
---
 data/lalr1.cc | 34 +++++++++++++++++-----------------
 tests/c++.at  | 38 +++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/data/lalr1.cc b/data/lalr1.cc
index d6ea50b..75eaf57 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -721,20 +721,20 @@ b4_dollar_popdef])[]dnl
       {
         YYCDEBUG << "Reading a token: ";
         try
-        {
+          {
 ]b4_lex_symbol_if(
-[          yyla = b4_function_call([yylex], [symbol_type],
+[            yyla = b4_function_call([yylex], [symbol_type],
                                      m4_ifdef([b4_lex_param], b4_lex_param));],
-[          yyla.type = yytranslate_ (b4_function_call([yylex], [int],
+[            yyla.type = yytranslate_ (b4_function_call([yylex], [int],
                                      [b4_api_PREFIX[STYPE*], 
[&yyla.value]][]dnl
 b4_locations_if([, [[location*], [&yyla.location]]])dnl
 m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
-        }
+          }
         catch (const syntax_error& yyexc)
-        {
-          error (yyexc);
-          goto yyerrlab1;
-        }
+          {
+            error (yyexc);
+            goto yyerrlab1;
+          }
         yyempty = false;
       }
     YY_SYMBOL_PRINT ("Next token is", yyla);
@@ -807,19 +807,19 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
     // Perform the reduction.
     YY_REDUCE_PRINT (yyn);
     try
-    {
-      switch (yyn)
       {
+        switch (yyn)
+          {
 ]b4_user_actions[
-        default:
-          break;
+          default:
+            break;
+          }
       }
-    }
     catch (const syntax_error& yyexc)
-    {
-      error (yyexc);
-      YYERROR;
-    }
+      {
+        error (yyexc);
+        YYERROR;
+      }
     YY_SYMBOL_PRINT ("-> $$ =", yylhs);
 ]b4_variant_if([[
     // Destroy the rhs symbols.
diff --git a/tests/c++.at b/tests/c++.at
index 155f2de..288ff86 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -66,7 +66,7 @@ typedef std::list<std::string> strings_type;
     operator<<(std::ostream& o, const strings_type& s)
     {
       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 ())
             o << ", ";
@@ -84,7 +84,7 @@ typedef std::list<std::string> strings_type;
   {
     std::ostringstream o;
     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.
 %type <::std::list<std::string>> list result;
 
-%printer { debug_stream() << $][$; }
+%printer { yyo << $][$; }
   <int> <::std::string> <::std::list<std::string>>;
 %%
 
@@ -108,23 +108,23 @@ result:
 
 list:
   /* nothing */ { /* Generates an empty string list */ }
-| list item     { std::swap($][$,$][1); $$.push_back($][2); }
-| list error    { std::swap($][$,$][1); }
+| list item     { std::swap ($][$,$][1); $$.push_back ($][2); }
+| list error    { std::swap ($][$,$][1); }
 ;
 
 item:
-  TEXT          { std::swap($][$,$][1); }
-| NUMBER        { if ($][1 == 3) YYERROR; else $][$ = string_cast($][1); }
+  TEXT          { std::swap ($][$,$][1); }
+| NUMBER        { if ($][1 == 3) YYERROR; else $][$ = string_cast ($][1); }
 ;
 %%
 
 #define STAGE_MAX 5
 static
 #if defined USE_LEX_SYMBOL
-yy::parser::symbol_type yylex()
+yy::parser::symbol_type yylex ()
 #else
-yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
-                             yy::parser::location_type* yylloc)
+yy::parser::token_type yylex (yy::parser::semantic_type* yylval,
+                              yy::parser::location_type* yylloc)
 #endif
 {
 #ifndef USE_LEX_SYMBOL
@@ -148,7 +148,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* 
yylval,
       return yy::parser::make_NUMBER (stage, location_type ());
 #else
 # if defined ONE_STAGE_BUILD
-      yylval->build(stage);
+      yylval->build (stage);
 # else
       yylval->build<int>() = stage;
 # endif
@@ -170,12 +170,12 @@ yy::parser::token_type yylex(yy::parser::semantic_type* 
yylval,
       return token::TEXT;
 #endif
     }
-  abort();
+  abort ();
 }
 
 void
-yy::parser::error(const yy::parser::location_type&,
-                  const std::string& message)
+yy::parser::error (const yy::parser::location_type&,
+                   const std::string& message)
 {
   std::cerr << message << std::endl;
 }
@@ -184,8 +184,8 @@ int
 main ()
 {
   yy::parser p;
-  p.set_debug_level(!!getenv("YYDEBUG"));
-  return p.parse();
+  p.set_debug_level (!!getenv ("YYDEBUG"));
+  return p.parse ();
 }
 ]])
 
@@ -487,7 +487,7 @@ item:
   'a'
 | '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++)
   {
     case 'l':
-      throw yy::parser::syntax_error("invalid character");
+      throw yy::parser::syntax_error ("invalid character");
     default:
       return res;
   }
@@ -516,7 +516,7 @@ int
 main ()
 {
   yy::parser parser;
-  parser.set_debug_level(!!getenv("YYDEBUG"));
+  parser.set_debug_level (!!getenv ("YYDEBUG"));
   return parser.parse ();
 }
 ]])
-- 
1.7.12.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]