bison-patches
[Top][All Lists]
Advanced

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

{master} tests: check variants without locations


From: Akim Demaille
Subject: {master} tests: check variants without locations
Date: Wed, 28 Nov 2012 10:53:29 +0100

commit f5fceda596e63df67e7dea89a4c3f9f069f467c3
Author: Akim Demaille <address@hidden>
Date:   Wed Nov 28 10:51:45 2012 +0100

    tests: check variants without locations
    
    * tests/c++.at (Variants): Support non-use of locations, and
    check its support.

diff --git a/tests/c++.at b/tests/c++.at
index 08040d6..19856ff 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -35,7 +35,6 @@ AT_DATA_GRAMMAR([list.yy],
 %skeleton "lalr1.cc"
 %defines
 %define variant
-%locations
 ]m4_bpatsubst([$1], [\\n], [
 ])[
 
@@ -48,6 +47,7 @@ typedef std::list<std::string> strings_type;
 
 %code // code for the .cc file
 {
+#include <cstdlib> // abort, getenv
 #include <iostream>
 #include <sstream>
 
@@ -55,8 +55,8 @@ typedef std::list<std::string> strings_type;
   {
     static]AT_TOKEN_CTOR_IF([[
     parser::symbol_type yylex ()]], [[
-    parser::token_type yylex (parser::semantic_type* yylval,
-                              parser::location_type* yylloc)]])[;
+    parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
+                              parser::location_type* yylloc])[)]])[;
   }
 
   // Printing a list of strings (for %printer).
@@ -130,42 +130,40 @@ namespace yy
 {
   static]AT_TOKEN_CTOR_IF([[
   parser::symbol_type yylex ()]], [[
-  parser::token_type yylex (parser::semantic_type* yylval,
-                            parser::location_type* yylloc)]])[
-  {
-    typedef parser::location_type location;
+  parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
+                            parser::location_type* yylloc])[)]])[
+  {]AT_LOCATION_IF([
+    typedef parser::location_type location;])[
     static int stage = -1;
     ++stage;
     if (stage == STAGE_MAX)
       {]AT_TOKEN_CTOR_IF([[
-        return parser::make_END_OF_FILE (location ());]], [[
-        *yylloc = location ();
+        return parser::make_END_OF_FILE (]AT_LOCATION_IF([location ()])[);]],
+[AT_LOCATION_IF([
+        *yylloc = location ();])[
         return parser::token::END_OF_FILE;]])[
       }
     else if (stage % 2)
       {]AT_TOKEN_CTOR_IF([[
-        return parser::make_NUMBER (stage, location ());]], [[
-        yylval->BUILD (int, stage);
-        *yylloc = location ();
+        return parser::make_NUMBER (stage]AT_LOCATION_IF([, location ()])[);]],
+[[
+        yylval->BUILD (int, stage);]AT_LOCATION_IF([
+        *yylloc = location ();])[
         return parser::token::NUMBER;]])[
       }
     else
       {]AT_TOKEN_CTOR_IF([[
-        return parser::make_TEXT (string_cast (stage), location ());]], [[
-        yylval->BUILD (std::string, string_cast (stage));
-        *yylloc = location ();
+        return parser::make_TEXT (string_cast (stage)]AT_LOCATION_IF([, 
location ()])[);]], [[
+        yylval->BUILD (std::string, string_cast (stage));]AT_LOCATION_IF([
+        *yylloc = location ();])[
         return parser::token::TEXT;]])[
       }
     abort ();
   }
-
-  void
-  parser::error (const parser::location_type&, const std::string& message)
-  {
-    std::cerr << message << std::endl;
-  }
 }
 
+]AT_YYERROR_DEFINE[
+
 int
 main ()
 {
@@ -187,9 +185,11 @@ AT_CLEANUP
 
 AT_TEST([])
 AT_TEST([%define parse.assert])
+AT_TEST([%locations %define parse.assert])
 AT_TEST([[%define parse.assert %code {\n#define TWO_STAGE_BUILD\n}]])
 AT_TEST([[%define parse.assert %define api.token.constructor]])
 AT_TEST([[%define parse.assert %define api.token.constructor %define 
api.token.prefix "TOK_"]])
+AT_TEST([[%locations %define parse.assert %define api.token.constructor 
%define api.token.prefix "TOK_"]])
 
 m4_popdef([AT_TEST])
 




reply via email to

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