@@ -144,30 +144,6 @@ class Context
144
144
145
145
}; // class Context
146
146
147
- // TODO (Carlosespicur): Perhaps would be better to define state tags as constexpr variables (IDLParserTags.hpp??)
148
-
149
- // __FLAG__
150
- template <typename Input>
151
- void debug_action (
152
- const std::string& rule_name,
153
- const Input& in,
154
- const std::map<std::string, std::string>& state,
155
- size_t operand_size)
156
- {
157
- std::cout << " [DEBUG] Rule: " << rule_name << " \n " ;
158
- std::cout << " Input: \" " << in.string () << " \"\n " ;
159
- std::cout << " Operands stack: " << operand_size << " \n " ;
160
- std::cout << " State:\n " ;
161
-
162
- for (std::map<std::string, std::string>::const_iterator it = state.begin (); it != state.end (); ++it)
163
- {
164
- std::cout << " - " << it->first << " : " << it->second << " \n " ;
165
- }
166
-
167
- std::cout << " -----------------------------------\n " ;
168
- }
169
-
170
- // ///////////////
171
147
172
148
// Actions
173
149
template <typename Rule>
@@ -195,7 +171,6 @@ struct action<identifier>
195
171
std::map<std::string, std::string>& state,
196
172
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
197
173
{
198
- debug_action (" identifier" , in, state, 0 );
199
174
std::string identifier_name = in.string ();
200
175
201
176
if (state.count (" enum_name" ))
@@ -362,7 +337,6 @@ struct action<scoped_name>
362
337
std::map<std::string, std::string>& state,
363
338
std::vector<traits<DynamicData>::ref_type>& operands)
364
339
{
365
- // debug_action("scoped_name", in, state, operands.size());
366
340
Module& module = ctx->module ();
367
341
std::string identifier_name = in.string ();
368
342
@@ -420,12 +394,11 @@ struct action<semicolon>
420
394
{
421
395
template <typename Input>
422
396
static void apply (
423
- const Input& in /* in*/ ,
397
+ const Input& /* in*/ ,
424
398
Context* /* ctx*/ ,
425
399
std::map<std::string, std::string>& state,
426
400
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
427
401
{
428
- debug_action (" semicolon" , in, state, 0 );
429
402
if (!state[" type" ].empty ())
430
403
{
431
404
if (state.count (" current_struct_member_name" ) && !state[" current_struct_member_name" ].empty ())
@@ -475,9 +448,6 @@ struct action<semicolon>
475
448
}
476
449
else if (state.count (" union_name" ) && !state[" union_name" ].empty ())
477
450
{
478
- // TODO (Carlosespicur): Probably, this could be refactored to be unified with the previous case after
479
- // supporting array types in unions.
480
-
481
451
// Add the type and name to the member lists
482
452
// NOTE: For sequence types, the type stored in "union_member_types"
483
453
// is the type of each element in the sequence, not "sequence".
@@ -505,7 +475,6 @@ struct action<semicolon>
505
475
}
506
476
507
477
// Clear the temporary states for the next member
508
- // TODO (Carlosespicur): Maybe I could clean variables always in a clean guard class
509
478
state[" type" ].clear ();
510
479
511
480
if (state.count (" element_type" ))
@@ -561,7 +530,6 @@ struct action<semicolon>
561
530
} \
562
531
else if (state.count (" parsing_sequence" ) && (state[" parsing_sequence" ] == " true" )) \
563
532
{ \
564
- std::cout << " [DEBUG] Parsing sequence type: " << type << " \n " ; \
565
533
state[" element_type" ] = type; \
566
534
state[" arithmetic_expr" ] = " " ; \
567
535
} \
@@ -594,12 +562,6 @@ load_type_action(string_type, string)
594
562
load_type_action (wide_string_type, wstring)
595
563
load_type_action (sequence_type, sequence)
596
564
597
- // TODO (Carlosespicur): Sequences could contain other types (declared before), so maybe i could add here a macro
598
- // to load the name of the type or create a new one. Probably, the first one is the best option because all the types above
599
- // can also be the internal type of a sequence. Ej: sequence<int32>. In this case:
600
- // load_type_action(type_spec, customType). How to get custom type name:
601
- // Maybe check if state["parsing_sequence"] == "true" and state.count("member_type_name") > 0 in macro?
602
-
603
565
template <>
604
566
struct action <char_type>
605
567
{
@@ -700,24 +662,6 @@ struct action<open_bracket>
700
662
701
663
};
702
664
703
- // TODO (Carlosespicur): Maybe a better approach is erase "arithmetic_expr"
704
- // after closing the bracket (I think it is more general)
705
- // template<>
706
- // struct action<close_bracket>
707
- // {
708
- // template<typename Input>
709
- // static void apply(
710
- // const Input& /*in*/,
711
- // Context* /*ctx*/,
712
- // std::map<std::string, std::string>& state,
713
- // std::vector<traits<DynamicData>::ref_type>& /*operands*/)
714
- // {
715
- // if (state.count)
716
- // state.erase("arithmetic_expr");
717
- // }
718
-
719
- // };
720
-
721
665
template <>
722
666
struct action <fixed_array_size>
723
667
{
@@ -767,7 +711,6 @@ struct action<fixed_array_size>
767
711
768
712
};
769
713
770
- // TODO (Carlosespicur): Perhaps the following action can be unified with load_stringsize_action
771
714
template <>
772
715
struct action <sequence_size>
773
716
{
@@ -852,8 +795,6 @@ struct action<kw_wstring>
852
795
853
796
};
854
797
855
-
856
-
857
798
template <>
858
799
struct action <open_ang_bracket>
859
800
{
@@ -926,7 +867,6 @@ struct action<kw_sequence>
926
867
std::map<std::string, std::string>& state,
927
868
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
928
869
{
929
- // debug_action("kw_sequence", in, state, 0);
930
870
state[" type" ] = " sequence" ;
931
871
// Set the default sequence size to LENGTH_UNLIMITED. In case of bounded sequence, it will be overrided later.
932
872
state[" sequence_size" ] = std::to_string (LENGTH_UNLIMITED);
@@ -941,24 +881,6 @@ struct action<kw_sequence>
941
881
}
942
882
};
943
883
944
- // template<>
945
- // struct action<sequence_type>
946
- // {
947
- // template<typename Input>
948
- // static void apply(
949
- // const Input& in,
950
- // Context* /*ctx*/,
951
- // std::map<std::string, std::string>& state,
952
- // std::vector<traits<DynamicData>::ref_type>& /*operands*/)
953
- // {
954
- // state["type"] = in.string();
955
- // // TODO (Carlosespicur): Implement sequence type parsing
956
-
957
- // // Should "sequence_sizes" state key be bconfigured here or add an action<sequence_size>?
958
- // EPROSIMA_LOG_INFO(IDLPARSER, "[TODO] sequence_type parsing not supported: " << state["type"]);
959
- // }
960
- // };
961
-
962
884
template <>
963
885
struct action <map_type>
964
886
{
@@ -1091,7 +1013,6 @@ struct action<boolean_literal>
1091
1013
std::map<std::string, std::string>& state, \
1092
1014
std::vector<traits<DynamicData>::ref_type>& operands) \
1093
1015
{ \
1094
- debug_action (#Rule, in, state, operands.size ()); \
1095
1016
if (state.count (" arithmetic_expr" )) \
1096
1017
{ \
1097
1018
state[" arithmetic_expr" ] += (state[" arithmetic_expr" ].empty () ? " " : " ;" ) + std::string{#id}; \
@@ -1125,11 +1046,8 @@ struct action<boolean_literal>
1125
1046
DynamicData::_ref_type xdata {DynamicDataFactory::get_instance ()->create_data (xtype)}; \
1126
1047
xdata->set_value (MEMBER_ID_INVALID, value); \
1127
1048
\
1128
- std::cout << " Before pushing..." << std::endl; \
1129
- debug_action (#Rule, in, state, operands.size ()); \
1130
1049
if (state.count (" arithmetic_expr" )) \
1131
1050
{ \
1132
- std::cout << " Pushing back " << #id << " literal: " << in.string () << " \n " ; \
1133
1051
operands.push_back (xdata); \
1134
1052
} \
1135
1053
} \
@@ -1732,7 +1650,6 @@ struct action<struct_def>
1732
1650
state.erase (" struct_member_types" );
1733
1651
state.erase (" struct_member_names" );
1734
1652
state.erase (" current_struct_member_name" );
1735
- // TODO (Carlosespicur): I think I should remove each unnecesary key after building the type.
1736
1653
state[" type" ] = " " ;
1737
1654
state[" all_array_sizes" ] = " " ;
1738
1655
state[" current_array_sizes" ] = " " ;
@@ -1741,7 +1658,7 @@ struct action<struct_def>
1741
1658
1742
1659
template <typename Input>
1743
1660
static void apply (
1744
- const Input& in /* in*/ ,
1661
+ const Input& /* in*/ ,
1745
1662
Context* ctx,
1746
1663
std::map<std::string, std::string>& state,
1747
1664
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
@@ -1758,8 +1675,6 @@ struct action<struct_def>
1758
1675
}
1759
1676
cleanup_guard{state};
1760
1677
1761
- debug_action (" struct_def" , in, state, 0 );
1762
-
1763
1678
Module& module = ctx->module ();
1764
1679
const std::string& struct_name = state[" struct_name" ];
1765
1680
@@ -1772,8 +1687,6 @@ struct action<struct_def>
1772
1687
std::vector<std::string> types = ctx->split_string (state[" struct_member_types" ], ' ;' );
1773
1688
std::vector<std::string> names = ctx->split_string (state[" struct_member_names" ], ' ;' );
1774
1689
std::vector<std::string> all_array_sizes = ctx->split_string (state[" all_array_sizes" ], ' ;' );
1775
- // TODO (Carlosespicur): Probably here I need add a "sequence_sizes" key to state map
1776
- // i.e: state["sequence_sizes"] = "size_1;size_2;...;size_n";
1777
1690
std::vector<std::string> sequence_sizes = ctx->split_string (state[" sequence_sizes" ], ' ;' );
1778
1691
1779
1692
for (size_t i = 0 ; i < types.size (); i++)
@@ -1875,12 +1788,11 @@ struct action<kw_union>
1875
1788
{
1876
1789
template <typename Input>
1877
1790
static void apply (
1878
- const Input& in /* in*/ ,
1791
+ const Input& /* in*/ ,
1879
1792
Context* /* ctx*/ ,
1880
1793
std::map<std::string, std::string>& state,
1881
1794
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
1882
1795
{
1883
- debug_action (" kw_union" , in, state, 0 );
1884
1796
// Create empty union states to indicate the start of parsing union
1885
1797
state[" union_name" ] = " " ;
1886
1798
state[" union_discriminant" ] = " " ;
@@ -1889,7 +1801,6 @@ struct action<kw_union>
1889
1801
state[" union_member_types" ] = " " ;
1890
1802
state[" current_union_member_name" ] = " " ;
1891
1803
state[" sequence_sizes" ] = " " ;
1892
- // state["union_expecting_member_name"] = "";
1893
1804
state[" type" ] = " " ;
1894
1805
}
1895
1806
@@ -2032,12 +1943,11 @@ struct action<union_def>
2032
1943
state.erase (" union_member_types" );
2033
1944
state.erase (" union_member_names" );
2034
1945
state.erase (" sequence_sizes" );
2035
- // state.erase("union_expecting_member_name");
2036
1946
}
2037
1947
2038
1948
template <typename Input>
2039
1949
static void apply (
2040
- const Input& in /* in*/ ,
1950
+ const Input& /* in*/ ,
2041
1951
Context* ctx,
2042
1952
std::map<std::string, std::string>& state,
2043
1953
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
@@ -2054,7 +1964,6 @@ struct action<union_def>
2054
1964
}
2055
1965
cleanup_guard{state};
2056
1966
2057
- debug_action (" union_def" , in, state, 0 );
2058
1967
Module& module = ctx->module ();
2059
1968
const std::string& union_name = state[" union_name" ];
2060
1969
@@ -2063,7 +1972,7 @@ struct action<union_def>
2063
1972
DynamicType::_ref_type discriminant_type = ctx->get_type (state, state[" union_discriminant" ]);
2064
1973
if (!discriminant_type)
2065
1974
{
2066
- EPROSIMA_LOG_INFO (IDLPARSER, " [TODO] union type not supported: " << state[" union_discriminant" ]);
1975
+ EPROSIMA_LOG_WARNING (IDLPARSER, " [TODO] union type not supported: " << state[" union_discriminant" ]);
2067
1976
return ;
2068
1977
}
2069
1978
type_descriptor->kind (TK_UNION);
@@ -2194,8 +2103,6 @@ struct action<kw_typedef>
2194
2103
// Create empty alias states to indicate the start of parsing alias
2195
2104
state[" alias" ] = " " ;
2196
2105
state[" current_array_sizes" ] = " " ;
2197
-
2198
- // TODO (Carlosespicur): Think about it is necessary to reset state["current_sequence_size"] here.
2199
2106
}
2200
2107
2201
2108
};
@@ -2221,7 +2128,7 @@ struct action<typedef_dcl>
2221
2128
2222
2129
template <typename Input>
2223
2130
static void apply (
2224
- const Input& in /* in*/ ,
2131
+ const Input& /* in*/ ,
2225
2132
Context* ctx,
2226
2133
std::map<std::string, std::string>& state,
2227
2134
std::vector<traits<DynamicData>::ref_type>& /* operands*/ )
@@ -2238,8 +2145,6 @@ struct action<typedef_dcl>
2238
2145
}
2239
2146
cleanup_guard{state};
2240
2147
2241
- debug_action (" typedef_dcl" , in, state, 0 );
2242
-
2243
2148
Module& module = ctx->module ();
2244
2149
2245
2150
std::string alias_name;
@@ -2271,10 +2176,8 @@ struct action<typedef_dcl>
2271
2176
2272
2177
if (!alias_type)
2273
2178
{
2274
- EPROSIMA_LOG_INFO (IDLPARSER, " [TODO] alias type not supported: " << state[" type" ]);
2179
+ EPROSIMA_LOG_WARNING (IDLPARSER, " [TODO] alias type not supported: " << state[" type" ]);
2275
2180
return ;
2276
-
2277
- // throw std::runtime_error("Alias type not supported: " + state["type"]);
2278
2181
}
2279
2182
2280
2183
DynamicTypeBuilderFactory::_ref_type factory {DynamicTypeBuilderFactory::get_instance ()};
@@ -2458,7 +2361,7 @@ class Parser
2458
2361
else
2459
2362
{
2460
2363
context_->success = false ;
2461
- EPROSIMA_LOG_INFO (IDLPARSER, " IDL parsing failed." );
2364
+ EPROSIMA_LOG_ERROR (IDLPARSER, " IDL parsing failed." );
2462
2365
return false ;
2463
2366
}
2464
2367
}
0 commit comments