jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
155 stars 30 forks source link

KeyError: c_conditional_context for c++ #567

Closed asottile closed 3 years ago

asottile commented 3 years ago

Checklist

The code with a problem is:

int main() {
    int x = 1;
    switch (x) {
        case 1:;
    }
    return 0;
}

It looks like:

(causes a crash for my highlighter currently)

  File "/home/carlos/virtualenvs/sw/lib/python3.7/site-packages/babi/highlight.py", line 574, in _include
    return self._patterns(grammar, (repository[s[1:]],))
  File "/home/carlos/virtualenvs/sw/lib/python3.7/site-packages/babi/fdict.py", line 46, in __getitem__
    raise KeyError(key)
KeyError: 'c_conditional_context'

It should look like:

(not crash)

explanation

it looks like there's a #c_condtional_context in the c++ grammar, but no target for it to include. the currently checked-in C grammar contains a c_conditional_context though

asottile commented 3 years ago

fixing that I get a KeyError on block_innards as well

jeff-hykin commented 3 years ago

Yup looks like they've been overdue for removal.

Screen Shot 2021-09-12 at 1 53 35 PM Screen Shot 2021-09-12 at 1 56 26 PM

Now that the C++ and C repos are seperated, I went ahead and pulled them out of the C++ syntax

asottile commented 3 years ago

looks like there's one more c_conditional_context on line 528

also what is the relationship between ./autogenerated and ./syntaxes?

jeff-hykin commented 3 years ago

Oh, use the auto-generated.

The syntaxes folder is still around because I refactored the codebase last week and haven't told Microsoft about it. They're currently pulling from the syntaxes folder so I didn't want to spontaneously break their workflow.

jeff-hykin commented 3 years ago

Also as part of the refactor, this repo is only going to have the C++ and C++ embedded syntaxes.

So if you're looking for the other ones, I created several twin repositories (better-c-syntax, better-objc-syntax, better-objcpp-syntax) to house the syntax files for the other languages.

asottile commented 3 years ago

I tried fixing the one on line 528 but it generates a lot of diffs on regeneration (though admittedly I don't have nix set up so I was just doing npm i + gem install ruby_grammar_builder --version 0.0.4 + gem install walk_up and then ruby main/main.rb

jeff-hykin commented 3 years ago

Oh oops, I didn't realize you meant line 500 in the main.rb. I was thinking you meant in the syntaxes/

jeff-hykin commented 3 years ago

I tried fixing the one on line 528 but it generates a lot of diffs on regeneration (though admittedly I don't have nix set up so I was just doing npm i + gem install ruby_grammar_builder --version 0.0.4 + gem install walk_up and then ruby main/main.rb

I would have guessed that would, and that's how we used to set it up. And I pushed the change just now and it was pretty minimal so maybe you can diff against it to figure out what wasn't working. Or alternatively just use the nix setup.