MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / parseToken

Method parseToken

src/engine/ConsoleInterpreter.cpp:127–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 Token Lexer::parseToken()
128 {
129 Token token;
130
131 bool inString = true;
132 bool inEscape = false;
133 bool inQuotes = false;
134
135 for ( ;!m_Eof && inString && !std::isspace(m_Next); advance())
136 {
137 if (inEscape)
138 {
139 token.value.push_back(m_Next);
140 inEscape = false;
141 }
142 else
143 {
144 switch (m_Next)
145 {
146 case '\\': inEscape = true; break;
147 case '\'':
148 case '\"': inString = inQuotes = !inQuotes; break;
149 default:
150 token.value.push_back(m_Next);
151 }
152 }
153 }
154
155 if (!m_Eof && !std::isspace(m_Next))
156 m_Error = Error::UNEXPECTED_STRING_ENDING;
157 if (inEscape)
158 m_Error = Error::MISSING_ESCAPED_CHARACTER;
159 if (inQuotes)
160 m_Error = Error::MISSING_QUOTE_ENDING;
161
162 if (m_Error == Error::NONE)
163 {
164 token.type = TokenType::STRING;
165 parseSpace();
166 return token;
167 }
168 return Token();
169 }
170
171 //
172 // Interpreter implementation

Callers

nothing calls this directly

Calls 2

TokenClass · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected