MCPcopy Index your code
hub / github.com/codeaashu/claude-code / createTokenizer

Function createTokenizer

src/ink/termio/tokenize.ts:57–92  ·  view source on GitHub ↗
(options?: TokenizerOptions)

Source from the content-addressed store, hash-verified

55 * ```
56 */
57export function createTokenizer(options?: TokenizerOptions): Tokenizer {
58 let currentState: State = 'ground'
59 let currentBuffer = ''
60 const x10Mouse = options?.x10Mouse ?? false
61
62 return {
63 feed(input: string): Token[] {
64 const result = tokenize(
65 input,
66 currentState,
67 currentBuffer,
68 false,
69 x10Mouse,
70 )
71 currentState = result.state.state
72 currentBuffer = result.state.buffer
73 return result.tokens
74 },
75
76 flush(): Token[] {
77 const result = tokenize('', currentState, currentBuffer, true, x10Mouse)
78 currentState = result.state.state
79 currentBuffer = result.state.buffer
80 return result.tokens
81 },
82
83 reset(): void {
84 currentState = 'ground'
85 currentBuffer = ''
86 },
87
88 buffer(): string {
89 return currentBuffer
90 },
91 }
92}
93
94type InternalState = {
95 state: State

Callers 3

expandTabsFunction · 0.85
parseMultipleKeypressesFunction · 0.85
ParserClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected