Skip to content

C-style Preprocessor includes and simple macro expansion? #871

Answered by msujew
pheller asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @pheller,

Similar to the lex/yacc toolchain you can implement a custom lexer that takes care of special requirements like these. The lexer is by default tightly coupled to Chevrotain, but you can supply your own implementation and convert the tokens to the interface that Chevrotain expects.

I imagine that such a feature massively mess with how the location-based LSP features work (basically all of them), due to locations in the source text (i.e. the vscode editor document) and the actual text (after performing the preprocessing) not being the same. You can probably work around this by selectively reimplementing such services.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pheller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants