28namespace LinguisticProcessing {
35#define CHAR_SEP_CONSTRAINT_INTERNAL '/'
36#define CHAR_BEGIN_CONSTRAINT_INTERNAL '+'
37#define CHAR_NEGATIVE_CONSTRAINT_INTERNAL '!'
51 const std::string& functionName,
67m_functionAddr(c.m_functionAddr),
69m_negative(c.m_negative)
91 m_functionAddr = c.m_functionAddr;
92 m_action = c.m_action;
93 m_negative = c.m_negative;
103 getFunctionName(m_functionAddr,
110 LERROR <<
"constraint function "
111 << m_functionAddr <<
" not available";
140 secondVertex(vertex);
145 constraintCheckList[m_index].store(vertex);
149 constraintCheckList[m_index].push(vertex);
153 firstVertex=constraintCheckList[m_index].getValueStored();
160 secondVertex=constraintCheckList[m_index].getValueStored();
165 firstVertex=constraintCheckList[m_index].getValueStack();
172 secondVertex=constraintCheckList[m_index].getValueStack();
177 success=(*m_functionAddr)(graph,vertex,analysis);
185 LERROR <<
"Constraint: cannot call checkConstraint with EXECUTE type"
191 LERROR <<
"Constraint: no action specified "
203 success=(*m_functionAddr)(graph,firstVertex,secondVertex,analysis);
209 return (m_negative?(!success):success);
224 if (success) {
return true; }
228 if (success) {
return true; }
233 if (! success) {
return true; }
237 if (! success) {
return true; }
243 LERROR <<
"cannot apply an action if not type EXECUTE "
256 if ((*m_functionAddr).actionNeedsRecognizedExpression()) {
257 res=(*m_functionAddr)(*result,analysis);
260 res=(*m_functionAddr)(analysis);
265 constraintCheckList[m_index].getValueStack();
272 constraintCheckList[m_index].pop();
273 if (constraintCheckList[m_index].empty()) {
275 res=(*m_functionAddr)(graph,
281 constraintCheckList[m_index].getValueStack();
289 res=(*m_functionAddr)(graph,
298 return (m_negative?(!res):res);
305 if (c1.m_index != c2.m_index) {
return false; }
306 if (c1.m_functionAddr != c2.m_functionAddr) {
return false; }
307 if (c1.m_action != c2.m_action) {
return false; }
308 if (c1.m_negative != c2.m_negative) {
return false; }
319 getFunctionName(m_functionAddr,
323 LERROR <<
"constraint function "
324 << m_functionAddr <<
" not availale";
330 <<
static_cast<uint64_t
>(m_action)
336 if (! complement.isEmpty()) {
343std::string Constraint::
350 getFunctionName(m_functionAddr,
354 LERROR <<
"constraint function "
355 << m_functionAddr <<
" not availale";
359 oss <<
"Constraint:" << actionString()
360 <<
" vertex " << vertex
362 <<
" in constraint " << m_index
369std::string Constraint::
376 getFunctionName(m_functionAddr,
380 LERROR <<
"constraint function "
381 << m_functionAddr <<
" not availale";
385 oss <<
"Constraint: executing action "
387 if (firstArg!=0 && secondArg!=0) {
388 oss <<
" on vertices "<< firstArg
391 else if (firstArg!=0) {
392 oss <<
" on vertex " << firstArg;
401std::string Constraint::
402actionString()
const {
404 case NONE:
return "NONE";
405 case STORE:
return "STORE";
406 case COMPARE:
return "COMPARE";
407 case PUSH:
return "PUSH";
409 case TEST:
return "TEST";
418 return "UNKNOWN_ACTION";
426 getFunctionName(c.m_functionAddr,
430 LERROR <<
"constraint function "
431 << c.m_functionAddr <<
" not availale";
438 default: os <<
"+";
break;
444 os <<
"[" << c.
index()<<
",";
449 os << functionName <<
"," << c.actionString();
450 if (! complement.isEmpty()) {
465 LERROR <<
"constraint function "
466 << c.m_functionAddr <<
" not availale";
473 default: os <<
"+";
break;
479 os <<
"[" << c.
index()<<
",";
485 os << functionName <<
"," << c.actionString();
486 if (! complement.isEmpty()) {
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
static const uint64_t novalue
static const uint64_t noindex
std::string functionName() const
Constraint & operator=(const Constraint &)
bool apply(const LinguisticAnalysisStructure::AnalysisGraph &graph, AnalysisContent &analysis, ConstraintCheckList &constraintCheckList, const bool success, RecognizerMatch *result) const
apply an action (only for EXECUTE type of action)
ConstraintAction action() const
bool checkConstraint(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis, ConstraintCheckList &constraintCheckList) const
check a constraint
An AnalysisData containing a LinguisticGraph with a language and an id.
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
static const ConstraintFunctionManager & single()
const singleton accessor
static ConstraintFunctionManager & changeable()
singleton accessor
#define CHAR_BEGIN_CONSTRAINT_INTERNAL
#define CHAR_NEGATIVE_CONSTRAINT_INTERNAL
#define CHAR_SEP_CONSTRAINT_INTERNAL
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
LimaString utf8stdstring2limastring(const std::string &src)
@ EXECUTE_IF_FAILURE_REVERSE
@ EXECUTE_IF_SUCCESS_REVERSE
std::ostream & operator<<(std::ostream &os, const DFFSPos &x)
bool operator==(const Constraint &c1, const Constraint &c2)
std::vector< ConstraintCheckListElement > ConstraintCheckList