Skip to content

Commit

Permalink
Add SystemVerilog filetype
Browse files Browse the repository at this point in the history
Add SystemVerilog filetype and syntax highlighting:
- Create SystemVerilog filetype in Geany.
- Set it to use the existing Verilog lexer and ctags parser
  (which already supported both Verilog and SystemVerilog).
- Create filedefs file, including all the standard keywords
  from SystemVerilog-2017 (IEEE Std 1800-2017).

The ctags parser is currently underutilized, since classes and other
SystemVerilog constructs are tagged but not shown in the Symbols panel.
These will be added in a future commit.
  • Loading branch information
cousteaulecommandant committed Nov 10, 2024
1 parent bf35b7b commit 0405ed7
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 1 deletion.
62 changes: 62 additions & 0 deletions data/filedefs/filetypes.systemverilog
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
default=default
comment=comment
comment_line=comment_line
comment_line_bang=comment_line
number=number_1
word=keyword_1
word2=keyword_2
word3=keyword_3
string=string_1
preprocessor=preprocessor
operator=operator
identifier=identifier_1
stringeol=string_eol
userword=type
comment_word=comment_doc_keyword
input=keyword_4
output=keyword_4
inout=keyword_4
port_connect=keyword_4

[keywords]
# all items must be in one line
word=accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind bins binsof bit break buf bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin function generate genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import incdir include initial inout input inside instance int integer interconnect interface intersect join join_any join_none large let liblist library local localparam logic longint macromodule matches medium modport module nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 null or output package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor
word2=$finish $exit $stop $realtime $time $stime $printtimescale $timeformat $bitstoreal $bitstoshortreal $itor $signed $cast $realtobits $shortrealtobits $rtoi $unsigned $bits $typename $isunbounded $unpacked_dimensions $left $low $increment $dimensions $right $high $size $clog2 $ln $log10 $exp $sqrt $pow $floor $ceil $sin $cos $tan $asin $acos $atan $atan2 $hypot $sinh $cosh $tanh $asinh $acosh $atanh $countbits $onehot $isunknown $countones $onehot0 $fatal $warning $error $info $fatal $warning $error $info $asserton $assertkill $assertpasson $assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff $assertfailoff $assertvacuousoff $sampled $fell $changed $past_gclk $fell_gclk $changed_gclk $rising_gclk $steady_gclk $rose $stable $past $rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $coverage_control $coverage_get $coverage_save $set_coverage_db_name $coverage_get_max $coverage_merge $get_coverage $load_coverage_db $random $dist_erlang $dist_normal $dist_t $dist_chi_square $dist_exponential $dist_poisson $dist_uniform $q_initialize $q_remove $q_exam $q_add $q_full $async$and$array $async$nand$array $async$or$array $async$nor$array $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system
word3=
docComment=

[settings]
# default extension used when saving files
extension=sv

# MIME type
mime_type=text/x-systemverilog

# these characters define word boundaries when making selections and searching
# using word matching options
wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$

# single comments, like # in this file
comment_single=//
# multiline comments
comment_open=/*
comment_close=*/

# set to false if a comment character/string should start at column 0 of a line, true uses any
# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
# #command_example();
# setting to false would generate this
# # command_example();
# This setting works only for single line comments
comment_use_indent=true

# context action command (please see Geany's main documentation for details)
context_action_cmd=

[indentation]
#width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
#type=1
3 changes: 2 additions & 1 deletion data/filetype_extensions.conf
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*
Smalltalk=*.st;
SQL=*.sql;
Swift=*.swift;
SystemVerilog=*.sv;*.svh;
Tcl=*.tcl;*.tk;*.wish;*.exp;
Txt2tags=*.t2t;
TypeScript=*.ts;*.cts;*.mts;*.tsx;
Vala=*.vala;*.vapi;
Verilog=*.v;
Verilog=*.v;*.vh;
VHDL=*.vhd;*.vhdl;
XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml;*.xul;*.dtd;*.xtpl;*.mml;*.mathml;
YAML=*.yaml;*.yml;
Expand Down
1 change: 1 addition & 0 deletions src/filetypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ static void init_builtin_filetypes(void)
FT_INIT( PROLOG, NONE, "Prolog", NULL, SOURCE_FILE, COMPILED );
FT_INIT( NIM, NONE, "Nim", NULL, SOURCE_FILE, COMPILED );
FT_INIT( ZIG, NONE, "Zig", NULL, SOURCE_FILE, COMPILED );
FT_INIT( SYSVERILOG, SYSVERILOG, "SystemVerilog", NULL, SOURCE_FILE, COMPILED );
}


