scantag.cpp
Go to the documentation of this file.
1 #include "scanner.h"
2 #include "regex.h"
3 #include "exp.h"
5 
6 namespace YAML_PM
7 {
9  {
10  std::string tag;
11 
12  // eat the start character
13  INPUT.get();
14 
15  while(INPUT) {
16  if(INPUT.peek() == Keys::VerbatimTagEnd) {
17  // eat the end character
18  INPUT.get();
19  return tag;
20  }
21 
22  int n = Exp::URI().Match(INPUT);
23  if(n <= 0)
24  break;
25 
26  tag += INPUT.get(n);
27  }
28 
30  }
31 
32  const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle)
33  {
34  std::string tag;
35  canBeHandle = true;
36  Mark firstNonWordChar;
37 
38  while(INPUT) {
39  if(INPUT.peek() == Keys::Tag) {
40  if(!canBeHandle)
41  throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE);
42  break;
43  }
44 
45  int n = 0;
46  if(canBeHandle) {
47  n = Exp::Word().Match(INPUT);
48  if(n <= 0) {
49  canBeHandle = false;
50  firstNonWordChar = INPUT.mark();
51  }
52  }
53 
54  if(!canBeHandle)
55  n = Exp::Tag().Match(INPUT);
56 
57  if(n <= 0)
58  break;
59 
60  tag += INPUT.get(n);
61  }
62 
63  return tag;
64  }
65 
67  {
68  std::string tag;
69 
70  while(INPUT) {
71  int n = Exp::Tag().Match(INPUT);
72  if(n <= 0)
73  break;
74 
75  tag += INPUT.get(n);
76  }
77 
78  if(tag.empty())
80 
81  return tag;
82  }
83 }
84 
const char VerbatimTagEnd
Definition: exp.h:192
const char *const CHAR_IN_TAG_HANDLE
Definition: exceptions.h:26
const char *const TAG_WITH_NO_SUFFIX
Definition: exceptions.h:27
::std::string string
Definition: gtest.h:1979
const std::string ScanVerbatimTag(Stream &INPUT)
Definition: scantag.cpp:8
const char *const END_OF_VERBATIM_TAG
Definition: exceptions.h:28
const std::string ScanTagHandle(Stream &INPUT, bool &canBeHandle)
Definition: scantag.cpp:32
int Match(const std::string &str) const
Definition: regeximpl.h:42
char peek() const
Definition: stream.cpp:228
const char Tag
Definition: exp.h:188
const RegEx & Word()
Definition: exp.h:54
const RegEx & Tag()
Definition: exp.h:129
const Mark mark() const
Definition: stream.h:38
const std::string ScanTagSuffix(Stream &INPUT)
Definition: scantag.cpp:66
const RegEx & URI()
Definition: exp.h:125


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03