Skip to content
Permalink
Browse files

Fix for Seq output and ordering of IncParser output nodes

  • Loading branch information
nfomon committed Sep 27, 2015
1 parent 8fe1f2d commit 7356a778eb2b09ff05ac58b1407d11b2a609e41a
Showing with 28 additions and 22 deletions.
  1. +12 −5 statik/IncParser.cpp
  2. +13 −3 statik/Meta.cpp
  3. +1 −2 statik/Meta.h
  4. +2 −12 statik/Seq.cpp
@@ -411,14 +411,18 @@ void IncParser::ComputeOutput_Update(const STree& node, Batch& out_batch, const
item != output.end(); ++item) {
node_mod_iter find_ins = nodes.find(*item);
if (nodes.end() == find_ins) {
g_log.debug() << "Updating item " << *item << " behind node " << behind_node;
g_log.debug() << "Updating item " << *item << " after behind-node " << behind_node;
UpdateOutput(*item, out_batch, behind_node, worst_station);
} else {
nodes.erase(find_ins);
g_log.debug() << "Inserting item " << *item << " behind node " << behind_node;
g_log.debug() << "Inserting item " << *item << " after behind-node " << behind_node;
InsertOutput(*item, out_batch, behind_node, worst_station);
}
behind_node = GetOEnd(*item);
const List* b = GetOEnd(*item);
if (b) {
g_log.debug() << "Update of " << node << ": Set behind_node to " << *b;
behind_node = b;
}
}

if (output.empty()) {
@@ -447,8 +451,11 @@ void IncParser::ComputeOutput_Insert(const STree& node, Batch& out_batch, const
for (OutputList::const_iterator item = output.begin();
item != output.end(); ++item) {
InsertOutput(*item, out_batch, behind_node, worst_station);
g_log.info() << " insert woo...";
behind_node = GetOEnd(*item);
const List* b = GetOEnd(*item);
if (b) {
g_log.debug() << "Inserting " << node << "; set behind_node to " << *b;
behind_node = b;
}
}

if (output.empty()) {
@@ -5,6 +5,7 @@

#include "IncParser.h"
#include "OutputFunc.h"
#include "SError.h"
#include "SLog.h"
#include "STree.h"

@@ -29,23 +30,32 @@ auto_ptr<ParseFunc> statik::MakeParseFunc_Meta(const string& searchName) {
return auto_ptr<ParseFunc>(new ParseFunc_Meta(searchName));
}

ParseFunc_Meta::ParseFunc_Meta(const string& searchName)
: m_searchName(searchName) {
if (m_searchName.empty()) {
throw SError("Cannot create empty Meta");
}
}

void ParseFunc_Meta::operator() (ParseAction::Action action, const List& inode, const STree* initiator) {
g_log.info() << "Computing Meta at " << *m_node << " with inode "<< inode;
State& state = m_node->GetState();
state.Clear();
const List& first = m_node->IStart();
m_node->GetIncParser().Listen(*m_node, first);
m_node->GetIConnection().SetEnd(first);
if (first.name == m_searchName) {
state.GoDone();
const List* second = first.right;
if (second) {
state.GoComplete();
m_node->GetIConnection().SetEnd(*second);
} else {
m_node->GetIConnection().SetEnd(first);
}
} else {
state.GoBad();
}
g_log.debug() << "Meta now at: " << *m_node;
if (state.IsPending()) {
throw SError("Meta failed to determine state");
}
g_log.debug() << "Meta now at: " << *m_node << " with IStart: " << m_node->IStart() << " and IEnd: " << m_node->IEnd();
}
@@ -26,8 +26,7 @@ std::auto_ptr<Rule> META(const std::string& name,

class ParseFunc_Meta : public ParseFunc {
public:
ParseFunc_Meta(const std::string& searchName)
: m_searchName(searchName) {}
ParseFunc_Meta(const std::string& searchName);
virtual ~ParseFunc_Meta() {}
virtual void operator() (ParseAction::Action action, const List& inode, const STree* initiator);
virtual std::auto_ptr<ParseFunc> Clone() {
@@ -193,18 +193,8 @@ void ParseFunc_Seq::operator() (ParseAction::Action action, const List& inode, c
if (istate.IsPending()) {
throw SError("Seq's breach child is Pending");
} else if (istate.IsBad()) {
// last child bad, prev children all complete => complete
// otherwise, we're bad
if (m_node->children.empty()) {
throw SError("Should not be evaluating bad breach child when node has no children");
}
if (&*m_node->children.back() == breachChild) {
state.GoComplete();
m_node->GetIConnection().SetEnd(breachChild->IEnd());
} else {
state.GoBad();
m_node->GetIConnection().SetEnd(breachChild->IEnd());
}
state.GoBad();
m_node->GetIConnection().SetEnd(breachChild->IEnd());
} else if (istate.IsOK()) {
state.GoOK();
m_node->GetIConnection().SetEnd(breachChild->IEnd());

0 comments on commit 7356a77

Please sign in to comment.
You can’t perform that action at this time.