Expand Down
1 change: 1 addition & 0 deletions src/filetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ typedef enum
GEANY_FILETYPES_PROLOG,
GEANY_FILETYPES_NIM,
GEANY_FILETYPES_ZIG,
GEANY_FILETYPES_SYSVERILOG,
/* ^ append items here */
GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */
}
Expand Down
2 changes: 2 additions & 0 deletions src/highlighting.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
init_styleset_case(TXT2TAGS);
init_styleset_case(VHDL);
init_styleset_case(VERILOG);
init_styleset_case(SYSVERILOG);
init_styleset_case(XML);
init_styleset_case(YAML);
init_styleset_case(ZEPHIR);
Expand Down Expand Up @@ -1153,6 +1154,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft)
styleset_case(TXT2TAGS);
styleset_case(VHDL);
styleset_case(VERILOG);
styleset_case(SYSVERILOG);
styleset_case(XML);
styleset_case(YAML);
styleset_case(ZEPHIR);
Expand Down
7 changes: 7 additions & 0 deletions src/highlightingmappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,13 @@ static const HLKeyword highlighting_keywords_VERILOG[] =
#define highlighting_properties_VERILOG EMPTY_PROPERTIES


/* SystemVerilog */
#define highlighting_lexer_SYSVERILOG highlighting_lexer_VERILOG
#define highlighting_styles_SYSVERILOG highlighting_styles_VERILOG
#define highlighting_keywords_SYSVERILOG highlighting_keywords_VERILOG
#define highlighting_properties_SYSVERILOG highlighting_properties_VERILOG


/* XML */
#define highlighting_lexer_XML SCLEX_XML
#define highlighting_styles_XML highlighting_styles_HTML
Expand Down
43 changes: 43 additions & 0 deletions src/tagmanager/tm_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,47 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
};

static TMParserMapEntry map_SYSVERILOG[] = {
// Verilog and SystemVerilog
{'c', tm_tag_variable_t}, // constant
{'d', tm_tag_variable_t}, // define
{'e', tm_tag_typedef_t}, // event
{'f', tm_tag_function_t}, // function
{'m', tm_tag_class_t}, // module
{'n', tm_tag_variable_t}, // net
{'p', tm_tag_variable_t}, // port
{'r', tm_tag_variable_t}, // register
{'t', tm_tag_function_t}, // task
{'b', tm_tag_undef_t}, // block
{'i', tm_tag_undef_t}, // instance
// SystemVerilog only (currently unused)
{'A', tm_tag_undef_t}, // assert
{'C', tm_tag_undef_t}, // class
{'V', tm_tag_undef_t}, // covergroup
{'E', tm_tag_undef_t}, // enum
{'I', tm_tag_undef_t}, // interface
{'M', tm_tag_undef_t}, // modport
{'K', tm_tag_undef_t}, // package
{'P', tm_tag_undef_t}, // program
{'Q', tm_tag_undef_t}, // prototype
{'R', tm_tag_undef_t}, // property
{'S', tm_tag_undef_t}, // struct
{'T', tm_tag_undef_t}, // typedef
{'H', tm_tag_undef_t}, // checker
{'L', tm_tag_undef_t}, // clocking
{'q', tm_tag_undef_t}, // sequence
{'w', tm_tag_undef_t}, // member
{'l', tm_tag_undef_t}, // ifclass
{'O', tm_tag_undef_t}, // constraint
{'N', tm_tag_undef_t}, // nettype
};
static TMParserMapGroup group_SYSVERILOG[] = {
{N_("Events"), TM_ICON_MACRO, tm_tag_typedef_t},
{N_("Modules"), TM_ICON_CLASS, tm_tag_class_t},
{N_("Functions / Tasks"), TM_ICON_METHOD, tm_tag_function_t},
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
};

static TMParserMapEntry map_R[] = {
{'f', tm_tag_function_t}, // function
{'l', tm_tag_other_t}, // library
Expand Down Expand Up @@ -1257,6 +1298,7 @@ static TMParserMap parser_map[] = {
MAP_ENTRY(TXT2TAGS),
MAP_ENTRY(ABC),
MAP_ENTRY(VERILOG),
MAP_ENTRY(SYSVERILOG),
MAP_ENTRY(R),
MAP_ENTRY(COBOL),
MAP_ENTRY(OBJC),
Expand Down Expand Up @@ -1811,6 +1853,7 @@ gboolean tm_parser_has_full_scope(TMParserType lang)
case TM_PARSER_VALA:
case TM_PARSER_VHDL:
case TM_PARSER_VERILOG:
case TM_PARSER_SYSVERILOG:
case TM_PARSER_ZEPHIR:
case TM_PARSER_AUTOIT:
return TRUE;
Expand Down
1 change: 1 addition & 0 deletions src/tagmanager/tm_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ enum
TM_PARSER_TXT2TAGS,
TM_PARSER_ABC,
TM_PARSER_VERILOG,
TM_PARSER_SYSVERILOG,
TM_PARSER_R,
TM_PARSER_COBOL,
TM_PARSER_OBJC,
Expand Down
1 change: 1 addition & 0 deletions src/tagmanager/tm_parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
Txt2tagsParser, \
AbcParser, \
VerilogParser, \
SystemVerilogParser, \
RParser, \
CobolParser, \
ObjcParser, \
Expand Down

0 comments on commit 0405ed7

Please sign in to comment.