From f088dd957aa8b46dc0fce126017eeb037136662d Mon Sep 17 00:00:00 2001 From: Muffindrake Date: Thu, 8 Nov 2018 10:30:27 +0100 Subject: [PATCH 1/6] Update C grammar This highlighting and static completion for types and macros that were previously missing. No functions are included, but some macros are highlighted as such, even if they're function-like macros. --- rc/core/c-family.kak | 56 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 55e08c6a..44fb627b 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -159,29 +159,63 @@ add-highlighter shared/c/code/numbers regex %{\b-?(0x[0-9a-fA-F]+|\d+)([uU][lL]{ evaluate-commands %sh{ # Grammar keywords="asm break case continue default do else for goto if return - sizeof switch while" + sizeof switch while offsetof alignas alignof" attributes="auto const enum extern inline register restrict static struct - typedef union volatile" - types="char double float int long short signed size_t unsigned void" - stdint_types="int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t intptr_t intmax_t uintmax_t" - unistd_types="ssize_t gid_t uid_t off_t off64_t useconds_t pid_t socklen_t" - unistd_macros="R_OK W_OK X_OK F_OK SEEK_SET SEEK_CUR SEEK_END F_ULOCK F_LOCK F_TLOCK F_TEST" - stdint_macros="INT8_MIN INT16_MIN INT32_MIN INT64_MIN UINT8_MIN UINT16_MIN UINT32_MIN UINT64_MIN INT8_MAX INT16_MAX INT32_MAX INT64_MAX UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX INTPTR_MIN INTPTR_MAX UINTPTR_MAX INTMAX_MIN INTMAX_MAX UINTMAX_MAX PTRDIFF_MIN PTRDIFF_MAX" - values="NULL" + typedef union volatile thread_local" + types="char double float int long short signed unsigned void" + complex_types="complex imaginary" + fenv_types=$(echo f{env,except}_t) + inttypes_types="imaxdiv_t" + locale_types="lconv" + math_types=$(echo {float,double}_t) + setjmp_types="jmp_buf" + signal_types="sig_atomic_t" + stdarg_types="va_list" + stdatomic_types=$(echo memory_order atomic_{bool,{,s,u,w}char,{,u}short,{,u}int,{,u}{,l}long,char{16,32}_t,{,u}int{ptr,max,{,_{least,fast}}{8,16,32,64}}_t,{size,ptrdiff}_t}) + stddef_types=$(echo {ptrdiff,size,max_align,wchar}_t) + stdint_types=$(echo {,u}int{ptr,max,{,_{least,fast}}{8,16,32,64}}_t) + stdio_types="FILE fpos_t" + stdlib_types=$(echo {,{,l}l}div_t) + threads_types=$(echo {cnd,thrd{,_start},tss{,_dtor},mtx}_t once_flag) + wchar_types=$(echo {mbstate,wint}_t tm) + unistd_types=$(echo {ssize,gid,uid,off{,64},useconds,pid,socklen}_t) + + assert_macros=$(echo {,static_}assert NDEBUG) + complex_macros="I" + error_macros=$(echo E{DOM,ILSEQ,RANGE} errno) + fenv_macros=$(echo FE_{DIVBYZERO,INEXACT,INVALID,{OVER,UNDER}FLOW,ALL_EXCEPT,DOWNWARD,TONEAREST,TOWARDZERO,UPWARD,DFL_ENV}) + inttypes_macros=$(echo PRI{d,i,o,u,x,X}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}} SCN{d,i,o,u,x}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}}) + iso646_macros=$(echo and{,_eq} bit{and,or} compl not{,_eq} or{,_eq}, xor{,_eq}) + limits_macros=$(echo {{,S,W}CHAR,SHRT,INT,{,L}LONG}_{MIN,MAX} {MB_LEN,U{CHAR,SHRT,INT,{,L}LONG}}_MAX CHAR_BIT) + locale_macros=$(echo LC_{ALL,COLLATE,CTYPE,MONETARY,NUMERIC,TIME}) + math_macros=$(echo HUGE_VAL{,F,L} INFINITY NAN FP_{INFINITE,NAN,NORMAL,SUBNORMAL,ZERO,FAST_FMA{,F,L},ILOGB{0,NAN}} MATH_ERR{NO,EXCEPT} math_errhandling is{greater{,equal},less{,equal},lessgreater,unordered}) + setjmp_macros="setjmp" + signal_macros=$(echo SIG{_{DFL,ERR,IGN},ABRT,FPE,ILL,INT,SEGV,TERM}) + stdarg_macros=$(echo va_{start,arg,end,copy}) + stdatomic_macros=$(echo ATOMIC_{BOOL,CHAR{,{16,32}_T},WCHAR_T,SHORT,INT,{,L}LONG,POINTER}_LOCK_FREE ATOMIC_{FLAG,VAR}_INIT memory_order_{relaxed,consume,acquire,release,acq_rel,seq_cst} kill_dependency) + stdbool_macros="true false" + stddef_macros="NULL" + stdio_macros=$(echo _IO{FB,LB,NB}F BUFSIZ EOF {FOPEN,FILENAME,TMP}_MAX L_tmpnam SEEK_{CUR,END,SET} std{err,in,out}) + stdlib_macros=$(echo EXIT_{FAILURE,SUCCESS} {MB_CUR,RAND}_MAX) + stdint_macros=$(echo {PTRDIFF,SIG_ATOMIC,WINT,INT{MAX,PTR,{,_{LEAST,FAST}}{8,16,32,64}}}_{MIN,MAX} UINT{MAX,PTR,{,_{LEAST,FAST}}{8,16,32,64}}_MAX {,U}INT{MAX,{8,16,32,64}}_C) + threads_macros=$(echo mtx_{plain,recursive,timed} thrd_{timedout,success,busy,error,nomem} ONCE_FLAG_INIT TSS_DTOR_ITERATION) + wchar_macros="WEOF" + misc_macros="noreturn" + unistd_macros=$(echo {R,W,X,F}_OK F_{{,U,T}LOCK,TEST}) join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list printf '%s\n' "hook global WinSetOption filetype=c %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${stdint_types} ${unistd_types} ${stdint_macros} ${unistd_macros} ${values}" ' ') + set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') }" # Highlight keywords printf %s " add-highlighter shared/c/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword add-highlighter shared/c/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute - add-highlighter shared/c/code/types regex \b($(join "${types} ${stdint_types} ${unistd_types}" '|'))\b 0:type - add-highlighter shared/c/code/values regex \b($(join "${values} ${stdint_macros} ${unistd_macros}" '|'))\b 0:value + add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types}" '|'))\b 0:type + add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value " } From 3c9f9255d799904c35f4bf19d0962fdf2f447e5e Mon Sep 17 00:00:00 2001 From: Muffindrake Date: Thu, 8 Nov 2018 18:03:31 +0100 Subject: [PATCH 3/6] Add macros for float.h --- rc/core/c-family.kak | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 44fb627b..c981202f 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -184,6 +184,7 @@ evaluate-commands %sh{ complex_macros="I" error_macros=$(echo E{DOM,ILSEQ,RANGE} errno) fenv_macros=$(echo FE_{DIVBYZERO,INEXACT,INVALID,{OVER,UNDER}FLOW,ALL_EXCEPT,DOWNWARD,TONEAREST,TOWARDZERO,UPWARD,DFL_ENV}) + float_macros=$(echo DECIMAL_DIG FLT_{ROUNDS,EVAL_METHOD,RADIX} {FLT,DBL,LDBL}{{{,_{MANT,DECIMAL}}_DIG,_{MIN_{,10_},MAX_}EXP},_{MAX,EPSILON,TRUE_MIN,HAS_SUBNORM}}) inttypes_macros=$(echo PRI{d,i,o,u,x,X}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}} SCN{d,i,o,u,x}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}}) iso646_macros=$(echo and{,_eq} bit{and,or} compl not{,_eq} or{,_eq}, xor{,_eq}) limits_macros=$(echo {{,S,W}CHAR,SHRT,INT,{,L}LONG}_{MIN,MAX} {MB_LEN,U{CHAR,SHRT,INT,{,L}LONG}}_MAX CHAR_BIT) @@ -207,7 +208,7 @@ evaluate-commands %sh{ # Add the language's grammar to the static completion list printf '%s\n' "hook global WinSetOption filetype=c %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') + set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') }" # Highlight keywords @@ -215,7 +216,7 @@ evaluate-commands %sh{ add-highlighter shared/c/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword add-highlighter shared/c/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types}" '|'))\b 0:type - add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value + add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value " } From 3012bf48e55ecfc6549bd3bc8b8333e650ac8652 Mon Sep 17 00:00:00 2001 From: Muffindrake Date: Thu, 8 Nov 2018 18:26:16 +0100 Subject: [PATCH 4/6] Convert subshells to strings --- rc/core/c-family.kak | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index c981202f..8c4a615d 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -164,45 +164,45 @@ evaluate-commands %sh{ typedef union volatile thread_local" types="char double float int long short signed unsigned void" complex_types="complex imaginary" - fenv_types=$(echo f{env,except}_t) + fenv_types="fenv_t fexcept_t" inttypes_types="imaxdiv_t" locale_types="lconv" - math_types=$(echo {float,double}_t) + math_types="float_t double_t" setjmp_types="jmp_buf" signal_types="sig_atomic_t" stdarg_types="va_list" - stdatomic_types=$(echo memory_order atomic_{bool,{,s,u,w}char,{,u}short,{,u}int,{,u}{,l}long,char{16,32}_t,{,u}int{ptr,max,{,_{least,fast}}{8,16,32,64}}_t,{size,ptrdiff}_t}) - stddef_types=$(echo {ptrdiff,size,max_align,wchar}_t) - stdint_types=$(echo {,u}int{ptr,max,{,_{least,fast}}{8,16,32,64}}_t) + stdatomic_types="memory_order atomic_bool atomic_char atomic_schar atomic_uchar atomic_wchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_llong atomic_ulong atomic_ullong atomic_char16_t atomic_char32_t atomic_intptr_t atomic_intmax_t atomic_int8_t atomic_int16_t atomic_int32_t atomic_int64_t atomic_int_least8_t atomic_int_least16_t atomic_int_least32_t atomic_int_least64_t atomic_int_fast8_t atomic_int_fast16_t atomic_int_fast32_t atomic_int_fast64_t atomic_uintptr_t atomic_uintmax_t atomic_uint8_t atomic_uint16_t atomic_uint32_t atomic_uint64_t atomic_uint_least8_t atomic_uint_least16_t atomic_uint_least32_t atomic_uint_least64_t atomic_uint_fast8_t atomic_uint_fast16_t atomic_uint_fast32_t atomic_uint_fast64_t atomic_size_t atomic_ptrdiff_t" + stddef_types="ptrdiff_t size_t max_align_t wchar_t" + stdint_types="intptr_t intmax_t int8_t int16_t int32_t int64_t int_least8_t int_least16_t int_least32_t int_least64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t uintptr_t uintmax_t uint8_t uint16_t uint32_t uint64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t" stdio_types="FILE fpos_t" - stdlib_types=$(echo {,{,l}l}div_t) - threads_types=$(echo {cnd,thrd{,_start},tss{,_dtor},mtx}_t once_flag) - wchar_types=$(echo {mbstate,wint}_t tm) - unistd_types=$(echo {ssize,gid,uid,off{,64},useconds,pid,socklen}_t) + stdlib_types="div_t ldiv_t lldiv_t" + threads_types="cnd_t thrd_t thrd_start_t tss_t tss_dtor_t mtx_t once_flag" + wchar_types="mbstate_t wint_t tm" + unistd_types="ssize_t gid_t uid_t off_t off64_t useconds_t pid_t socklen_t" - assert_macros=$(echo {,static_}assert NDEBUG) + assert_macros="assert static_assert NDEBUG" complex_macros="I" - error_macros=$(echo E{DOM,ILSEQ,RANGE} errno) - fenv_macros=$(echo FE_{DIVBYZERO,INEXACT,INVALID,{OVER,UNDER}FLOW,ALL_EXCEPT,DOWNWARD,TONEAREST,TOWARDZERO,UPWARD,DFL_ENV}) - float_macros=$(echo DECIMAL_DIG FLT_{ROUNDS,EVAL_METHOD,RADIX} {FLT,DBL,LDBL}{{{,_{MANT,DECIMAL}}_DIG,_{MIN_{,10_},MAX_}EXP},_{MAX,EPSILON,TRUE_MIN,HAS_SUBNORM}}) - inttypes_macros=$(echo PRI{d,i,o,u,x,X}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}} SCN{d,i,o,u,x}{MAX,PTR,{,LEAST,FAST}{8,16,32,64}}) - iso646_macros=$(echo and{,_eq} bit{and,or} compl not{,_eq} or{,_eq}, xor{,_eq}) - limits_macros=$(echo {{,S,W}CHAR,SHRT,INT,{,L}LONG}_{MIN,MAX} {MB_LEN,U{CHAR,SHRT,INT,{,L}LONG}}_MAX CHAR_BIT) - locale_macros=$(echo LC_{ALL,COLLATE,CTYPE,MONETARY,NUMERIC,TIME}) - math_macros=$(echo HUGE_VAL{,F,L} INFINITY NAN FP_{INFINITE,NAN,NORMAL,SUBNORMAL,ZERO,FAST_FMA{,F,L},ILOGB{0,NAN}} MATH_ERR{NO,EXCEPT} math_errhandling is{greater{,equal},less{,equal},lessgreater,unordered}) + error_macros="EDOM EILSEQ ERANGE errno" + fenv_macros="FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW FE_ALL_EXCEPT FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD FE_DFL_ENV" + float_macros="DECIMAL_DIG FLT_ROUNDS FLT_EVAL_METHOD FLT_RADIX FLT_DIG FLT_MANT_DIG FLT_DECIMAL_DIG FLT_MIN_EXP FLT_MIN_10_EXP FLT_MAX_EXP FLT_MAX FLT_EPSILON FLT_TRUE_MIN FLT_HAS_SUBNORM DBL_DIG DBL_MANT_DIG DBL_DECIMAL_DIG DBL_MIN_EXP DBL_MIN_10_EXP DBL_MAX_EXP DBL_MAX DBL_EPSILON DBL_TRUE_MIN DBL_HAS_SUBNORM LDBL_DIG LDBL_MANT_DIG LDBL_DECIMAL_DIG LDBL_MIN_EXP LDBL_MIN_10_EXP LDBL_MAX_EXP LDBL_MAX LDBL_EPSILON LDBL_TRUE_MIN LDBL_HAS_SUBNORM" + inttypes_macros="PRIdMAX PRIdPTR PRId8 PRId16 PRId32 PRId64 PRIdLEAST8 PRIdLEAST16 PRIdLEAST32 PRIdLEAST64 PRIdFAST8 PRIdFAST16 PRIdFAST32 PRIdFAST64 PRIiMAX PRIiPTR PRIi8 PRIi16 PRIi32 PRIi64 PRIiLEAST8 PRIiLEAST16 PRIiLEAST32 PRIiLEAST64 PRIiFAST8 PRIiFAST16 PRIiFAST32 PRIiFAST64 PRIoMAX PRIoPTR PRIo8 PRIo16 PRIo32 PRIo64 PRIoLEAST8 PRIoLEAST16 PRIoLEAST32 PRIoLEAST64 PRIoFAST8 PRIoFAST16 PRIoFAST32 PRIoFAST64 PRIuMAX PRIuPTR PRIu8 PRIu16 PRIu32 PRIu64 PRIuLEAST8 PRIuLEAST16 PRIuLEAST32 PRIuLEAST64 PRIuFAST8 PRIuFAST16 PRIuFAST32 PRIuFAST64 PRIxMAX PRIxPTR PRIx8 PRIx16 PRIx32 PRIx64 PRIxLEAST8 PRIxLEAST16 PRIxLEAST32 PRIxLEAST64 PRIxFAST8 PRIxFAST16 PRIxFAST32 PRIxFAST64 PRIXMAX PRIXPTR PRIX8 PRIX16 PRIX32 PRIX64 PRIXLEAST8 PRIXLEAST16 PRIXLEAST32 PRIXLEAST64 PRIXFAST8 PRIXFAST16 PRIXFAST32 PRIXFAST64 SCNdMAX SCNdPTR SCNd8 SCNd16 SCNd32 SCNd64 SCNdLEAST8 SCNdLEAST16 SCNdLEAST32 SCNdLEAST64 SCNdFAST8 SCNdFAST16 SCNdFAST32 SCNdFAST64 SCNiMAX SCNiPTR SCNi8 SCNi16 SCNi32 SCNi64 SCNiLEAST8 SCNiLEAST16 SCNiLEAST32 SCNiLEAST64 SCNiFAST8 SCNiFAST16 SCNiFAST32 SCNiFAST64 SCNoMAX SCNoPTR SCNo8 SCNo16 SCNo32 SCNo64 SCNoLEAST8 SCNoLEAST16 SCNoLEAST32 SCNoLEAST64 SCNoFAST8 SCNoFAST16 SCNoFAST32 SCNoFAST64 SCNuMAX SCNuPTR SCNu8 SCNu16 SCNu32 SCNu64 SCNuLEAST8 SCNuLEAST16 SCNuLEAST32 SCNuLEAST64 SCNuFAST8 SCNuFAST16 SCNuFAST32 SCNuFAST64 SCNxMAX SCNxPTR SCNx8 SCNx16 SCNx32 SCNx64 SCNxLEAST8 SCNxLEAST16 SCNxLEAST32 SCNxLEAST64 SCNxFAST8 SCNxFAST16 SCNxFAST32 SCNxFAST64" + iso646_macros="and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq" + limits_macros="CHAR_MIN CHAR_MAX SCHAR_MIN SCHAR_MAX WCHAR_MIN WCHAR_MAX SHRT_MIN SHRT_MAX INT_MIN INT_MAX LONG_MIN LONG_MAX LLONG_MIN LLONG_MAX MB_LEN_MAX UCHAR_MAX USHRT_MAX UINT_MAX ULONG_MAX ULLONG_MAX CHAR_BIT" + locale_macros="LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME" + math_macros="HUGE_VAL HUGE_VALF HUGE_VALL INFINITY NAN FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO FP_FAST_FMA FP_FAST_FMAF FP_FAST_FMAL FP_ILOGB0 FP_ILOGBNAN MATH_ERRNO MATH_ERREXCEPT math_errhandling isgreater isgreaterequal isless islessequal islessgreater isunordered" setjmp_macros="setjmp" - signal_macros=$(echo SIG{_{DFL,ERR,IGN},ABRT,FPE,ILL,INT,SEGV,TERM}) - stdarg_macros=$(echo va_{start,arg,end,copy}) - stdatomic_macros=$(echo ATOMIC_{BOOL,CHAR{,{16,32}_T},WCHAR_T,SHORT,INT,{,L}LONG,POINTER}_LOCK_FREE ATOMIC_{FLAG,VAR}_INIT memory_order_{relaxed,consume,acquire,release,acq_rel,seq_cst} kill_dependency) + signal_macros="SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGINT SIGSEGV SIGTERM" + stdarg_macros="va_start va_arg va_end va_copy" + stdatomic_macros="ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE ATOMIC_FLAG_INIT ATOMIC_VAR_INIT memory_order_relaxed memory_order_consume memory_order_acquire memory_order_release memory_order_acq_rel memory_order_seq_cst kill_dependency" stdbool_macros="true false" stddef_macros="NULL" - stdio_macros=$(echo _IO{FB,LB,NB}F BUFSIZ EOF {FOPEN,FILENAME,TMP}_MAX L_tmpnam SEEK_{CUR,END,SET} std{err,in,out}) - stdlib_macros=$(echo EXIT_{FAILURE,SUCCESS} {MB_CUR,RAND}_MAX) - stdint_macros=$(echo {PTRDIFF,SIG_ATOMIC,WINT,INT{MAX,PTR,{,_{LEAST,FAST}}{8,16,32,64}}}_{MIN,MAX} UINT{MAX,PTR,{,_{LEAST,FAST}}{8,16,32,64}}_MAX {,U}INT{MAX,{8,16,32,64}}_C) - threads_macros=$(echo mtx_{plain,recursive,timed} thrd_{timedout,success,busy,error,nomem} ONCE_FLAG_INIT TSS_DTOR_ITERATION) + stdio_macros="_IOFBF _IOLBF _IONBF BUFSIZ EOF FOPEN_MAX FILENAME_MAX TMP_MAX L_tmpnam SEEK_CUR SEEK_END SEEK_SET stderr stdin stdout" + stdlib_macros="EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX" + stdint_macros="PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX WINT_MIN WINT_MAX INTMAX_MIN INTMAX_MAX INTPTR_MIN INTPTR_MAX INT8_MIN INT8_MAX INT16_MIN INT16_MAX INT32_MIN INT32_MAX INT64_MIN INT64_MAX INT_LEAST8_MIN INT_LEAST8_MAX INT_LEAST16_MIN INT_LEAST16_MAX INT_LEAST32_MIN INT_LEAST32_MAX INT_LEAST64_MIN INT_LEAST64_MAX INT_FAST8_MIN INT_FAST8_MAX INT_FAST16_MIN INT_FAST16_MAX INT_FAST32_MIN INT_FAST32_MAX INT_FAST64_MIN INT_FAST64_MAX UINTMAX_MAX UINTPTR_MAX UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX INTMAX_C INT8_C INT16_C INT32_C INT64_C UINTMAX_C UINT8_C UINT16_C UINT32_C UINT64_C" + threads_macros="mtx_plain mtx_recursive mtx_timed thrd_timedout thrd_success thrd_busy thrd_error thrd_nomem ONCE_FLAG_INIT TSS_DTOR_ITERATION" wchar_macros="WEOF" misc_macros="noreturn" - unistd_macros=$(echo {R,W,X,F}_OK F_{{,U,T}LOCK,TEST}) + unistd_macros="R_OK W_OK X_OK F_OK F_LOCK F_ULOCK F_TLOCK F_TEST" join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } From a807dbf1e02e3dfbad1c899d4efa4bd7c648291c Mon Sep 17 00:00:00 2001 From: Muffindrake Date: Sun, 11 Nov 2018 15:33:55 +0100 Subject: [PATCH 5/6] Add missing highlighting for time/wctype --- rc/core/c-family.kak | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 8c4a615d..1bfb1fd3 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -177,7 +177,9 @@ evaluate-commands %sh{ stdio_types="FILE fpos_t" stdlib_types="div_t ldiv_t lldiv_t" threads_types="cnd_t thrd_t thrd_start_t tss_t tss_dtor_t mtx_t once_flag" - wchar_types="mbstate_t wint_t tm" + time_types="clock_t time_t timespec tm" + wchar_types="mbstate_t wint_t" + wctype_types="wctrans_t wctype_t" unistd_types="ssize_t gid_t uid_t off_t off64_t useconds_t pid_t socklen_t" assert_macros="assert static_assert NDEBUG" @@ -200,6 +202,7 @@ evaluate-commands %sh{ stdlib_macros="EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX RAND_MAX" stdint_macros="PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX WINT_MIN WINT_MAX INTMAX_MIN INTMAX_MAX INTPTR_MIN INTPTR_MAX INT8_MIN INT8_MAX INT16_MIN INT16_MAX INT32_MIN INT32_MAX INT64_MIN INT64_MAX INT_LEAST8_MIN INT_LEAST8_MAX INT_LEAST16_MIN INT_LEAST16_MAX INT_LEAST32_MIN INT_LEAST32_MAX INT_LEAST64_MIN INT_LEAST64_MAX INT_FAST8_MIN INT_FAST8_MAX INT_FAST16_MIN INT_FAST16_MAX INT_FAST32_MIN INT_FAST32_MAX INT_FAST64_MIN INT_FAST64_MAX UINTMAX_MAX UINTPTR_MAX UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX INTMAX_C INT8_C INT16_C INT32_C INT64_C UINTMAX_C UINT8_C UINT16_C UINT32_C UINT64_C" threads_macros="mtx_plain mtx_recursive mtx_timed thrd_timedout thrd_success thrd_busy thrd_error thrd_nomem ONCE_FLAG_INIT TSS_DTOR_ITERATION" + time_macros="CLOCKS_PER_SEC TIME_UTC" wchar_macros="WEOF" misc_macros="noreturn" unistd_macros="R_OK W_OK X_OK F_OK F_LOCK F_ULOCK F_TLOCK F_TEST" @@ -208,15 +211,15 @@ evaluate-commands %sh{ # Add the language's grammar to the static completion list printf '%s\n' "hook global WinSetOption filetype=c %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') + set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${time_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') }" # Highlight keywords printf %s " add-highlighter shared/c/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword add-highlighter shared/c/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute - add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${wchar_types} ${unistd_types}" '|'))\b 0:type - add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value + add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types}" '|'))\b 0:type + add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${time_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value " } From d40a6bc44ad82b49ffcf51d2a85700f8d92026ec Mon Sep 17 00:00:00 2001 From: Muffindrake Date: Fri, 23 Nov 2018 00:12:01 +0100 Subject: [PATCH 6/6] Highlight bool type --- rc/core/c-family.kak | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 1bfb1fd3..e485568e 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -172,6 +172,7 @@ evaluate-commands %sh{ signal_types="sig_atomic_t" stdarg_types="va_list" stdatomic_types="memory_order atomic_bool atomic_char atomic_schar atomic_uchar atomic_wchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_llong atomic_ulong atomic_ullong atomic_char16_t atomic_char32_t atomic_intptr_t atomic_intmax_t atomic_int8_t atomic_int16_t atomic_int32_t atomic_int64_t atomic_int_least8_t atomic_int_least16_t atomic_int_least32_t atomic_int_least64_t atomic_int_fast8_t atomic_int_fast16_t atomic_int_fast32_t atomic_int_fast64_t atomic_uintptr_t atomic_uintmax_t atomic_uint8_t atomic_uint16_t atomic_uint32_t atomic_uint64_t atomic_uint_least8_t atomic_uint_least16_t atomic_uint_least32_t atomic_uint_least64_t atomic_uint_fast8_t atomic_uint_fast16_t atomic_uint_fast32_t atomic_uint_fast64_t atomic_size_t atomic_ptrdiff_t" + stdbool_types="bool" stddef_types="ptrdiff_t size_t max_align_t wchar_t" stdint_types="intptr_t intmax_t int8_t int16_t int32_t int64_t int_least8_t int_least16_t int_least32_t int_least64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t uintptr_t uintmax_t uint8_t uint16_t uint32_t uint64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t" stdio_types="FILE fpos_t" @@ -211,14 +212,14 @@ evaluate-commands %sh{ # Add the language's grammar to the static completion list printf '%s\n' "hook global WinSetOption filetype=c %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${time_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') + set-option window static_words $(join "${keywords} ${attributes} ${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stdbool_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types} ${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdlib_macros} ${stdint_macros} ${threads_macros} ${time_macros} ${wchar_macros} ${misc_macros} ${unistd_macros} ${values}" ' ') }" # Highlight keywords printf %s " add-highlighter shared/c/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword add-highlighter shared/c/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute - add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types}" '|'))\b 0:type + add-highlighter shared/c/code/types regex \b($(join "${types} ${complex_types} ${fenv_types} ${inttypes_types} ${locale_types} ${math_types} ${setjmp_types} ${signal_types} ${stdarg_types} ${stdatomic_types} ${stdbool_types} ${stddef_types} ${stdint_types} ${stdio_types} ${stdlib_types} ${threads_types} ${time_types} ${wchar_types} ${wctype_types} ${unistd_types}" '|'))\b 0:type add-highlighter shared/c/code/values regex \b($(join "${assert_macros} ${complex_macros} ${error_macros} ${fenv_macros} ${float_macros} ${inttypes_macros} ${iso646_macros} ${limits_macros} ${locale_macros} ${math_macros} ${setjmp_macros} ${signal_macros} ${stdarg_macros} ${stdatomic_macros} ${stdbool_macros} ${stddef_macros} ${stdio_macros} ${stdint_macros} ${threads_macros} ${time_macros} ${wchar_macros} ${misc_macros} ${unistd_macros}" '|'))\b 0:value " }