(stream, state)
| 298 | } |
| 299 | |
| 300 | function tokenLexer(stream, state) { |
| 301 | if (stream.sol()) { |
| 302 | state.beginningOfLine = true; |
| 303 | state.dedent = false; |
| 304 | } |
| 305 | |
| 306 | var style = state.tokenize(stream, state); |
| 307 | var current = stream.current(); |
| 308 | |
| 309 | // Handle decorators |
| 310 | if (state.beginningOfLine && current == "@") |
| 311 | return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS; |
| 312 | |
| 313 | if (/\S/.test(current)) state.beginningOfLine = false; |
| 314 | |
| 315 | if ((style == "variable" || style == "builtin") |
| 316 | && state.lastToken == "meta") |
| 317 | style = "meta"; |
| 318 | |
| 319 | // Handle scope changes. |
| 320 | if (current == "pass" || current == "return") |
| 321 | state.dedent = true; |
| 322 | |
| 323 | if (current == "lambda") state.lambda = true; |
| 324 | if (current == ":" && !state.lambda && top(state).type == "py" && stream.match(/^\s*(?:#|$)/, false)) |
| 325 | pushPyScope(state); |
| 326 | |
| 327 | if (current.length == 1 && !/string|comment/.test(style)) { |
| 328 | var delimiter_index = "[({".indexOf(current); |
| 329 | if (delimiter_index != -1) |
| 330 | pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); |
| 331 | |
| 332 | delimiter_index = "])}".indexOf(current); |
| 333 | if (delimiter_index != -1) { |
| 334 | if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent |
| 335 | else return ERRORCLASS; |
| 336 | } |
| 337 | } |
| 338 | if (state.dedent && stream.eol() && top(state).type == "py" && state.scopes.length > 1) |
| 339 | state.scopes.pop(); |
| 340 | |
| 341 | return style; |
| 342 | } |
| 343 | |
| 344 | var external = { |
| 345 | startState: function(basecolumn) { |
no test coverage detected