Commit 6f4c22aa authored by Florent Jacquemard's avatar Florent Jacquemard
Browse files

minor refactor LRT builder : table reference not pointer

parent ab62f5c0
......@@ -52,7 +52,7 @@ public:
/// @warning even when the returned tree is not FAIL,
/// it may contain FAIL subtrees,
/// when parsing partially failed e.g. for 1 bar (FAIL subrun).
static LabeledRhythmTree* best(parsing::TableA<K>* tab,
static LabeledRhythmTree* best(parsing::TableA<K>& tab,
const K& k,
size_t n=1,
bool unfailing=false);
......@@ -65,9 +65,9 @@ public:
/// @return the tree associated to the best run. should never be NULL.
/// A parse error is signaled by a FAIL symbol.
/// @remark defined as factory because one cannot define template constructors.
static LabeledRhythmTree* projection(parsing::TableA<K>* tab,
static LabeledRhythmTree* projection(parsing::TableA<K>& tab,
const parsing::Run* r,
size_t m,
size_t m=1,
bool unfailing=false);
};
......
......@@ -9,26 +9,24 @@
template <class K>
LabeledRhythmTree*
LRTFactory<K>::best(parsing::TableA<K>* tab,
LRTFactory<K>::best(parsing::TableA<K>& tab,
const K& k,
size_t n,
bool unfailing)
{
assert(tab);
assert(n >= 1);
const parsing::Run* r = tab->best(k, n); // should not be NULL
const parsing::Run* r = tab.best(k, n); // should not be NULL
return projection(tab, r, 0, unfailing); // multiplicity is 0 at top
}
template <class K>
LabeledRhythmTree*
LRTFactory<K>::projection(parsing::TableA<K>* tab,
LRTFactory<K>::projection(parsing::TableA<K>& tab,
const parsing::Run* r,
size_t mult,
bool unfailing)
{
assert(tab);
assert(r);
if (r->fail())
......@@ -55,7 +53,8 @@ LRTFactory<K>::projection(parsing::TableA<K>* tab,
assert (r->inner());
assert (ar > 0);
const parsing::RunInner<K>* ir = dynamic_cast<const parsing::RunInner<K>*>(r);
const parsing::RunInner<K>* ir =
dynamic_cast<const parsing::RunInner<K>*>(r);
assert(ir);
// inner RhythmTree, initialy empty.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment