c++: style changes

* data/c++.m4, data/variant.hh: Improve layout of the generated code.
Avoid casts.
(_b4_symbol_constructor_declare, _b4_symbol_constructor_define): Rename
as...
(_b4_token_maker_declare, _b4_token_maker_define): these.
* tests/types.at: Improve pair printing.
This commit is contained in:
Akim Demaille
2018-12-19 17:51:10 +01:00
parent a8e66fc010
commit 34c52d10ac
3 changed files with 31 additions and 33 deletions

View File

@@ -295,15 +295,14 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
[[%token <std::unique_ptr<int>> '1';
%token <std::pair<int, int>> '2';]],
['1' '2' { std::cout << *$1 << ", "
<< $2.first << ", "
<< $2.second << '\n'; }],
<< $2.first << ':' << $2.second << '\n'; }],
["12"],
[[if (res == '1')
]AT_VAL[.emplace <std::unique_ptr<int>>
(std::make_unique <int> (10));
else if (res == '2')
]AT_VAL[.emplace <std::pair<int, int>> (21, 22);]],
[10, 21, 22],
[10, 21:22],
[AT_REQUIRE_CXX_STD(14, [echo "$at_std not supported"; continue])])
# Token constructors on move-only types, and types with commas.
@@ -315,8 +314,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
%token <std::pair<int, int>> TWO;
%token EOI 0;]],
[ONE TWO { std::cout << *$1 << ", "
<< $2.first << ", "
<< $2.second << '\n'; }],
<< $2.first << ':' << $2.second << '\n'; }],
["12"],
[[if (res == '1')
return yy::parser::make_ONE (std::make_unique<int> (10));
@@ -324,7 +322,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
return yy::parser::make_TWO (std::make_pair (21, 22));
else
return yy::parser::make_EOI ()]],
[10, 21, 22],
[10, 21:22],
[AT_REQUIRE_CXX_STD(14, [echo "$at_std not supported"; continue])])
])