MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / parse

Method parse

src/common/Tokens.cpp:57–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void Tokens::parse(FB_SIZE_T length, const char* toParse)
58{
59 tokens.clear();
60
61 if (!length)
62 length = strlen(toParse);
63 str.assign(toParse, length);
64
65 char inStr = '\0';
66 Tok* inToken = NULL;
67 FB_SIZE_T startp = 0;
68 FB_SIZE_T origin = 0;
69
70 FB_SIZE_T p = 0;
71
72 while (p < str.length())
73 {
74 if (comms && !inStr)
75 {
76 bool foundComment = false;
77
78 for (const Comment* comm = comms; comm->start; ++comm)
79 {
80 if (strncmp(comm->start, &str[p], strlen(comm->start)) == 0)
81 {
82 FB_SIZE_T p2 = p + strlen(comm->start);
83 p2 = str.find(comm->stop, p2);
84
85 if (p2 == str.npos)
86 {
87 if (!comm->endOnEol)
88 error("Missing close comment for %s", comm->start);
89 p2 = str.length();
90 }
91 else
92 p2 += strlen(comm->stop);
93
94 str.erase(p, p2 - p);
95 origin += (p2 - p);
96 foundComment = true;
97 break;
98 }
99 }
100
101 if (foundComment)
102 continue;
103 }
104
105 char c = str[p];
106
107 if (inStr)
108 {
109 if (c == inStr)
110 {
111 ++p;
112 ++origin;
113
114 if (p >= str.length() || str[p] != inStr)

Callers

nothing calls this directly

Calls 6

errorFunction · 0.70
clearMethod · 0.45
assignMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected