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

Method _get_token

core/math/expression.cpp:43–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#include "core/object/class_db.h"
42
43Error Expression::_get_token(Token &r_token) {
44 while (true) {
45#define GET_CHAR() (str_ofs >= expression.length() ? 0 : expression[str_ofs++])
46
47 char32_t cchar = GET_CHAR();
48
49 switch (cchar) {
50 case 0: {
51 r_token.type = TK_EOF;
52 return OK;
53 }
54 case '{': {
55 r_token.type = TK_CURLY_BRACKET_OPEN;
56 return OK;
57 }
58 case '}': {
59 r_token.type = TK_CURLY_BRACKET_CLOSE;
60 return OK;
61 }
62 case '[': {
63 r_token.type = TK_BRACKET_OPEN;
64 return OK;
65 }
66 case ']': {
67 r_token.type = TK_BRACKET_CLOSE;
68 return OK;
69 }
70 case '(': {
71 r_token.type = TK_PARENTHESIS_OPEN;
72 return OK;
73 }
74 case ')': {
75 r_token.type = TK_PARENTHESIS_CLOSE;
76 return OK;
77 }
78 case ',': {
79 r_token.type = TK_COMMA;
80 return OK;
81 }
82 case ':': {
83 r_token.type = TK_COLON;
84 return OK;
85 }
86 case '$': {
87 r_token.type = TK_INPUT;
88 int index = 0;
89 do {
90 if (!is_digit(expression[str_ofs])) {
91 _set_error("Expected number after '$'");
92 r_token.type = TK_ERROR;
93 return ERR_PARSE_ERROR;
94 }
95 index *= 10;
96 index += expression[str_ofs] - '0';
97 str_ofs++;
98
99 } while (is_digit(expression[str_ofs]));
100

Callers

nothing calls this directly

Calls 11

is_digitFunction · 0.85
is_hex_digitFunction · 0.85
is_binary_digitFunction · 0.85
to_floatMethod · 0.80
bin_to_intMethod · 0.80
hex_to_intMethod · 0.80
to_intMethod · 0.80
VariantClass · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected