()
| 1920 | return position + 1; |
| 1921 | } |
| 1922 | _tokenize() { |
| 1923 | if (this._token.type !== '\n') { |
| 1924 | this._skipWhitespace(); |
| 1925 | } |
| 1926 | if (this._token.type === 'dedent') { |
| 1927 | this._indentation.pop(); |
| 1928 | this._outdent--; |
| 1929 | if (this._outdent > 0) { |
| 1930 | this._token = { type: 'dedent', value: '' }; |
| 1931 | return; |
| 1932 | } |
| 1933 | } |
| 1934 | if (this._token.type === '\n') { |
| 1935 | let indent = ''; |
| 1936 | let i = this._position; |
| 1937 | while (i < this._text.length) { |
| 1938 | const c = this._text[i]; |
| 1939 | if (ast._Tokenizer._isSpace(c)) { |
| 1940 | indent += c; |
| 1941 | i++; |
| 1942 | } else if (ast._Tokenizer._isNewline(c)) { |
| 1943 | indent = ''; |
| 1944 | i = this._newLine(i); |
| 1945 | this._position = i; |
| 1946 | this.linepos = i; |
| 1947 | this.lineno += 1; |
| 1948 | } else if (c === '#') { |
| 1949 | indent = ''; |
| 1950 | while (i < this._text.length && !ast._Tokenizer._isNewline(this._text[i])) { |
| 1951 | i++; |
| 1952 | } |
| 1953 | continue; |
| 1954 | } else { |
| 1955 | break; |
| 1956 | } |
| 1957 | } |
| 1958 | let type = null; |
| 1959 | if (indent.length > 0) { |
| 1960 | const current = this._indentation.length > 0 ? this._indentation[this._indentation.length - 1] : ''; |
| 1961 | if (indent.length > current.length) { |
| 1962 | type = 'indent'; |
| 1963 | this._indentation.push(indent); |
| 1964 | } else if (indent.length > 0 && indent.length < current.length) { |
| 1965 | type = 'dedent'; |
| 1966 | this._outdent = 0; |
| 1967 | for (let j = this._indentation.length - 1; j >= 0 && indent.length < this._indentation[j].length; j--) { |
| 1968 | this._outdent++; |
| 1969 | } |
| 1970 | } else { |
| 1971 | this._position += indent.length; |
| 1972 | } |
| 1973 | } else if (i >= this._text.length) { |
| 1974 | this._token = { type: 'eof', value: '' }; |
| 1975 | return; |
| 1976 | } else if (this._indentation.length > 0) { |
| 1977 | type = 'dedent'; |
| 1978 | this._outdent = this._indentation.length; |
| 1979 | } |
no test coverage detected