TuringSim
C++ framework to simulate abstract computing models
Public Member Functions | Friends | List of all members
TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType > Class Template Reference

A dynamic symbol pattern where some accepted/rejected symbols are explicit and constant, and other accepted/rejected letters are identified by keys, and interpreted in a context. More...

#include <symbol/turingMachineSymbolPattern.h>

Inheritance diagram for TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >:
Inheritance graph
[legend]
Collaboration diagram for TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >:
Collaboration graph
[legend]

Public Member Functions

constexpr MixedSymbolPattern (const std::set< KeyType > &symbols, const std::set< KeyType > &keys, bool neg)
 Builds a new MixedSymbolPattern. More...
 
constexpr bool matchAccordingToPredicate (const SymbolType &symbol, const std::map< KeyType, ValueType > &context, const std::function< bool(const ValueType &)> &predicate) const
 Test if a key match a given predicate in a given context. More...
 
constexpr bool operator== (const MixedSymbolPattern< KeyType, ValueType, SymbolType > &other) const
 Equality operator. More...
 
constexpr bool operator!= (const MixedSymbolPattern< KeyType, ValueType, SymbolType > &other) const
 Non-equality operator. More...
 
constexpr bool operator< (const MixedSymbolPattern< KeyType, ValueType, SymbolType > &other) const
 Less than operator, total order. More...
 
constexpr bool isAlphaEquivalent (const MixedSymbolPattern< KeyType, ValueType, SymbolType > &other, const std::map< KeyType, KeyType > &rewriting) const
 Test if, given a renaming of keys, *this is alpha-equivalent to another DynamicSymbolPattern. More...
 
- Public Member Functions inherited from TuringSim::Symbol::SymbolPattern< SymbolType, std::map< KeyType, ValueType > >
 SymbolPattern ()=default
 The default constructor.
 
 SymbolPattern (const SymbolPattern &)=default
 The default copy constructor.
 
 SymbolPattern (SymbolPattern &&)=default
 The default move constructor.
 
SymbolPatternoperator= (const SymbolPattern &)=default
 The default copy assignment operator. More...
 
SymbolPatternoperator= (SymbolPattern &&)=default
 The default move assignment operator. More...
 
virtual ~SymbolPattern ()=default
 The default virtual destructor.
 
virtual bool match (const SymbolType &symbol, const Context &context) const noexcept=0
 Test whether a symbol match the pattern, given a context. More...
 

Friends

template<typename CharT = char, typename Traits = std::char_traits<CharT>>
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const MixedSymbolPattern< KeyType, ValueType, SymbolType > &pattern)
 Debug printer for MixedSymbolPattern. More...
 

Additional Inherited Members

- Public Types inherited from TuringSim::Symbol::SymbolPattern< SymbolType, std::map< KeyType, ValueType > >
typedef SymbolType SymbolType
 The type of symbols.
 
typedef std::map< KeyType, ValueType > Context
 The type of context.
 

Detailed Description

template<typename KeyType, typename ValueType, typename SymbolType>
class TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >

A dynamic symbol pattern where some accepted/rejected symbols are explicit and constant, and other accepted/rejected letters are identified by keys, and interpreted in a context.

Template Parameters
KeyTypeThe type of keys.
ValueTypeThe type to which keys map.
SymbolTypeThe type of symbols.

Definition at line 311 of file turingMachineSymbolPattern.h.

Constructor & Destructor Documentation

◆ MixedSymbolPattern()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::MixedSymbolPattern ( const std::set< KeyType > &  symbols,
const std::set< KeyType > &  keys,
bool  neg 
)
inlineconstexpr

Builds a new MixedSymbolPattern.

Parameters
[in]symbolsexplicit set of symbols to recognize.
[in]keyskeys of symbols to recognize in a context.
[in]negwhether to accept or reject the symbol when the pattern matches.

Definition at line 318 of file turingMachineSymbolPattern.h.

Member Function Documentation

◆ isAlphaEquivalent()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr bool TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::isAlphaEquivalent ( const MixedSymbolPattern< KeyType, ValueType, SymbolType > &  other,
const std::map< KeyType, KeyType > &  rewriting 
) const
inlineconstexpr

Test if, given a renaming of keys, *this is alpha-equivalent to another DynamicSymbolPattern.

Parameters
[in]otherthe other pattern to compare.
[in]rewritingthe renaming of keys, must be injective.
Returns
whether the two pattern are equivalent.

Definition at line 386 of file turingMachineSymbolPattern.h.

◆ matchAccordingToPredicate()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr bool TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::matchAccordingToPredicate ( const SymbolType symbol,
const std::map< KeyType, ValueType > &  context,
const std::function< bool(const ValueType &)> &  predicate 
) const
inlineconstexpr

Test if a key match a given predicate in a given context.

Parameters
[in]symbolthe symbol we want to match.
[in]contexta map from KeyType to ValueType, that gives a meaning to each key.
[in]predicatea predicate that recognizes values of type ValueType.
Returns
Whether the pattern is accepted.

The pattern matches if a key of *this maps to a value (according to context) that is recognized by predicate, or if the symbol is equal to one of the explicit symbols.

If the pattern matches, and the pattern is positive, the pattern is accepted. If the pattern matches and is negative, it is rejected. Conversely if the pattern does not match, it is accepted if and only if the pattern is negative.

Definition at line 333 of file turingMachineSymbolPattern.h.

◆ operator!=()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr bool TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::operator!= ( const MixedSymbolPattern< KeyType, ValueType, SymbolType > &  other) const
inlineconstexpr

Non-equality operator.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 360 of file turingMachineSymbolPattern.h.

◆ operator<()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr bool TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::operator< ( const MixedSymbolPattern< KeyType, ValueType, SymbolType > &  other) const
inlineconstexpr

Less than operator, total order.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 365 of file turingMachineSymbolPattern.h.

◆ operator==()

template<typename KeyType , typename ValueType , typename SymbolType >
constexpr bool TuringSim::Symbol::MixedSymbolPattern< KeyType, ValueType, SymbolType >::operator== ( const MixedSymbolPattern< KeyType, ValueType, SymbolType > &  other) const
inlineconstexpr

Equality operator.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 355 of file turingMachineSymbolPattern.h.

Friends And Related Function Documentation

◆ operator<<

template<typename KeyType , typename ValueType , typename SymbolType >
template<typename CharT = char, typename Traits = std::char_traits<CharT>>
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const MixedSymbolPattern< KeyType, ValueType, SymbolType > &  pattern 
)
friend

Debug printer for MixedSymbolPattern.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream traits.
Parameters
osoutput stream.
patternpattern to print.
Returns
a reference to os.

Definition at line 416 of file turingMachineSymbolPattern.h.


The documentation for this class was generated from the following file: