--- a/src/parser.cpp Sun Sep 22 11:51:41 2019 +0300 +++ b/src/parser.cpp Mon Sep 23 14:06:36 2019 +0300 @@ -262,6 +262,52 @@ } } +namespace +{ + namespace regexes + { + static const QRegExp comment {R"(^\s*0\s*\/\/\s*(.+)$)"}; + static const QRegExp metacommand {R"(^\s*0\s*(.+)$)"}; + static const QRegExp edgeline + { + R"(^\s*2)" // starting 2-token + R"(\s+(\d+))" // colour + R"(((?:\s+[^\s]+){3}))" // 1st vertex + R"(((?:\s+[^\s]+){3}))" // 2nd vertex + R"(\s*$)" // end + }; + static const QRegExp triangle + { + R"(^\s*3)" // starting 3-token + R"(\s+(\d+))" // colour + R"(((?:\s+[^\s]+){3}))" // 1st vertex + R"(((?:\s+[^\s]+){3}))" // 2nd vertex + R"(((?:\s+[^\s]+){3}))" // 3rd vertex + R"(\s*$)" // end + }; + static const QRegExp quadrilateral + { + R"(^\s*4)" // starting 4-token + R"(\s+(\d+))" // colour + R"(((?:\s+[^\s]+){3}))" // 1st vertex + R"(((?:\s+[^\s]+){3}))" // 2nd vertex + R"(((?:\s+[^\s]+){3}))" // 3rd vertex + R"(((?:\s+[^\s]+){3}))" // 4th vertex + R"(\s*$)" // end + }; + static const QRegExp conditionaledge + { + R"(^\s*5)" // starting 5-token + R"(\s+(\d+))" // colour + R"(((?:\s+[^\s]+){3}))" // 1st vertex + R"(((?:\s+[^\s]+){3}))" // 2nd vertex + R"(((?:\s+[^\s]+){3}))" // 1st control point + R"(((?:\s+[^\s]+){3}))" // 2nd control point + R"(\s*$)" // end + }; + } +} + modelobjects::BaseObject* Parser::parseFromString( Model::EditContext& editor, const QString& line)