supernova: allocators - fix construct method
[supercollider.git] / external_libraries / yaml-cpp-0.2.6 / src / scantag.cpp
blobb71cbcc49f44cea6fb3e8ffdafd3cddf1826338f
1 #include "scanner.h"
2 #include "regex.h"
3 #include "exp.h"
4 #include "yaml-cpp/exceptions.h"
6 namespace YAML
8 const std::string ScanVerbatimTag(Stream& INPUT)
10 std::string tag;
12 // eat the start character
13 INPUT.get();
15 while(INPUT) {
16 if(INPUT.peek() == Keys::VerbatimTagEnd) {
17 // eat the end character
18 INPUT.get();
19 return tag;
22 int n = Exp::URI().Match(INPUT);
23 if(n <= 0)
24 break;
26 tag += INPUT.get(n);
29 throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG);
32 const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle)
34 std::string tag;
35 canBeHandle = true;
36 Mark firstNonWordChar;
38 while(INPUT) {
39 if(INPUT.peek() == Keys::Tag) {
40 if(!canBeHandle)
41 throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE);
42 break;
45 int n = 0;
46 if(canBeHandle) {
47 n = Exp::Word().Match(INPUT);
48 if(n <= 0) {
49 canBeHandle = false;
50 firstNonWordChar = INPUT.mark();
54 if(!canBeHandle)
55 n = Exp::Tag().Match(INPUT);
57 if(n <= 0)
58 break;
60 tag += INPUT.get(n);
63 return tag;
66 const std::string ScanTagSuffix(Stream& INPUT)
68 std::string tag;
70 while(INPUT) {
71 int n = Exp::Tag().Match(INPUT);
72 if(n <= 0)
73 break;
75 tag += INPUT.get(n);
78 if(tag.empty())
79 throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX);
81 return tag;