MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / scan

Method scan

modules/gdscript/gdscript_tokenizer.cpp:1366–1648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1364}
1365
1366GDScriptTokenizer::Token GDScriptTokenizerText::scan() {
1367 if (has_error()) {
1368 return pop_error();
1369 }
1370
1371 _skip_whitespace();
1372
1373 if (pending_newline) {
1374 pending_newline = false;
1375 if (!multiline_mode) {
1376 // Don't return newline tokens on multiline mode.
1377 return last_newline;
1378 }
1379 }
1380
1381 // Check for potential errors after skipping whitespace().
1382 if (has_error()) {
1383 return pop_error();
1384 }
1385
1386 _start = _current;
1387 start_line = line;
1388 start_column = column;
1389
1390 if (pending_indents != 0) {
1391 // Adjust position for indent.
1392 _start -= start_column - 1;
1393 start_column = 1;
1394 if (pending_indents > 0) {
1395 // Indents.
1396 pending_indents--;
1397 return make_token(Token::INDENT);
1398 } else {
1399 // Dedents.
1400 pending_indents++;
1401 Token dedent = make_token(Token::DEDENT);
1402 dedent.end_column += 1;
1403 return dedent;
1404 }
1405 }
1406
1407 if (_is_at_end()) {
1408 return make_token(Token::TK_EOF);
1409 }
1410
1411 const char32_t c = _advance();
1412
1413 if (c == '\\') {
1414 // Line continuation with backslash.
1415 if (_peek() == '\r') {
1416 if (_peek(1) != '\n') {
1417 return make_error("Unexpected carriage return character.");
1418 }
1419 _advance();
1420 }
1421 if (_peek() != '\n') {
1422 return make_error("Expected new line after \"\\\".");
1423 }

Callers 10

parseMethod · 0.45
parse_binaryMethod · 0.45
advanceMethod · 0.45
push_multilineMethod · 0.45
parse_lambdaMethod · 0.45
get_classes_usedMethod · 0.45
find_functionMethod · 0.45
update_document_linksMethod · 0.45
test_tokenizerFunction · 0.45
test_tokenizer_bufferFunction · 0.45

Calls 6

is_digitFunction · 0.85
is_whitespaceFunction · 0.85
vformatFunction · 0.85
can_precede_bin_opMethod · 0.80
push_backMethod · 0.45

Tested by 2

test_tokenizerFunction · 0.36
test_tokenizer_bufferFunction · 0.36