!7
cmodule TopDownParsing > DynSingleComponent {
S input = "Bob paid for Charlie 's college education";
TryPatterns root;
// Tree has 2 types of nodes: composite and options
class Base {
new L children;
L children() { ret children; }
}
class AppliedPattern > Base {
S pattern;
LS arguments;
}
class TryPatterns > Base {
S input;
*() {}
*(S *input) {
for (S pat : patterns())
for (LS arguments : flexMatchIC_all(pat, input))
children.add(setAll(new AppliedPatern, pattern := pat, +arguments));
}
}
start-thread {
setField(root := parse(input));
setComponent(jDynamicTree(root, root.children()));
}
LS patterns() { ret dm_getUnclearList("patterns"); }
TryPatterns parse(S s) {
ret new TryPatterns(s);
}
}