MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / ReadNextToken

Method ReadNextToken

libraries/muparser/src/muParserTokenReader.cpp:263–346  ·  view source on GitHub ↗

\brief Read the next token from the string. */

Source from the content-addressed store, hash-verified

261
262 /** \brief Read the next token from the string. */
263 ParserTokenReader::token_type ParserTokenReader::ReadNextToken()
264 {
265 MUP_ASSERT(m_pParser != nullptr);
266
267 const char_type* szExpr = m_strFormula.c_str();
268 token_type tok;
269
270 // Ignore all non printable characters when reading the expression
271 while (szExpr[m_iPos] > 0 && szExpr[m_iPos] <= 0x20)
272 {
273 // 14-31 are control characters. I don�t want to have to deal with such strings at all!
274 // (see https://en.cppreference.com/w/cpp/string/byte/isprint)
275 if (szExpr[m_iPos] >= 14 && szExpr[m_iPos] <= 31)
276 Error(ecINVALID_CHARACTERS_FOUND, m_iPos);
277
278 ++m_iPos;
279 }
280
281 // Check for end of formula
282 if (IsEOF(tok))
283 return SaveBeforeReturn(tok);
284
285 // Check for user defined binary operator
286 if (IsOprt(tok))
287 return SaveBeforeReturn(tok);
288
289 // Check for function token
290 if (IsFunTok(tok))
291 return SaveBeforeReturn(tok);
292
293 // Check built in operators / tokens
294 if (IsBuiltIn(tok))
295 return SaveBeforeReturn(tok);
296
297 // Check for function argument separators
298 if (IsArgSep(tok))
299 return SaveBeforeReturn(tok);
300
301 // Check for values / constant tokens
302 if (IsValTok(tok))
303 return SaveBeforeReturn(tok);
304
305 // Check for variable tokens
306 if (IsVarTok(tok))
307 return SaveBeforeReturn(tok);
308
309 // Check for string variables
310 if (IsStrVarTok(tok))
311 return SaveBeforeReturn(tok);
312
313 // Check for String tokens
314 if (IsString(tok))
315 return SaveBeforeReturn(tok);
316
317 // Check for unary operators
318 if (IsInfixOpTok(tok))
319 return SaveBeforeReturn(tok);
320

Callers 1

CreateRPNMethod · 0.80

Calls 1

ValidNameCharsMethod · 0.80

Tested by

no test coverage detected