#include "sema.h"
namespace goose::sema
{
Term Quote( const Term& t )
{
return SetComplexity( VEC( TSID( quote ), t ), 0 );
}
optional< Term > Unquote( const Term& t )
{
auto result = Decompose( t,
Vec(
Lit( "quote"_sid ),
SubTerm()
)
);
if( !result )
return nullopt;
auto&& [quoted] = *result;
return quoted;
}
void SetupQuoteUnificationRules( UnificationRuleSet& ruleSet )
{
ruleSet.addHalfUnificationRule( URINFOS, VEC( TSID( quote ), ANYTERM( _ ) ),
[]( const Term& lhs, UnificationContext& c ) -> UniGen
{
co_yield { lhs, c };
} );
ruleSet.addSymRule( URINFOS, VEC( TSID( quote ), ANYTERM( _ ) ),
[]( const Term& lhs, const Term& rhs, UnificationContext& c ) -> UniGen
{
if( lhs == rhs )
co_yield { lhs, c };
} );
}
}