MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / scan

Method scan

bytecode/gdscript_v2_tokenizer_compat.cpp:1186–1473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184}
1185
1186GDScriptV2TokenizerCompat::Token GDScriptV2TokenizerCompatText::scan() {
1187 if (has_error()) {
1188 return pop_error();
1189 }
1190
1191 _skip_whitespace();
1192
1193 if (pending_newline) {
1194 pending_newline = false;
1195 if (!multiline_mode) {
1196 // Don't return newline tokens on multiline mode.
1197 return last_newline;
1198 }
1199 }
1200
1201 // Check for potential errors after skipping whitespace().
1202 if (has_error()) {
1203 return pop_error();
1204 }
1205
1206 _start = _current;
1207 start_line = line;
1208 start_column = column;
1209 leftmost_column = column;
1210 rightmost_column = column;
1211
1212 if (pending_indents != 0) {
1213 // Adjust position for indent.
1214 _start -= start_column - 1;
1215 start_column = 1;
1216 leftmost_column = 1;
1217 if (pending_indents > 0) {
1218 // Indents.
1219 pending_indents--;
1220 return make_token(Token::Type::G_TK_INDENT);
1221 } else {
1222 // Dedents.
1223 pending_indents++;
1224 Token dedent = make_token(Token::Type::G_TK_DEDENT);
1225 dedent.end_column += 1;
1226 dedent.rightmost_column += 1;
1227 return dedent;
1228 }
1229 }
1230
1231 if (_is_at_end()) {
1232 return make_token(Token::Type::G_TK_EOF);
1233 }
1234
1235 const char32_t c = _advance();
1236
1237 if (c == '\\') {
1238 // Line continuation with backslash.
1239 if (_peek() == '\r') {
1240 if (_peek(1) != '\n') {
1241 return make_error("Unexpected carriage return character.");
1242 }
1243 _advance();

Callers

nothing calls this directly

Calls 4

scanFunction · 0.85
push_backMethod · 0.80
can_precede_bin_opMethod · 0.80
get_local_token_valMethod · 0.45

Tested by

no test coverage detected