dparkins / language-fortran

Syntax highlighting for FORTRAN for atom
MIT License
35 stars 16 forks source link

coloring of subroutine calls #57

Closed maxlevesque closed 8 years ago

maxlevesque commented 8 years ago

Hi there :)

Is this coloring expected? Seems strange to me. screenshot from 2015-10-15 18 16 07

I suspect case 1 to be incoherent with the subroutine definitions and so on.

tomedunn commented 8 years ago

This coloring is expected given the way the rule is written but it is inconsistent with the current standard. I originally did this to make sure functions wouldn't highlight variables with the same names (unless they're arrays) but it's probably not be needed for subroutines since they can only exist inside a call statement. I'll make a note to fix this tonight after I get home.

The real tricky part with subroutines though is what to do with type-bound subroutines. I would love if it would only highlight the subroutine part and not the variable part but I still haven't thought of a good way of making that work.

maxlevesque commented 8 years ago

Can I be of any help without knowing the language behind these rules?

tomedunn commented 8 years ago

The rules are written using regular expressions, specifically the oniguruma regular expression rules. To do that sort of highlighting you need to utilize look ahead and look behind regex. There are a lot of additional nuanced rules that are specific to the Textmate grammar engine that Atom uses. So if you try it out and run into behavior that doesn't make sense let me know. I've banged my head against the wall enough working with the grammar engine to have figured out a lot of them.