21 if (current[1] ==
'/') {
22 while (*current !=
'\n' && !IsAtEnd()) Advance();
39 return c >=
'0' && c <=
'9';
43 return (c >=
'a' && c <=
'z') ||
44 (c >=
'A' && c <=
'Z') ||
60 if (
isAlpha(c))
return Identifier();
83 return MakeToken(Match(
'=') ?
85 case '"':
return String();
88 return ErrorToken(
"Unexpected character.");
92 if (IsAtEnd())
return false;
93 if (*current != c)
return false;
105 return *current ==
'\0';
112 token.
length = current - start;
117 while (*current !=
'"' && !IsAtEnd()) {
121 if (IsAtEnd())
return ErrorToken(
"Unterminated string.");
128 while (
isDigit(*current)) Advance();
130 if (*current ==
'.') {
134 while (
isDigit(*current)) Advance();
141 static const std::vector<std::string>
keywords {
"and",
"or",
"if",
"else",
"for",
"while",
"return",
"true",
"false",
"fun",
"nil",
"var",
"print",
"length",
"fields"};
142 static const std::vector<uscript::TokenType> keyword_types {
159 std::string comp = std::string(start, current);
160 for (
unsigned i = 0; i <
keywords.size(); i++) {
161 if (strcmp(comp.c_str(),
keywords[i].c_str()) == 0) {
162 return keyword_types[i];
172 return MakeToken(IdentifierType());
179 token.
length = (int)strlen(message);
Token ErrorToken(const char *message) const
void SetSource(const char *_start)
TokenType IdentifierType() const
static bool isAlpha(char c)
Token MakeToken(TokenType type) const
static bool isDigit(char c)
process_name showerreco Particles Coinciding wih the Vertex services ScanOptions nu_mu services ScanOptions Number