ohmjs / ohm-editor

An IDE for the Ohm language (JavaScript edition)
MIT License
96 stars 18 forks source link

Better feedback when an example's start rule is deleted #12

Closed pdubroy closed 7 years ago

pdubroy commented 7 years ago

If an example has an explicit start rule set (e.g., 'Foo') and that rule is later delete from the grammar, we should improve the feedback that we give. Currently, the example will turn red, but we don't show much feedback about what the problem is.

Here's what I'm thinking:

  1. We keep an entry in the start rule dropdown, e.g. "Foo (undeclared rule)", and
  2. We show a regular error in the example editor saying "Rule Foo is not declared in grammar Arithmetic"

Thoughts, @mroeder and @sakekasi?

mroeder commented 7 years ago
  1. We automatically change the attached rule to null so that it picks whatever rule is first (implicit start rule) again.

I think that either 3. or 2. are good ways to go. I don't really like the idea of keeping a reference to a non-existing rule anymore.

pdubroy commented 7 years ago

I'm worried about what happens if -- intentionally or accidentally -- you change the name of a rule that several examples use as their start rule. Say you accidentally delete a character from the rule name, I think it could be pretty annoying if that silently updated a dozen examples and then you had to go and manually fix them again.

mroeder commented 7 years ago

I see. It wouldn't break anything when it is still the first rule and therefore the implicit start rule. However, it makes a difference for a rule somewhere in between. So, 2.?

pdubroy commented 7 years ago

This has already been fixed.