ptomato / sublime_autotools

Autotools syntax highlighting for Sublime Text
GNU General Public License v3.0
17 stars 15 forks source link

Syntax broken with lines containing '#' #11

Closed CheyenneWills closed 3 years ago

CheyenneWills commented 3 years ago

In the line that has "#include", the "#" is being scoped as comment.line.number-sign.shell The ')' character following "..un=no" and the on the last line both get scoped as invalid.illegal.syntax-error

AC_CACHE_CHECK(
       [for n_un in struct nlist], 
       ac_cv_struct_nlist_n_un,
       [AC_TRY_MYCOMPILE(
                         [#include <nlist.h>],
                         [struct nlist n; n.n_un.n_name = 0;],
                         ac_cv_struct_nlist_n_un=yes,
                         ac_cv_struct_nlist_n_un=no
                         ) 
       ]
)

Changing the '(' following 'MYCOMPILE' to a '[' (with the matching closing) does "fix" the syntax error, but the "#" still introduces the comment scope.

(Note the above was "adapted" from one of the autoconf supplied checks to try to illustrate the problem. The case that I'm dealing with is much more extensive and deals with several project specific m4 macros)

CheyenneWills commented 3 years ago

Looking at the syntax definition, I see that there are tests for many of the "builtin" autoconf functions which may explain why "AC_TRY_COMPILE" works and the above example doesn't.

Not sure if there is an easy general solution to this. Maybe a doc update just noting that arguments to custom functions may not be recognized correctly.

ptomato commented 3 years ago

Thanks for the report, appreciated! And sorry I didn't get to it earlier.

Indeed, there isn't really a way to do this for custom macros, unfortunately. I have added the note to the README that you suggested, though.