From bfa50d8f1183ff39c2e52b9beaca1ba48bd2cef0 Mon Sep 17 00:00:00 2001 From: David de Hilster Date: Tue, 8 Oct 2024 15:48:57 -0400 Subject: [PATCH] NLP-ENGINE-427 Added pnsetfired function to allow highlighting Signed-off-by: David de Hilster --- include/Api/lite/Arun.h | 2 ++ lite/fn.cpp | 73 +++++++++++++++++++++++++++++++++++++++-- lite/fn.h | 1 + lite/fnrun.cpp | 17 ++++++++++ lite/func_defs.h | 1 + lite/funcs.h | 1 + lite/parse.cpp | 1 + lite/pat.cpp | 2 ++ lite/seqn.cpp | 4 +++ lite/seqn.h | 4 +++ nlp/main.cpp | 2 +- vcpkg | 2 +- 12 files changed, 105 insertions(+), 5 deletions(-) diff --git a/include/Api/lite/Arun.h b/include/Api/lite/Arun.h index 7474b8ff..d5d7ea5e 100644 --- a/include/Api/lite/Arun.h +++ b/include/Api/lite/Arun.h @@ -1551,6 +1551,8 @@ class LITE_API Arun static RFASem *pnvarnames(Nlppp*,RFASem*); // 05/13/02 AM. static RFASem *pnvartype(Nlppp*,NODE*,_TCHAR*); + static bool pnsetfired(Nlppp*,NODE*,bool); + static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,_TCHAR*); // 07/03/02 AM. static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,long long); // 07/03/02 AM. static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,RFASem*); // 07/03/02 AM. diff --git a/lite/fn.cpp b/lite/fn.cpp index ab3d4547..a07805fb 100644 --- a/lite/fn.cpp +++ b/lite/fn.cpp @@ -488,6 +488,8 @@ switch (fnid) // 12/21/01 AM. return fnPnroot(args,nlppp,/*UP*/sem); // 10/18/00 AM. case FNpnrpushval: return fnPnrpushval(args,nlppp,/*UP*/sem); // 12/12/14 AM. + case FNpnsetfired: + return fnPnsetfired(args,nlppp,sem); case FNpnsingletdown: return fnPnsingletdown(args,nlppp,/*UP*/sem); // 10/18/00 AM. case FNpnup: @@ -10953,11 +10955,11 @@ Parse *parse = nlppp->parse_; RFASem *sem1; _TCHAR *name1=0; -if (!Arg::sem1(_T("pnvar"),nlppp,(DELTS*&)args,sem1)) +if (!Arg::sem1(_T("pnvartype"),nlppp,(DELTS*&)args,sem1)) return false; -if (!Arg::str1(_T("pnvar"), /*UP*/ (DELTS*&)args, name1)) +if (!Arg::str1(_T("pnvartype"), /*UP*/ (DELTS*&)args, name1)) return false; -if (!Arg::done((DELTS*)args, _T("pnvar"),parse)) +if (!Arg::done((DELTS*)args, _T("pnvartype"),parse)) return false; if (!sem1) @@ -10991,6 +10993,71 @@ return true; } +/******************************************** +* FN: FNPNSETFIRED +* CR: 10/8/2024 Dd. +* SUBJ: Sets the fired flag of a PNODE. +* RET: previous value of fired flag. +********************************************/ + +bool Fn::fnPnsetfired( + Delt *args, + Nlppp *nlppp, + RFASem* &sem + ) +{ +sem = 0; +Parse *parse = nlppp->parse_; + +RFASem *sem1; +long long num1=0; + +if (!Arg::sem1(_T("pnsetflag"),nlppp,(DELTS*&)args,sem1)) + return false; +if (!Arg::num1(_T("pnsetflag"), /*UP*/ (DELTS*&)args,num1)) + return false; +if (!Arg::done((DELTS*)args, _T("pnsetflag"),parse)) + return false; + +if (!sem1) + { + _stprintf(Errbuf,_T("[pnsetflag: Warning. Given no pnode.]")); + return parse->errOut(true); + } + +if (sem1->getType() != RSNODE) + { + _stprintf(Errbuf,_T("[pnsetflag: Bad semantic arg.]")); + return parse->errOut(false); + } + +Node *node = sem1->getNode(); + +if (!node) + { + _stprintf(Errbuf,_T("[pnsetflag: Couldn't fetch node.]")); + return parse->errOut(false); + } + +if (num1 < 0LL || num1 > 1LL) + { + _stprintf(Errbuf,_T("[pnsetflag: Warning. Flag value out of range.]")); + return parse->errOut(true); + } + +bool firedFlag = (num1 == 1LL); +if (firedFlag) { + Delt *seq = parse->getSeq(); + Seqn *seqn = 0; + if (!(seqn = seq->getData())) + return 0; + seqn->setDisplaytree(true); +} +Arun::pnsetfired(nlppp,node,firedFlag); +return true; +} + + #ifdef _ODBC /******************************************** diff --git a/lite/fn.h b/lite/fn.h index ec9c2bfe..d8d3223c 100644 --- a/lite/fn.h +++ b/lite/fn.h @@ -969,6 +969,7 @@ static bool fnStruniquechars( static bool fnInteractive(Delt*,Nlppp*,RFASem*&); // 05/06/02 AM. static bool fnPnvarnames(Delt*,Nlppp*,RFASem*&); // 05/13/02 AM. static bool fnPnvartype(Delt*,Nlppp*,RFASem*&); // 05/13/02 AM. + static bool fnPnsetfired(Delt*,Nlppp*,RFASem*&); static bool fnDbopen(Delt*,Nlppp*,RFASem*&); // 05/23/02 AM. static bool fnDbclose(Delt*,Nlppp*,RFASem*&); // 05/23/02 AM. diff --git a/lite/fnrun.cpp b/lite/fnrun.cpp index 1f5458d6..a45c12dd 100644 --- a/lite/fnrun.cpp +++ b/lite/fnrun.cpp @@ -13412,6 +13412,23 @@ return sem; } +bool Arun::pnsetfired( + Nlppp *nlppp, + NODE *pnode, + bool fired + ) +{ +RFASem *sem = 0; +if (!nlppp || !pnode || !fired) + return 0; + +Node *node = (Node *)pnode; +Pn *pn = node->getData(); +pn->setFired(fired); +return fired; +} + + #ifdef _ODBC /******************************************** diff --git a/lite/func_defs.h b/lite/func_defs.h index 5ff8a096..686e9c9d 100644 --- a/lite/func_defs.h +++ b/lite/func_defs.h @@ -173,6 +173,7 @@ enum funcDef FNpnreplaceval, FNpnroot, FNpnrpushval, // 12/12/14 AM. + FNpnsetfired, FNpnsingletdown, FNpnup, FNpnvar, diff --git a/lite/funcs.h b/lite/funcs.h index a8b312be..57cb3432 100644 --- a/lite/funcs.h +++ b/lite/funcs.h @@ -167,6 +167,7 @@ _T("pnrename"), _T("pnreplaceval"), _T("pnroot"), _T("pnrpushval"), // 12/12/14 AM. +_T("pnsetfired"), _T("pnsingletdown"), _T("pnup"), _T("pnvar"), diff --git a/lite/parse.cpp b/lite/parse.cpp index 2dcabebe..66b7fd16 100644 --- a/lite/parse.cpp +++ b/lite/parse.cpp @@ -640,6 +640,7 @@ std::_t_ostream *sout; // For restoring output stream. // 12/01/98 AM. clock_t s_time; _TCHAR *pretname; Seqn *pass = seq->getData(); +this->seq_ = seq; Algo *algo = pass->getAlgo(); _TCHAR *sfile = pass->getRulesfilename(); _TCHAR *salgo = pass->getAlgoname(); diff --git a/lite/pat.cpp b/lite/pat.cpp index 3806bd21..bf6aba49 100644 --- a/lite/pat.cpp +++ b/lite/pat.cpp @@ -194,6 +194,8 @@ if (!rulelist) gerrStr << _T("[Pat pass given no rules.]") << std::ends; return errOut(&gerrStr,false); } + if (seqn->displaytree_) + prettyPass(root,tree,parse); return true; } diff --git a/lite/seqn.cpp b/lite/seqn.cpp index 405de834..15237eca 100644 --- a/lite/seqn.cpp +++ b/lite/seqn.cpp @@ -55,6 +55,7 @@ else rules_ = rules; name_ = name; // 11/24/98 AM. rulesfile_ = 0; // 11/25/98 AM. +displaytree_ = false; active_ = true; // 01/08/99 AM. comment_[0] = '\0'; // 01/08/99 AM. passnum_ = 0; // 09/23/99 AM. @@ -102,6 +103,7 @@ if (comment && *comment) // 02/12/99 AM. algo = 0; rules_ = 0; rulesfile_ = 0; +displaytree_ = false; passnum_ = 0; // 09/23/99 AM. recid_ = 0; @@ -156,6 +158,7 @@ Dlist *Seqn::getRules() {return rules_; } _TCHAR *Seqn::getName() {return name_; } Ifile *Seqn::getRulesfile() {return rulesfile_; } bool Seqn::getActive() {return active_; } +bool Seqn::getDisplaytree() {return displaytree_; } _TCHAR *Seqn::getComment() {return comment_; } _TCHAR *Seqn::getAlgoname() {return algo_name_; } int Seqn::getPassnum() {return passnum_; } // 09/23/99 AM. @@ -186,6 +189,7 @@ void Seqn::setRules(Dlist *x) {rules_ = x;} void Seqn::setName(_TCHAR *x) {name_ = x;} void Seqn::setRulesfile(Ifile *x) {rulesfile_ = x;} void Seqn::setActive(bool x) {active_ = x;} +void Seqn::setDisplaytree(bool x) {displaytree_ = x;} void Seqn::setPassnum(int x) {passnum_ = x;} // 09/23/99 AM. void Seqn::setRecid(int x) {recid_ = x;} void Seqn::setComment(_TCHAR *x) diff --git a/lite/seqn.h b/lite/seqn.h index 85212a6c..50077027 100644 --- a/lite/seqn.h +++ b/lite/seqn.h @@ -70,6 +70,7 @@ class Seqn Ifile *getRulesfile(); Dlist *getSelects(); // 11/30/98 AM. bool getActive(); // 01/08/99 AM. + bool getDisplaytree(); _TCHAR *getAlgoname(); // 01/08/99 AM. _TCHAR *getComment(); // 01/08/99 AM. int getPassnum(); // 09/23/99 AM. @@ -83,6 +84,7 @@ class Seqn void setRulesfile(Ifile *); void setSelects(Dlist *); void setActive(bool); // 01/08/99 AM. + void setDisplaytree(bool); void setAlgoname(_TCHAR *); // 01/08/99 AM. void setComment(_TCHAR *); // 01/08/99 AM. void setPassnum(int); // 09/23/99 AM. @@ -142,6 +144,8 @@ class Seqn Ifile *rulesfile_; // Internal representation of rules file.// 11/25/98 AM. + bool displaytree_; // Force tree to be displayed + // New data to enable user-editing of the analyzer sequence.// 01/08/99 AM. bool active_; // If this pass will be executed. // 01/08/99 AM. _TCHAR comment_[MAXSTR]; // User comment for pass. // 01/08/99 AM. diff --git a/nlp/main.cpp b/nlp/main.cpp index f468c4a0..ac363016 100644 --- a/nlp/main.cpp +++ b/nlp/main.cpp @@ -15,7 +15,7 @@ All rights reserved. #include "lite/nlp_engine.h" #include "version.h" -#define NLP_ENGINE_VERSION "2.13.0" +#define NLP_ENGINE_VERSION "2.14.1" bool cmdReadArgs(int,_TCHAR*argv[],_TCHAR*&,_TCHAR*&,_TCHAR*&,_TCHAR*&,bool&,bool&,bool&); void cmdHelpargs(_TCHAR*); diff --git a/vcpkg b/vcpkg index 6f1ddd6b..c45ac46d 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 6f1ddd6b6878e7e66fcc35c65ba1d8feec2e01f8 +Subproject commit c45ac46dcc16dd588daa029f7ce5bcacc5d7645b