aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/yaml-cpp/src/scantag.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2019-07-30 15:26:31 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2019-08-30 08:42:22 +0000
commit0ba729e527da37f7c5d7fbc59247971df3da7d8a (patch)
treef6397a18ab4a7850b656f7b6e7a68f3d8a4e49ae /src/libs/3rdparty/yaml-cpp/src/scantag.cpp
parentd663b8e406c89585f123207d6e07832d1818e53b (diff)
Import YAML-Parser yaml-cpp
Version: tags/yaml-cpp-0.6.2 License: MIT yaml-cpp requires c++11 and since yaml-cpp 0.6 there is no dependency on boost anymore. A YAML parser is needed for the ClangTools plugin to parse exported diagnostics from clang-tidy/clazy: $ clang-tidy -export-fixes=/tmp/tidy.yaml source.cpp The imported source is stripped of unneeded files as documented with src/libs/3rdparty/yaml-cpp/patches/0001-yaml-cpp-Strip-unneeded-sources.patch (generated with "git format-patch -D") Change-Id: Ib0a521b5aff4b1cd058eb480bfb99fde4b320dc7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs/3rdparty/yaml-cpp/src/scantag.cpp')
-rw-r--r--src/libs/3rdparty/yaml-cpp/src/scantag.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/libs/3rdparty/yaml-cpp/src/scantag.cpp b/src/libs/3rdparty/yaml-cpp/src/scantag.cpp
new file mode 100644
index 00000000000..c5b39652ad0
--- /dev/null
+++ b/src/libs/3rdparty/yaml-cpp/src/scantag.cpp
@@ -0,0 +1,81 @@
+#include "exp.h"
+#include "regex_yaml.h"
+#include "regeximpl.h"
+#include "stream.h"
+#include "yaml-cpp/exceptions.h" // IWYU pragma: keep
+#include "yaml-cpp/mark.h"
+
+namespace YAML {
+const std::string ScanVerbatimTag(Stream& INPUT) {
+ std::string tag;
+
+ // eat the start character
+ INPUT.get();
+
+ while (INPUT) {
+ if (INPUT.peek() == Keys::VerbatimTagEnd) {
+ // eat the end character
+ INPUT.get();
+ return tag;
+ }
+
+ int n = Exp::URI().Match(INPUT);
+ if (n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG);
+}
+
+const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) {
+ std::string tag;
+ canBeHandle = true;
+ Mark firstNonWordChar;
+
+ while (INPUT) {
+ if (INPUT.peek() == Keys::Tag) {
+ if (!canBeHandle)
+ throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE);
+ break;
+ }
+
+ int n = 0;
+ if (canBeHandle) {
+ n = Exp::Word().Match(INPUT);
+ if (n <= 0) {
+ canBeHandle = false;
+ firstNonWordChar = INPUT.mark();
+ }
+ }
+
+ if (!canBeHandle)
+ n = Exp::Tag().Match(INPUT);
+
+ if (n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ return tag;
+}
+
+const std::string ScanTagSuffix(Stream& INPUT) {
+ std::string tag;
+
+ while (INPUT) {
+ int n = Exp::Tag().Match(INPUT);
+ if (n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ if (tag.empty())
+ throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX);
+
+ return tag;
+}
+}