Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
qparse
qparselib
Commits
9fef3f80
Commit
9fef3f80
authored
Apr 08, 2021
by
Florent Jacquemard
Browse files
update class KeySIO = refactoring of KeySIR (new format)
correct KeySIP (new format)
parent
6af7d854
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
qparse.xcodeproj/project.pbxproj
View file @
9fef3f80
...
...
@@ -91,7 +91,6 @@
43004600260496E6000E9898
/* KeyS.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
4373B456225163CC00D49D6C
/* KeyS.cpp */
;
};
43004601260496E6000E9898
/* KeySI.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43552EDD22A6CFDE00C557BA
/* KeySI.cpp */
;
};
43004603260496E6000E9898
/* KeySIR.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
439D5228239E576500796CBA
/* KeySIR.cpp */
;
};
43004604260496E6000E9898
/* KeySIO.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43CDB7932577899500956DDF
/* KeySIO.cpp */
;
};
43004605260496E6000E9898
/* DuraList.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43C7232F2362E2D800D5E20E
/* DuraList.cpp */
;
};
43004606260496E6000E9898
/* Ambitus.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43C67A3125879A2B00FE7724
/* Ambitus.cpp */
;
};
43004607260496E6000E9898
/* Clef.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43F2B531248658A30035F5BA
/* Clef.cpp */
;
};
...
...
@@ -474,6 +473,7 @@
4357721C203F1ADC0080B75A
/* RT.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
325F85B01DDCC7490053A732
/* RT.cpp */
;
};
4357C18D2303F7F700D66E74
/* TestTableInstances.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
4357C18C2303F7F700D66E74
/* TestTableInstances.cpp */
;
};
4357C18F2303FD7E00D66E74
/* TestTableParse.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
4357C18E2303FD7E00D66E74
/* TestTableParse.cpp */
;
};
435856BF261F4A9F00139C02
/* KeySIO.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
43CDB7932577899500956DDF
/* KeySIO.cpp */
;
};
4359236425231D27007CA0EF
/* RTU.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
432C481323C3881500300C68
/* RTU.cpp */
;
};
4359236525231D27007CA0EF
/* MTU.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
432C481023C362D000300C68
/* MTU.cpp */
;
};
4359236625231D27007CA0EF
/* AMTU.cpp in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
434E2D9A22181DCF00C03781
/* AMTU.cpp */
;
};
...
...
@@ -3149,7 +3149,6 @@
43004600260496E6000E9898
/* KeyS.cpp in Sources */
,
43004601260496E6000E9898
/* KeySI.cpp in Sources */
,
43004603260496E6000E9898
/* KeySIR.cpp in Sources */
,
43004604260496E6000E9898
/* KeySIO.cpp in Sources */
,
43004605260496E6000E9898
/* DuraList.cpp in Sources */
,
43004606260496E6000E9898
/* Ambitus.cpp in Sources */
,
43004607260496E6000E9898
/* Clef.cpp in Sources */
,
...
...
@@ -3374,6 +3373,7 @@
43F340D823FE980F00E2DC89
/* Continuation.cpp in Sources */
,
439E5D2C257E76F100862F2C
/* PitchedNote.cpp in Sources */
,
4331FC6A259B320500895F0F
/* StaffRange.cpp in Sources */
,
435856BF261F4A9F00139C02
/* KeySIO.cpp in Sources */
,
43F340DB23FE9CAE00E2DC89
/* Tied.cpp in Sources */
,
43F340DE23FE9CC500E2DC89
/* Dot.cpp in Sources */
,
43F340D523FE96C800E2DC89
/* LeafEvent.cpp in Sources */
,
...
...
src/parsing/KeyS.cpp
View file @
9fef3f80
...
...
@@ -23,6 +23,7 @@ _state(s)
{
}
// successor key (fs or ns or instance)
KeyS
::
KeyS
(
const
KeyS
&
k
,
RunInner
<
KeyS
>&
r
,
const
ParsingEnv
&
env
)
...
...
src/parsing/KeySI.cpp
View file @
9fef3f80
...
...
@@ -43,12 +43,22 @@ _barlen(len)
KeySI
::
KeySI
(
const
KeySI
&
k
,
RunInner
<
KeySI
>&
r
,
const
ParsingEnv
&
env
)
:
KeyS
(
k
,
(
RunInner
<
KeyS
>&
)
r
,
env
),
_barlen
(
k
.
_barlen
)
// k is the parent (fs, ns) or matcher (instanciate)
{
init
(
k
,
r
,
env
);
}
void
KeySI
::
init
(
const
KeySI
&
k
,
RunInner
<
KeySI
>&
r
,
const
ParsingEnv
&
env
)
{
assert
(
r
.
inner
());
const
Transition
&
t
=
r
.
origin
();
assert
(
t
.
inner
());
assert
(
0
<
t
.
size
());
assert
(
t
.
size
()
<=
t
.
arity
());
assert
((
!
SymbLabel
::
bar
(
t
.
label
()))
||
(
t
.
arity
()
==
2
));
assert
((
!
SymbLabel
::
bar
(
t
.
label
()))
||
(
t
.
multiplicity
(
0
)
==
1
));
// first child, k is parent
if
(
r
.
empty
())
...
...
@@ -63,9 +73,8 @@ _barlen(k._barlen) // k is the parent (fs, ns) or matcher (instanciate)
assert
(
r
.
size
()
==
t
.
size
());
assert
(
_state
==
k
.
_state
);
// check downcast of KeyS
assert
(
r
.
size
()
>
0
);
const
KeySI
*
last
=
r
.
key
(
r
.
size
()
-
1
);
assert
(
last
);
init_instanciate
(
k
,
*
last
,
t
,
env
);
assert
(
r
.
key
(
r
.
size
()
-
1
));
// last sibling
init_instanciate
(
k
,
*
(
r
.
key
(
r
.
size
()
-
1
)),
t
,
env
);
}
// next sibling
else
...
...
@@ -75,9 +84,8 @@ _barlen(k._barlen) // k is the parent (fs, ns) or matcher (instanciate)
assert
(
0
<
i
);
// there is at least one previous sibling
assert
(
i
<
t
.
size
());
// r partial
assert
(
_state
==
t
.
state
(
i
));
// check downcast of KeyS
const
KeySI
*
last
=
r
.
key
(
i
-
1
);
assert
(
last
);
init_nextsibling
(
k
,
*
last
,
t
,
i
,
env
);
assert
(
r
.
key
(
i
-
1
));
// last sibling
init_nextsibling
(
k
,
*
(
r
.
key
(
i
-
1
)),
t
,
i
,
env
);
}
}
...
...
@@ -411,13 +419,13 @@ RunTerm* KeySI::failRun(const ParsingEnv& env) const
assert
(
env
.
wta
);
const
Transition
&
t0
=
env
.
dummyTransition_zero
();
assert
(
t0
.
weight
().
zero
());
assert
(
_interval
);
if
(
!
_interval
->
aligned
())
{
assert
(
env
.
segment
);
_interval
->
align
(
env
.
segment
);
}
label_t
a
=
SymbLabel
::
make_fail
(
this
->
size
());
assert
(
_interval
);
size_t
length
=
_interval
->
size
();
return
new
RunTerm
(
t0
,
a
,
t0
.
weight
(),
length
);
}
...
...
src/parsing/KeySI.hpp
View file @
9fef3f80
...
...
@@ -46,7 +46,6 @@ public:
/// if false, the right bound is set to the duration of input segment.
KeySI
(
rtu_t
barlen
,
const
ParsingEnv
&
env
,
bool
f_open
=
true
);
/// @brief constructor of a successor of a key to complete an inner run.
/// @param k target key for the run. can be partial.
/// @param r an inner run to be completed with the key constructed.
...
...
@@ -129,16 +128,53 @@ protected:
/// @brief constructor for internal use
KeySI
(
state_t
s
,
IntervalTree
*
node
,
rtu_t
barlen
);
/// @param k target key for the run. can be partial.
/// @param r an inner run to be completed with the key initialized.
/// @param env input environment.
virtual
void
init
(
const
KeySI
&
k
,
RunInner
<
KeySI
>&
r
,
const
ParsingEnv
&
env
);
/// @param k parent of this key
/// @param t base wta transition to be augmented with the constructed key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_firstchild
(
const
KeySI
&
k
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
/// @param parent parent of this key (target of the run it belongs to).
/// @param prev previous sibling of this key (in the run it belongs to).
/// @param t base wta transition to be augmented with the constructed key.
/// @param i index of the next sibling in run (and transition)
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_nextsibling
(
const
KeySI
&
parent
,
const
KeySI
&
prev
,
const
Transition
&
t
,
size_t
i
,
const
ParsingEnv
&
env
);
/// @param head key to be instanciated (i.e. this key will be an instance of k).
/// @param last complete key, last child of this key.
/// @param t base wta transition to be augmented, with the constructed target key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_instanciate
(
const
KeySI
&
head
,
const
KeySI
&
last
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
/// @brief accessor
virtual
size_t
size
()
const
;
// @brief number of points to read in the input segment
// in order to make a transition to this Key state.
// @todo RM : replaced by size()
// virtual inline size_t points() const { return _interval->lsize(); }
/// @brief accessor
virtual
size_t
size
()
const
;
bool
equal_interval
(
const
KeySI
&
)
const
;
/// add to the given stack some terminal runs built from the given transition.
/// @param t transition to build terminal runs. must be terminal and complete.
/// @param st a stack to be filled with pairs containing terminal runs.
...
...
@@ -177,36 +213,6 @@ protected:
private:
/// @param k parent of this key
/// @param t base wta transition to be augmented with the constructed key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_firstchild
(
const
KeySI
&
k
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
/// @param parent parent of this key (target of the run it belongs to).
/// @param prev previous sibling of this key (in the run it belongs to).
/// @param t base wta transition to be augmented with the constructed key.
/// @param i index of the next sibling in run (and transition)
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_nextsibling
(
const
KeySI
&
parent
,
const
KeySI
&
prev
,
const
Transition
&
t
,
size_t
i
,
const
ParsingEnv
&
env
);
/// @param head key to be instanciated (i.e. this key will be an instance of k).
/// @param last complete key, last child of this key.
/// @param t base wta transition to be augmented, with the constructed target key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_instanciate
(
const
KeySI
&
head
,
const
KeySI
&
last
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
// virtual void runsWTA(std::stack<RunInner<KeySI>*>& si,
// std::stack<std::pair<KeySI, RunTerm*>>& st,
// ParsingEnv& env) const;
...
...
src/parsing/KeySIO.cpp
View file @
9fef3f80
This diff is collapsed.
Click to expand it.
src/parsing/KeySIO.hpp
View file @
9fef3f80
...
...
@@ -60,6 +60,9 @@ namespace parsing{
/// the interval contains no point.
class
KeySIO
:
public
KeySI
// Key<KeySI>
{
template
<
typename
>
friend
class
RunFactory
;
public:
/// @brief top constructor.
...
...
@@ -79,90 +82,24 @@ public:
// pre_t poston = P_UNKNOWN,
// bool postlaston = false);
/// @brief copy
KeySIO
(
const
KeySIO
&
k
);
/// @brief constructor of first child.
/// construct a partial key to be instanciated as the first child of parent
/// in the body of an augmented transition.
/// @param parent head key of the augmented transition.
/// partial or complete.
/// inner must be true for parent key.
/// @param tr WTA transition, augmented by the transition partially
/// constructed here. must be inner.
/// @brief constructor of a successor of a key to complete an inner run.
/// @param k target key for the run. can be partial.
/// @param r an inner run to be completed with the key constructed.
/// @param env input environment.
KeySIO
(
const
KeySIO
&
parent
,
const
Transition
&
tr
,
const
ParsingEnv
&
env
);
/// @brief constructor for building next sibling.
/// construct a partial key to be instanciated as sibling
/// in the body of an augmented transition.
/// @param previous previous sibling of this key in the body of the
/// augmented transition. must be complete.
/// @param i position of the next sibling in body, in 1..arity-1
/// (0 is the position of the first child).
/// @param parent head key of the augmented transition
/// partial or complete.
/// @param tr SWTA transition, augmented by the transition partially
/// constructed here.
/// @param env input environment.
KeySIO
(
const
KeySIO
&
previous
,
size_t
i
,
const
KeySIO
&
parent
,
const
Transition
&
tr
,
const
ParsingEnv
&
env
);
/// There are 4 cases of construction:
/// - if r is partial and empty, construct the first child k0 to add to r.
/// k is the parent of k0 in this case.
/// - if r is partial but not empty, construct the next sibling kn to add
/// to r. k is the parent of kn in this case.
/// - if r is inner and complete, construct a complete instance of k
/// that will be the (complete) target of run r.
KeySIO
(
const
KeySIO
&
k
,
RunInner
<
KeySIO
>&
r
,
const
ParsingEnv
&
env
);
/// @brief constructor of complete instance.
/// construct a complete upgrade of the head key, by copy,
/// to be the head of an augmented transition.
/// @param head a key to be instanciated. must be partial.
/// @param a label of the augmented transition.
/// @param lastchild last child in the body of the augmented transition.
/// must be complete.
/// @param env input environment.
/// @warning should not be called for this class (head must be partial).
/// @see Key::instanciate
KeySIO
(
const
KeySIO
&
head
,
label_t
a
,
const
KeySIO
&
lastchild
,
const
ParsingEnv
&
env
);
/// @brief constructor of complete instance for a leaf.
/// @param head a key to instanciate as leaf. must be partial
/// @param a label of the augmented transition. must be terminal.
/// @param env parsing environment.
/// @warning should not be called on this class (head must be partial)
/// @warning leaf for head, with same args, must return 1.
KeySIO
(
const
KeySIO
&
head
,
label_t
a
,
const
ParsingEnv
&
env
);
/// allocate and return a special Run representing a parse failure for this key.
/// @param env parsing environment.
/// @return a pointer to a newly allocated fail run, with
/// - transition with dummy symbol, empty body, weight one in the
/// domain of the base wta in the passed environment.
/// - fail symbol
/// - weight one (in the domain of the base wta).
/// This returned run will answer succesfully to Run.fail().
Run
<
KeySIO
>*
failRun
(
const
ParsingEnv
&
env
)
const
;
/// @brief copy
KeySIO
(
const
KeySIO
&
k
);
/// @brief completion of this partial leaf key to be the head
/// of a nullary (leaf) transition augmenting tr.
/// Build and store in the given queue q
/// all ther new complete instances of this key,
/// using the parsing environment env.
/// @param tr a SWTA transition, augmented by the transition partially
/// constructed here. must be nullary (leaf, terminal).
/// @param env parsing environment.
/// @param q empty queue used to store the complete instances.
/// @warning this Key must be partial.
virtual
void
leaves
(
const
Transition
&
tr
,
const
ParsingEnv
&
env
,
std
::
queue
<
KeySIO
>&
q
)
const
;
/// destructor
virtual
~
KeySIO
();
/// @brief Key assignement.
virtual
KeySIO
&
operator
=
(
const
KeySIO
&
p
);
...
...
@@ -196,19 +133,32 @@ public:
/// @brief accessor
inline
bool
post_laston
()
const
{
return
_post_laston
;
}
/// @brief number of input to read for this KeySIO state
/// @todo RM : replaced by size()
virtual
inline
size_t
points
()
const
{
return
_pre
+
_interval
->
lsize
();
}
// @brief number of input points to read for making a transition
// to this key, with the given label symbol.
// @param a a label. must be terminal.
// @param env parsing environment.
// @return -1 if the given symbol a cannot label a transition targeting
// this key, or, otherwise, the number of points of the interval
// to read (parse) when making the transition to this Key with symbol a.
// virtual long pointsTerminalLabel(const label_t& a,
// const ParsingEnv& env) const;
/// @brief construct (augmented) runs targeting complete instances of
/// this key.
/// @param si a stack to be filled with inner runs. must be empty.
/// @param st a stack to be filled with pairs containing terminal runs.
/// must be empty.
/// @param env parsing environment, containing a wta.
// @return how many runs have been added to the stacks.
/// @warning the runs constructed are added to the given stacks.
/// - si will contain inner runs, partial or complete.
/// - st will contains pairs made of
/// - a complete instance k' of k if k is partial, and NULL otherwise.
/// - a complete terminal run targeting r'
/// All the runs in stacks must be deallocate elsewhere.
void
runs
(
std
::
stack
<
RunInner
<
KeySIO
>*>&
si
,
std
::
stack
<
std
::
pair
<
const
KeySIO
*
,
RunTerm
*>>&
st
,
ParsingEnv
&
env
)
const
;
/// allocate and return a special Run representing a parse failure for this key.
/// @param env parsing environment.
/// @return a pointer to a newly allocated fail run, with
/// - transition with dummy symbol, empty body, weight one in the
/// domain of the base wta in the passed environment.
/// - fail symbol
/// - weight one (in the domain of the base wta).
/// This returned run will answer succesfully to Run.fail().
// Run<KeySIO>* failRun(const ParsingEnv& env) const;
/// @brief printer
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
KeySIO
&
p
);
...
...
@@ -241,29 +191,72 @@ protected:
/// if the second half contains no point.
bool
_post_laston
;
/// @param k parent of this key
/// @param t base wta transition to be augmented with the constructed key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_firstchild
(
const
KeySIO
&
k
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
/// @param parent parent of this key (target of the run it belongs to).
/// @param prev previous sibling of this key (in the run it belongs to).
/// @param t base wta transition to be augmented with the constructed key.
/// @param i index of the next sibling in run (and transition)
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_nextsibling
(
const
KeySIO
&
parent
,
const
KeySIO
&
prev
,
const
Transition
&
t
,
size_t
i
,
const
ParsingEnv
&
env
);
/// @param head key to be instanciated (i.e. this key will be an instance of k).
/// @param last complete key, last child of this key.
/// @param t base wta transition to be augmented, with the constructed target key.
/// @param env parsing environment, contain an input segment,
/// and interval tree and heap.
void
init_instanciate
(
const
KeySIO
&
head
,
const
KeySIO
&
last
,
const
Transition
&
t
,
const
ParsingEnv
&
env
);
/// @brief accessor
virtual
size_t
size
()
const
;
/// add to the given stack some terminal runs built from the given transition.
/// @param t transition to build terminal runs. must be terminal and complete.
/// @param st a stack to be filled with pairs containing terminal runs.
virtual
void
RunsTerminal
(
const
Transition
&
t
,
std
::
stack
<
std
::
pair
<
const
KeySIO
*
,
RunTerm
*>>&
st
,
const
ParsingEnv
&
env
)
const
;
/// add to the given stack some inner runs built from the given transition.
/// @param t transition to build inner runs. must be inner and complete.
/// @param si a stack to be filled with inner runs.
/// @warning the runs constructed are added to the given stack.
/// They can be partial or complete.
/// They must be deallocate elsewhere.
virtual
void
RunsInner
(
const
Transition
&
t
,
std
::
stack
<
RunInner
<
KeySIO
>*>&
si
,
const
ParsingEnv
&
env
)
const
;
/// @brief weight for the case of a and tr terminal.
virtual
Weight
terminalWeight
(
label_t
a
,
const
Transition
&
tr
,
const
ParsingEnv
&
env
)
const
;
/// @brief compatibility of this key with the given label symbol.
/// @param a a label. must be terminal.
/// @param env parsing environment.
/// @return whether the given symbol a can label
/// a transition targeted by this key.
virtual
bool
filterTerminalLabel
(
const
label_t
&
a
,
const
ParsingEnv
&
env
)
const
;
private:
/// @brief constructor for internal use
KeySIO
(
state_t
s
,
IntervalTree
*
node
,
rtu_t
barlen
,
pre_t
pre
,
pre_t
pre_on
,
bool
pre_laston
,
pre_t
pre
,
pre_t
pre_on
,
bool
pre_laston
,
pre_t
post
,
pre_t
post_on
,
bool
post_laston
);
/// @brief copy and instanciate. (up-propagation of post values)
/// for internal use.
KeySIO
(
const
KeySIO
&
k
,
pre_t
post
,
pre_t
post_on
,
bool
post_laston
);
/// check that the post values are as expected.
/// @warning this key must be terminal.
bool
checkPost
(
const
ParsingEnv
&
env
)
const
;
...
...
@@ -271,6 +264,21 @@ private:
/// compute the laston flag for the interval of this key.
/// @warning the interval of this key must be aligned.
bool
laston
(
const
ParsingEnv
&
env
)
const
;
/// add to the given stack one run built from the given transition,
/// the given number of points and an weight computed from the env.
/// @param k key the run is targeting. must be complete.
/// @param n number of points in interval for the run added
/// = grace-notes + grace-rests + 1 note or -1.
/// @param t transition to build terminal runs. must be terminal and complete.
/// @param st a stack to be filled with pairs containing terminal runs.
/// @param env parsing environment, contain an input segment,
void
addTerminalRun
(
const
KeySIO
&
k
,
size_t
n
,
// nb points
const
Transition
&
t
,
std
::
stack
<
std
::
pair
<
const
KeySIO
*
,
RunTerm
*>>&
st
,
const
ParsingEnv
&
env
)
const
;
};
...
...
src/parsing/KeySIP.cpp
View file @
9fef3f80
...
...
@@ -11,6 +11,7 @@
namespace
parsing
{
// static
//pre_t KeySIP::P_UNKNOWN = -1;
...
...
@@ -24,29 +25,29 @@ namespace parsing{
//}
//
internal use
KeySIP
::
KeySIP
(
state_t
s
,
IntervalTree
*
node
,
rtu_t
barl
en
,
//
top constructor (top state = first bar)
KeySIP
::
KeySIP
(
rtu_t
barlen
,
const
ParsingEnv
&
env
,
bool
f_op
en
,
pre_t
pre
,
pre_t
post
)
:
KeySI
(
s
,
node
,
barl
en
),
KeySI
(
barlen
,
env
,
f_op
en
),
_pre
(
pre
),
_post
(
post
)
{
assert
(
node
);
assert
(
P_KNOWN
(
pre
)
);
}
//
top constructor (top state = first bar)
KeySIP
::
KeySIP
(
rtu_t
barlen
,
const
ParsingEnv
&
env
,
bool
f_op
en
,
//
internal use
KeySIP
::
KeySIP
(
state_t
s
,
IntervalTree
*
node
,
rtu_t
barl
en
,
pre_t
pre
,
pre_t
post
)
:
KeySI
(
barlen
,
env
,
f_op
en
),
KeySI
(
s
,
node
,
barl
en
),
_pre
(
pre
),
_post
(
post
)
{
assert
(
P_KNOWN
(
pre
)
);
assert
(
node
);
}
...
...
@@ -58,45 +59,44 @@ KeySI(k, (RunInner<KeySI>&) r, env),
_pre
(
k
.
_pre
),
// k is the parent (fs, ns) or matcher (instanciate)
_post
(
k
.
_post
)
{
assert
(
r
.
inner
());
const
Transition
&
t
=
r
.
origin
();
assert
(
t
.
inner
());
assert
(
0
<
t
.
size
());
assert
(
t
.
size
()
<=
t
.
arity
());
// first child, k is parent
if
(
r
.
empty
())
{
assert
(
r
.
partial
());
assert
(
_state
==
t
.
state
(
0
));
// check downcast of KeyS
init_firstchild
(
k
,
t
,
env
);
}
// instanciate head (inner case)
else
if
(
r
.
complete
())
{
assert
(
r
.
size
()
==
t
.
size
());
assert
(
_state
==
k
.
_state
);
// check downcast of KeyS
assert
(
r
.
size
()
>
0
);
const
KeySIP
*
last
=
r
.
key
(
r
.
size
()
-
1
);
assert
(
last
);
init_instanciate
(
k
,
*
last
,
t
,
env
);
}
// next sibling
else
{
assert
(
r
.
partial
());
size_t
i
=
r
.
size
();
// index of next sibling in r
assert
(
0
<
i
);
// there is at least one previous sibling
assert
(
i
<
t
.
size
());
// r partial
assert
(
_state
==
t
.
state
(
i
));
// check downcast of KeyS
const
KeySIP
*
last
=
r
.
key
(
i
-
1
);
assert
(
last
);
init_nextsibling
(
k
,
*
last
,
t
,
i
,
env
);
}
init
(
k
,
(
RunInner
<
KeySI
>&
)
r
,
env
);
// in KeySI
// assert(r.inner());
// const Transition& t = r.origin();
// assert(t.inner());
// assert(0 < t.size());
// assert(t.size() <= t.arity());
//
// // first child, k is parent
// if (r.empty())
// {
// assert(r.partial());
// assert(_state == t.state(0)); // check downcast of KeyS
// init_firstchild(k, t, env);
// }
// // instanciate head (inner case)
// else if (r.complete())
// {
// assert(r.size() == t.size());
// assert(_state == k._state); // check downcast of KeyS
// assert(r.size() > 0);
// const KeySIP* last = r.key(r.size()-1);
// assert(last);
// init_instanciate(k, *last, t, env);
// }
// // next sibling
// else
// {
// assert(r.partial());
// size_t i = r.size(); // index of next sibling in r
// assert(0 < i); // there is at least one previous sibling
// assert(i < t.size()); // r partial
// assert(_state == t.state(i)); // check downcast of KeyS
// const KeySIP* last = r.key(i-1);
// assert(last);
// init_nextsibling(k, *last, t, i, env);
// }
}
void
KeySIP
::
init_firstchild
(
const
KeySIP
&
parent
,
const
Transition
&
t
,
const
ParsingEnv
&
env
)
...
...
@@ -176,6 +176,7 @@ _pre(k._pre),
_post
(
post
)
{
assert
(
k
.
partial
());
// this key is now complete
assert
(
P_KNOWN
(
post
));
assert
(
this
->
complete
());
}
...
...
@@ -389,7 +390,6 @@ Weight KeySIP::terminalWeight(label_t a,
}
void
KeySIP
::
RunsInner
(
const
Transition
&
t
,
std
::
stack
<
RunInner
<
KeySIP
>*>&
si
,
const
ParsingEnv
&
env
)
const
...
...
@@ -429,23 +429,6 @@ void KeySIP::RunsInner(const Transition& t,
}