p6p
4/10/2016 - 1:44 PM

parse.cpp

void parse(string str, vector<string> &p) {
    smatch sm;
    if (regex_search(str, sm, regex("^(Add|Sub|Div|Mul|Cross|Com|Proj|Area|isParallel|isOrthogonal|angle|pN) *\\( *(.*) *, *(.*) *\\) *$"))) {
        p.push_back(sm[1]);
        parse(sm[3], p);
        parse(sm[2], p);
    }
    else if (regex_search(str, sm, regex("^(Norm|Normal|IsLI|Ob|lowerT|upperT|Rank|trans|det|Inverse|Adj) *\\( *(.*) *\\) *$"))) {
        p.push_back(sm[1]);
        parse(sm[2], p);
    } else if (regex_search(str, sm, regex("\\$[mv]\\d{3}"))) {
        p.push_back(str);
    }
}