"(/|~|,|\\^)?" // 4
"\\]\\]"
"|"
- "(:)" // 5
+ "(:|!?\\?)" // 5
")"
- ")|(" // 6
- "\\]\\]"
- ")|(" // 7
- "\\|"
")|"
+ "(\\]\\])" // 6
+ "|"
+ "(\\|\\|)" // 7
+ "|"
"&"
"(" // 8
";"
/* ============================================================ */
ustring WikiMotorObjSelect::textOut (WikiFormat* wiki) {
- ustring ans;
- return ans;
+ ustring v = wiki->getVar (name);
+ ustring val = value.textOut (wiki);
+ bool c = (v == val);
+
+ if (c ^ fneg) {
+ return trueobjs.textOut (wiki);
+ } else {
+ return falseobjs.textOut (wiki);
+ }
+}
+
+ustring WikiMotorObjSelect::htmlOut (WikiFormat* wiki) {
+ ustring v = wiki->getVar (name);
+ ustring val = value.textOut (wiki);
+ bool c = (v == val);
+
+ if (c ^ fneg) {
+ return trueobjs.htmlOut (wiki);
+ } else {
+ return falseobjs.htmlOut (wiki);
+ }
}
ustring WikiMotorObjSelect::dump () {
compile_text (out);
return;
}
- } else if (sp.match (7)) { // |
- if (tmatch & TMATCH_BAR) {
+ } else if (sp.match (7)) { // ||
+ if (tmatch & TMATCH_BAR2) {
compile_text (out);
return;
}
}
void WikiMotor::compile_2 (WikiMotorObjVec& out) { // [[
- if (sp.match (5)) { // NAME:
- compile_3 (out, ustring (sp.matchBegin (2), sp.matchEnd (2)));
+ if (sp.match (5)) { // : | !? | ?
+ uiterator b = sp.matchBegin (5);
+ switch (*b) {
+ case ':': // NAME:
+ compile_3 (out, ustring (sp.matchBegin (2), sp.matchEnd (2)));
+ break;
+ case '?': // NAME?
+ compile_6 (out, sp.matchBegin (2), sp.matchEnd (2), false);
+ break;
+ case '!': // NAME!?
+ compile_6 (out, sp.matchBegin (2), sp.matchEnd (2), true);
+ break;
+ default:
+ assert (0);
+ }
} else {
- if (sp.match (4)) {
+ if (sp.match (4)) { // / | ~ | , | ^
uiterator b = sp.matchBegin (4);
switch (*b) {
case '/':
}
}
+void WikiMotor::compile_6 (WikiMotorObjVec& out, const uiterator& b, const uiterator& e, bool fneg) { // [[NAME?
+ WikiMotorObjSelect* obj = new WikiMotorObjSelect (b, e, fneg);
+
+ out.push_back (WikiMotorObjPtr (obj));
+ compile (obj->value, TMATCH_COLN | TMATCH_CKET);
+ if (sp.match (13)) { // :
+ compile (obj->trueobjs, TMATCH_BAR2 | TMATCH_CKET);
+ if (sp.match (7)) { // ||
+ compile (obj->falseobjs, TMATCH_CKET);
+ }
+ } else {
+ // syntax error
+ }
+}
+
/* ============================================================ */
void join (WikiMotorObjVecVec::const_iterator b, WikiMotorObjVecVec::const_iterator e, const ustring& ch, WikiMotorObjVec& ans) {
WikiMotorObjVec* v;
class WikiMotorObjSelect: public WikiMotorObj {
public:
- ustring variable;
+ ustring name;
WikiMotorObjVec value;
- bool fbang;
+ bool fneg;
WikiMotorObjVec trueobjs;
WikiMotorObjVec falseobjs;
- WikiMotorObjSelect (uiterator b, uiterator e, bool neg): WikiMotorObj (wiki_select) {
- variable.assign (b, e);
- fbang = neg;
+ WikiMotorObjSelect (uiterator b, uiterator e, bool _neg): WikiMotorObj (wiki_select) {
+ name.assign (b, e);
+ fneg = _neg;
};
virtual ~WikiMotorObjSelect () {};
virtual ustring textOut (WikiFormat* wiki);
+ virtual ustring htmlOut (WikiFormat* wiki);
virtual ustring dump ();
};
static const int TMATCH_COLN = 0x02;
static const int TMATCH_SPC = 0x04;
static const int TMATCH_QUOT = 0x08;
- static const int TMATCH_BAR = 0x10;
+ static const int TMATCH_BAR2 = 0x10;
WikiFormat* wiki;
Splitter sp;
virtual void compile_3 (WikiMotorObjVec& out, const ustring& name);
virtual bool compile_4 (WikiMotorObjVec& out, const ustring& name);
virtual void compile_5 (WikiMotorObjVec& out, int nchar);
+ virtual void compile_6 (WikiMotorObjVec& out, const uiterator& b, const uiterator& e, bool fneg);
};
void join (WikiMotorObjVecVec::const_iterator b, WikiMotorObjVecVec::const_iterator e, const ustring& ch, WikiMotorObjVec& ans);