Add support for #else and #elif preprocessor directives#56
Merged
Conversation
Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix support for ifndef preprocessor directive
Add support for #else and #elif preprocessor directives
Nov 21, 2025
Owner
|
@copilot can you bump the package version? make sure you update the agent description file to do so in future PRs automatically too |
…structions Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The parser supported
#ifndef,#ifdef,#if, and#endifbut failed on#elseand#elif, causing parse errors on standard C preprocessor patterns:#ifndef FOO namespace Primary { runtimeclass MyClass { } } #else namespace Fallback { runtimeclass MyClass { } } #endifChanges
PEG.js grammar (
server/src/midl.pegjs):elseKWandelifKWkeyword definitions following existing preprocessor directive patternpreprocessorStatementrule to include both directivesTextMate grammar (
syntaxes/midl3.tmGrammar.json):#elifto preprocessor regex pattern (#elsewas already present)Package version (
package.json):Agent configuration (
.github/agents/midl-dev.agent.md):Test coverage:
preprocessor.idlvalidating#ifndef/#else/#endifpreprocessor_elif.idlvalidating#if/#elif/#else/#endifchains<issue_title>ifndef not supported</issue_title>
><issue_description>
idl > #ifndef FOO > // ... > #else > // ... > #endif >>
> doesn't seem to be understood.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
>
>
>
> Custom agent used: MIDL Language Server Developer
> Expert in MIDL 3.0 language server development, VSCode extensions, and WinRT API definitions
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.