I suggest you ...

(IDE/Compiler) Semantic code highlighting

Improve the syntax highlighter by also highlighting words based on what they mean to the compiler. We could have different colors for objects, rulebooks, kinds, variables, properties, etc.

The semantic analysis would have to be done by NI, producing a markup file for the IDEs to read.

136 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Jesse McGrewJesse McGrew shared this idea  ·   ·  Admin →
    under review  ·  emshortAdminemshort (Admin, Inform 7) responded  · 

    We’re seriously considering this, but more discussion and planning is needed: it would require a great deal of work not just for the core of Inform but for all of the interfaces.

    16 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Jesse McGrewJesse McGrew commented  · 

        That Vim extension only does syntax highlighting, which is based on lexical analysis of the code (keywords, delimiters, comments, etc.). It's not much different from what the I7 IDE already does.

        Semantic highlighting would also account for the meanings of words that are defined elsewhere in the code (and extensions) and built into I7. For example, the words "divided by" could be an arithmetic operator, or a relation, or part of an object name, depending on what's been defined and how the words are used in context. I7's grammar is complicated enough, and definitions can be inferred so many ways, that it'd probably be impossible for any editor to get this right without the compiler's help.

      • Kevin NorrisKevin Norris commented  · 

        Can we just steal this?

        http://www.lesismore.co.za/viminform7.html

        >Well of course not. You can't just *take* it!

        OK, can we politely ask for permission to repurpose it?

        In my experience, it doesn't handle extensions perfectly (the documentation throws it) and it doesn't like comment nesting, and obviously it's written for Vim, but those are small hurdles, right? *hopeful face*

      • ThomasThomas commented  · 

        This is very important. I am a C/C++ programmer, and I really was intrigued by Inform's coding method at first. Unfortunately, learning the keywords was huge turn-off for me and took way longer than desired to learn. With proper highlighting of keyword types and same-object terms and such, it'd be much more pleasant.

      • riidomriidom commented  · 

        When dealing with colours, a choice of general colour schemes would be great.
        Having a "bright text on dark background" theme would be awesome for longer sessions, having it look more like darkroom writers.

      • Ron NewcombRon Newcomb commented  · 

        Regarding continuous compilation: someone had reported a bug in 6E59 (early build) that the Refresh Index menu option was lacking its keyboard shortcut. He said he pressed that keyboard shortcut all the time to see if what he had just written would compile. Since Refresh Index is quicker than a whole compile -- and perhaps even a stripped-down version of that which doesn't actually change the index files? -- then perhaps that would be appropriate and fairly easy for the dev team to implement.

        I vote for, at least on the Mac, the dotted green underline to highlight such does-not-compile pieces, mirroring how word processors identify questionable grammar.

        Granted, syntax-highlighting invalid code is only part of syntax highlighting in general, but I believe it the most useful subset. I, for one, do not need object names in brown, scene names in purple, etc.

      • kpkilburnkpkilburn commented  · 

        Is there any chance of this and the other top-ranking ideas getting implemented? I see that some of the lower-ranked ideas have comments one way or the other. It would be nice to know early if the ideas have a chance rather than debating them for months only to find that they don't stand a chance.

      • EleasEleas commented  · 

        I must say, it would be quite useful to easily turn such a function off and on at will. Alternatively, I'd love to be able to highlight every instance of the same object in the source text. That would substantially aid refactoring, among other things.

      • AaronReedAdminAaronReed (Admin, Inform 7) commented  · 

        Power consumed by constantly recompiling is definitely something to consider, but I would disagree that the feature would only be useful to new authors... I find that I still quite frequently write code that gets misinterpreted by the compiler in ways this sort of syntax highlighting (especially Andrew's version) would catch. (I have gotten much better at realizing what I've done from the problem message, though.) Were this available and power consumption was not an issue, I'm quite sure I would leave it on all the time.

      • Ron NewcombRon Newcomb commented  · 

        Please let this feature be turn-off-able. While I would have found this feature very useful when I first started learning Inform, most English text isn't in comic-book colors, and my laptop's battery life is short.

      • Jesse McGrewJesse McGrew commented  · 

        @midiguru23: That's basically what I had in mind. No need to wait for a full compile, though: the IDE could call the compiler in the background to perform highlighting when you stop typing for a few seconds.

      • midiguru23midiguru23 commented  · 

        As a compromise that might be easier to implement ... at the end of a successful compile, all of the analysis of the source text has been done, right? Inform "knows" what the syntax and semantics is for each and every word in the source. So it should be possible to apply syntax coloring to the source AFTER the compile. Any new source that is then entered would not have the coloring, until it's compiled. Would that be useful? I think perhaps it would. -- JA

      • Andrew PlotkinAndrew Plotkin commented  · 

        The ice-cream-pony version of this is not just highlighting words, but phrases and entire nested constructs. When debugging some problems it is most helpful to know that "beach north of the island" is being parsed as a single object name.

        For others, you might want to know that in the description "all gems carried by the player which are red", the "which are red" modifier is being applied to the player rather than the gems.

        This implies a certain Cthulhian nightmare of sentence-diagram-browsing UI embedded in the editor. But it's nicer than my current debugging approach in these cases, which is to read the generated I6 code to see what the compiler did.

      Feedback and Knowledge Base