Skip to content

Add public Tokenize() API to the VQL lexer - #139

Closed
predictiple wants to merge 1 commit into
Velocidex:masterfrom
predictiple:lsp-semantic-tokens
Closed

Add public Tokenize() API to the VQL lexer#139
predictiple wants to merge 1 commit into
Velocidex:masterfrom
predictiple:lsp-semantic-tokens

Conversation

@predictiple

Copy link
Copy Markdown
Contributor

The Velociraptor LSP server's semantic-highlighting handler (textDocument/semanticTokens) needs lexical information that the AST-based APIs deliberately hide: comment tokens and the raw surface of the query, down to token classification. Until now the VQL lexer (vqlLexer) was unexported, so there was no supported way to get tokens.

This adds no new grammar or parsing logic - it is a thin, purely additive wrapper over the existing lexer.StatefulDefinition that already feeds the participle parsers. Because it uses the same lexer the real parser consumes, the tokens can never drift out of sync with what Velociraptor actually accepts (unlike a shadow grammar such as tree-sitter).

Also includes three unit tests covering token stream contents, position monotonicity, and the fact that comments survive tokenization even though parse APIs elide them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants