| 11500 | return this.next(); |
| 11501 | } |
| 11502 | lex(token) { |
| 11503 | while (this.buffer[this.position] === ' ') { |
| 11504 | this.position += 1; |
| 11505 | } |
| 11506 | let i = this.position; |
| 11507 | if (i >= this.buffer.length) { |
| 11508 | token.kind = '\0'; |
| 11509 | token.value = ''; |
| 11510 | } else if (this.buffer[i] === '.' && this.buffer[i + 1] === '.' && this.buffer[i + 2] === '.') { |
| 11511 | token.kind = '...'; |
| 11512 | token.value = '...'; |
| 11513 | /* } else if (this.buffer[i] === '[' && this.buffer[i + 1] === ']') { |
| 11514 | this.kind = '[]'; |
| 11515 | this.value = '[]'; */ |
| 11516 | } else if (this.buffer[i] === '(' || this.buffer[i] === ')' || this.buffer[i] === ':' || this.buffer[i] === '.' || this.buffer[i] === '[' || this.buffer[i] === ']' || this.buffer[i] === ',' || this.buffer[i] === '=' || this.buffer[i] === '?' || this.buffer[i] === '!' || this.buffer[i] === '*' || this.buffer[i] === '|') { |
| 11517 | token.kind = this.buffer[i]; |
| 11518 | token.value = this.buffer[i]; |
| 11519 | } else if ((this.buffer[i] >= 'a' && this.buffer[i] <= 'z') || (this.buffer[i] >= 'A' && this.buffer[i] <= 'Z') || this.buffer[i] === '_') { |
| 11520 | i += 1; |
| 11521 | while (i < this.buffer.length && ((this.buffer[i] >= 'a' && this.buffer[i] <= 'z') || (this.buffer[i] >= 'A' && this.buffer[i] <= 'Z') || (this.buffer[i] >= '0' && this.buffer[i] <= '9') || this.buffer[i] === '_')) { |
| 11522 | i += 1; |
| 11523 | } |
| 11524 | token.kind = 'id'; |
| 11525 | token.value = this.buffer.slice(this.position, i); |
| 11526 | } else if (this.buffer[i] === '-' && this.buffer[i + 1] === '>') { |
| 11527 | token.kind = '->'; |
| 11528 | token.value = '->'; |
| 11529 | } else if ((this.buffer[i] >= '0' && this.buffer[i] <= '9') || this.buffer[i] === '-') { |
| 11530 | i += 1; |
| 11531 | while (i < this.buffer.length && ((this.buffer[i] >= '0' && this.buffer[i] <= '9') || this.buffer[i] === '.' || this.buffer[i] === 'e' || this.buffer[i] === '-')) { |
| 11532 | i += 1; |
| 11533 | } |
| 11534 | token.kind = '#'; |
| 11535 | token.value = this.buffer.slice(this.position, i); |
| 11536 | } else if (this.buffer[i] === "'" || this.buffer[i] === '"') { |
| 11537 | const quote = this.buffer[i]; |
| 11538 | i += 1; |
| 11539 | while (i < this.buffer.length && this.buffer[i] !== quote) { |
| 11540 | i += (this.buffer[i] === '\\' && (this.buffer[i + 1] === "'" || this.buffer[i + 1] === '"' || this.buffer[i + 1] === '\\')) ? 2 : 1; |
| 11541 | } |
| 11542 | i += 1; |
| 11543 | token.kind = 'string'; |
| 11544 | token.value = this.buffer.slice(this.position, i); |
| 11545 | } else { |
| 11546 | throw new python.Error(`Unsupported token at '${this.position}'.`); |
| 11547 | } |
| 11548 | } |
| 11549 | }); |
| 11550 | this.registerType('torch._C.SchemaTypeParser', class { |
| 11551 | constructor(L, complete_tensor_types, allow_typevars) { |