| 65 | return INITIAL; |
| 66 | }, |
| 67 | tokenize(line, state) { |
| 68 | const tokenizerState = state as StateStack; |
| 69 | const textMateResult = grammar.tokenizeLine(line, tokenizerState, 500); |
| 70 | if (textMateResult.stoppedEarly) { |
| 71 | return { |
| 72 | endState: state, |
| 73 | tokens: textMateResult.tokens.map(t => ({ ...t, scopes: t.scopes.reverse().join(' ') })) |
| 74 | }; |
| 75 | } |
| 76 | |
| 77 | let endState: StateStack; |
| 78 | if (state.equals(textMateResult.ruleStack)) { |
| 79 | endState = tokenizerState; |
| 80 | } else { |
| 81 | endState = textMateResult.ruleStack; |
| 82 | } |
| 83 | |
| 84 | return { |
| 85 | endState, |
| 86 | tokens: textMateResult.tokens.map(t => ({ ...t, scopes: t.scopes.reverse().join(' ') })) |
| 87 | }; |
| 88 | } |
| 89 | }); |
| 90 | } |