22 #include <fmt/format.h>
32 if ( !status )
return false;
43 if ( !status )
return false;
52 return std::make_unique<gp::PropertyName>( node->
children[0].value, node->
position );
56 for (
unsigned int i = 0; i < ( node->
children.size() - 1 ); ++i ) {
57 client += delim + node->
children[i].value;
60 return std::make_unique<gp::PropertyName>( client, node->
children[node->
children.size() - 1].value, node->
position );
66 switch ( node->
type ) {
77 double unit_value = 0;
78 if ( units->
Find( unit_name, unit_value ) ) {
81 value = std::make_unique<gp::PropertyValue>(
std::to_string( val * unit_value ) );
87 value = std::make_unique<gp::PropertyValue>( node->
value );
94 ss << std::quoted( node->
value );
95 value = std::make_unique<gp::PropertyValue>( ss.
str() );
100 value = std::make_unique<gp::PropertyValue>( node->
value );
108 [&](
const gp::Node& child ) { return GetPropertyValue( &child, catalog, units )->ToString(); } );
109 value = std::make_unique<gp::PropertyValue>(
std::move( result ) );
115 for (
const auto& child : node->
children ) {
116 auto kvalue = GetPropertyValue( &child.children[0], catalog, units );
117 auto vvalue = GetPropertyValue( &child.children[1], catalog, units );
118 result.emplace( kvalue->ToString(), vvalue->ToString() );
120 value = std::make_unique<gp::PropertyValue>(
std::move( result ) );
125 auto property = GetPropertyName( node );
126 gp::Property* exists = catalog->
Find( property->client(), property->property() );
128 value = std::make_unique<gp::PropertyValue>( exists->
property_value() );
135 auto property = GetPropertyName( node );
138 reference.
push_back( property->client() );
139 reference.
push_back( property->property() );
141 value = std::make_unique<gp::PropertyValue>(
std::move( reference ), property->position(),
true );
180 auto property = GetPropertyName( &node->
children[0] );
182 value = GetPropertyValue( &node->
children[2], catalog, units );
188 bool reassign =
false;
189 gp::Property* exists = catalog->
Find( property->client(), property->property() );
221 if ( !exists || reassign ) { result = catalog->
Add(
new gp::Property( *property, *value ) ); }
223 if ( result && is_print ) {
237 gp::Units::Container::mapped_type exists;
238 if ( units->
Find(
name, exists ) ) {
240 if ( exists.second.Exists() ) {
message +=
" at " + exists.second.ToString(); }
245 bool result = units->
Add(
name, right / left, node->
children[1].position );
246 if ( result && is_print ) {
255 auto property_name = GetPropertyName( &node->
children[0] );
257 bool is_defined = (
nullptr != catalog->
Find( property_name->client(), property_name->property() ) );
262 }
else if ( node->
children.size() > 2 ) {
274 bool local_result =
true;
275 bool skip_childs =
true;
278 switch ( node->
type ) {
286 local_result = IncludeNode( node, search_path, included, messages );
292 local_result = UnitsNode( node, search_path, included, messages );
298 local_result = AssignNode( node, messages, catalog, units, pragma->
is_print() );
303 local_result = UnitNode( node, messages, units, pragma->
is_print() );
308 local_result = ConditionNode( node, catalog, &next_root );
347 if ( result ) result = local_result;
349 if ( !skip_childs && next_root ) {
350 for (
auto& child : next_root->
children ) {
351 local_result = Analyze( &child, search_path, included, messages, catalog, units, pragma );
352 if ( result ) result = local_result;
359 bool unreference_result =
true;
360 for (
auto& client : catalog ) {
361 for (
auto& current : client.second ) {
362 if ( current.IsReference() ) {
365 gp::Property*
property = catalog.Find( names[0], names[1] );
367 messages->
AddError( value.
position(),
"Could not unreference " + current.ValueAsString() );
368 unreference_result =
false;
370 value =
property->property_value();
375 return unreference_result;
384 if ( !result )
return false;
386 bool result1 = Analyze(
root, search_path, &included, messages, catalog, units, pragma );
388 return result1 && result2;