Ticket #4316: add basic Ngspice syntax highlighting.

Add basic support for highlighting Ngspice/SPICE (http://ngspice.sourceforge.net/)
circuit description files syntax. Two main contexts are defined:
- the default context, where the circuit is described,
- the control script context (between .control and .endc).

The default context highlights dot commands, circuit element instance
names and model types. The control script context highlights supported
functions/commands and known variables. Both contexts highlight comments
and line continuation marks.

Other than two FIXMEs, it is a known issue the first line of the file is
part of the default context, while in most cases it would contain the
file title.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Grzegorz Szymaszek 2021-12-01 13:20:07 +01:00 committed by Andrew Borodin
parent eff779b246
commit 52d9d7946f
3 changed files with 425 additions and 0 deletions

View File

@ -80,6 +80,7 @@ SYNTAXFILES = \
slang.syntax \
smalltalk.syntax \
spec.syntax \
spice.syntax \
sql.syntax \
strace.syntax \
swift.syntax \

View File

@ -70,6 +70,9 @@ include html.syntax
file ..\*\\.((?i:xml|xsd|xslt?|dtd)|qpg|qpg\\.in)$ XML\sdocument (\\?xml\sversion|!DOCTYPE\s)
include xml.syntax
file ..\*\\.cir$ Spice\scircuit
include spice.syntax
file ..\*\\.(?i:tt)$ Template::Toolkit\sFile
include tt.syntax

421
misc/syntax/spice.syntax Normal file
View File

@ -0,0 +1,421 @@
caseinsensitive
context default
keyword linestart \**\n brown
keyword $*\n brown
keyword ;*\n brown
keyword //*\n brown
keyword linestart \+ red
# dot commands
keyword whole .ac brightmagenta
keyword whole .csparam brightmagenta
keyword whole .dc brightmagenta
keyword whole .disto brightmagenta
keyword whole .else brightmagenta
keyword whole .elseif brightmagenta
keyword whole .end brightmagenta
keyword whole .endif brightmagenta
keyword whole .ends brightmagenta
keyword whole .four brightmagenta
keyword whole .func brightmagenta
keyword whole .global brightmagenta
keyword whole .ic brightmagenta
keyword whole .if brightmagenta
keyword whole .include brightmagenta
keyword whole .lib brightmagenta
keyword whole .meas brightmagenta
keyword whole .model brightmagenta
keyword whole .nodeset brightmagenta
keyword whole .noise brightmagenta
keyword whole .op brightmagenta
keyword whole .options brightmagenta
keyword whole .param brightmagenta
keyword whole .plot brightmagenta
keyword whole .print brightmagenta
keyword whole .probe brightmagenta
keyword whole .pss brightmagenta
keyword whole .pz brightmagenta
keyword whole .save brightmagenta
keyword whole .sens brightmagenta
keyword whole .subckt brightmagenta
keyword whole .temp brightmagenta
keyword whole .tf brightmagenta
keyword whole .title brightmagenta
keyword whole .tran brightmagenta
keyword whole .width brightmagenta
# circuit elements
keyword wholeleft linestart A*\s brightcyan
keyword wholeleft linestart A*\t brightcyan
keyword wholeleft linestart B*\s brightcyan
keyword wholeleft linestart B*\t brightcyan
keyword wholeleft linestart C*\s brightcyan
keyword wholeleft linestart C*\t brightcyan
keyword wholeleft linestart D*\s brightcyan
keyword wholeleft linestart D*\t brightcyan
keyword wholeleft linestart E*\s brightcyan
keyword wholeleft linestart E*\t brightcyan
keyword wholeleft linestart F*\s brightcyan
keyword wholeleft linestart F*\t brightcyan
keyword wholeleft linestart G*\s brightcyan
keyword wholeleft linestart G*\t brightcyan
keyword wholeleft linestart H*\s brightcyan
keyword wholeleft linestart H*\t brightcyan
keyword wholeleft linestart I*\s brightcyan
keyword wholeleft linestart I*\t brightcyan
keyword wholeleft linestart J*\s brightcyan
keyword wholeleft linestart J*\t brightcyan
keyword wholeleft linestart K*\s brightcyan
keyword wholeleft linestart K*\t brightcyan
keyword wholeleft linestart L*\s brightcyan
keyword wholeleft linestart L*\t brightcyan
keyword wholeleft linestart M*\s brightcyan
keyword wholeleft linestart M*\t brightcyan
keyword wholeleft linestart N*\s brightcyan
keyword wholeleft linestart N*\t brightcyan
keyword wholeleft linestart O*\s brightcyan
keyword wholeleft linestart O*\t brightcyan
keyword wholeleft linestart P*\s brightcyan
keyword wholeleft linestart P*\t brightcyan
keyword wholeleft linestart Q*\s brightcyan
keyword wholeleft linestart Q*\t brightcyan
keyword wholeleft linestart R*\s brightcyan
keyword wholeleft linestart R*\t brightcyan
keyword wholeleft linestart S*\s brightcyan
keyword wholeleft linestart S*\t brightcyan
keyword wholeleft linestart T*\s brightcyan
keyword wholeleft linestart T*\t brightcyan
keyword wholeleft linestart U*\s brightcyan
keyword wholeleft linestart U*\t brightcyan
keyword wholeleft linestart V*\s brightcyan
keyword wholeleft linestart V*\t brightcyan
keyword wholeleft linestart W*\s brightcyan
keyword wholeleft linestart W*\t brightcyan
keyword wholeleft linestart X*\s brightcyan
keyword wholeleft linestart X*\t brightcyan
keyword wholeleft linestart Y*\s brightcyan
keyword wholeleft linestart Y*\t brightcyan
keyword wholeleft linestart Z*\s brightcyan
keyword wholeleft linestart Z*\t brightcyan
# model types
keyword whole R white
keyword whole C white
keyword whole L white
keyword whole SW white
keyword whole CSW white
keyword whole URC white
keyword whole LTRA white
keyword whole D white
keyword whole NPN white
keyword whole PNP white
keyword whole NJF white
keyword whole PJF white
keyword whole NMOS white
keyword whole PMOS white
keyword whole NMF white
keyword whole PMF white
keyword whole VDMOS white
# XSPICE models
keyword whole gain white
keyword whole summer white
keyword whole mult white
keyword whole divide white
keyword whole limit white
keyword whole climit white
keyword whole pwl white
keyword whole filesource white
keyword whole multi_input_pwl white
keyword whole aswitch white
keyword whole pswitch white
keyword whole zener white
keyword whole ilimit white
keyword whole hyst white
keyword whole d_dt white
keyword whole int white
keyword whole s_xfer white
keyword whole slew white
keyword whole lcouple white
keyword whole core white
keyword whole sine white
keyword whole triangle white
keyword whole square white
keyword whole oneshot white
keyword whole cmeter white
keyword whole lmeter white
keyword whole memristor white
keyword whole table2D white
keyword whole table3D white
keyword whole sidiode white
keyword whole dac_bridge white
keyword whole adc_bridge white
keyword whole d_osc white
keyword whole d_to_real white
keyword whole real_delay white
keyword whole real_gain white
keyword whole real_to_v white
keyword whole d_buffer white
keyword whole d_inverter white
keyword whole d_and white
keyword whole d_nand white
keyword whole d_or white
keyword whole d_nor white
keyword whole d_xor white
keyword whole d_xnor white
keyword whole d_tristate white
keyword whole d_pullup white
keyword whole d_pulldown white
keyword whole d_dff white
keyword whole d_jkff white
keyword whole d_tff white
keyword whole d_srff white
keyword whole d_dlatch white
keyword whole d_srlatch white
keyword whole d_state white
keyword whole d_fdiv white
keyword whole d_ram white
keyword whole d_source white
keyword whole d_lut white
keyword whole d_genlut white
keyword whole xfer white
# common model parameters
keyword whole m white
context " " green
context .control .endc
keyword linestart \**\n brown
keyword $*\n brown
keyword ;*\n brown
keyword //*\n brown
keyword linestart \+ red
keyword .control brightmagenta
keyword .endc brightmagenta
# commands
keyword whole ac yellow
keyword whole alias yellow
keyword whole alter yellow
keyword whole altermod yellow
keyword whole alterparam yellow
keyword whole asciiplot yellow
keyword whole aspice yellow
keyword whole bug yellow
keyword whole cd yellow
keyword whole cdump yellow
keyword whole circbyline yellow
keyword whole codemodel yellow
keyword whole compose yellow
keyword whole cutout yellow
keyword whole dc yellow
keyword whole define yellow
keyword whole deftype yellow
keyword whole delete yellow
keyword whole destroy yellow
keyword whole devhelp yellow
keyword whole diff yellow
keyword whole display yellow
keyword whole echo yellow
keyword whole edit yellow
keyword whole edisplay yellow
keyword whole eprint yellow
keyword whole eprvcd yellow
keyword whole fft yellow
keyword whole fourier yellow
keyword whole getcwd yellow
keyword whole gnuplot yellow
keyword whole hardcopy yellow
keyword whole help yellow
keyword whole history yellow
keyword whole inventory yellow
keyword whole iplot yellow
keyword whole jobs yellow
keyword whole let yellow
keyword whole linearize yellow
keyword whole listing yellow
keyword whole load yellow
keyword whole mc_source yellow
keyword whole meas yellow
keyword whole mdump yellow
keyword whole mrdump yellow
keyword whole noise yellow
keyword whole op yellow
keyword whole option yellow
keyword whole plot yellow
# FIXME: other pre_* keywords?
keyword whole pre_codemodel yellow
keyword whole pre_set yellow
keyword whole pre_unset yellow
keyword whole print yellow
keyword whole psd yellow
keyword whole quit yellow
keyword whole rehash yellow
keyword whole remcirc yellow
keyword whole remzerovec yellow
keyword whole reset yellow
keyword whole reshape yellow
keyword whole resume yellow
keyword whole rspice yellow
keyword whole run yellow
keyword whole rusage yellow
keyword whole save yellow
keyword whole sens yellow
keyword whole set yellow
keyword whole setcs yellow
keyword whole setcirc yellow
keyword whole setplot yellow
keyword whole setscale yellow
keyword whole setseed yellow
keyword whole settype yellow
keyword whole shell yellow
keyword whole shift yellow
keyword whole show yellow
keyword whole showmod yellow
keyword whole snload yellow
keyword whole snsave yellow
keyword whole source yellow
keyword whole spec yellow
keyword whole status yellow
keyword whole step yellow
keyword whole stop yellow
keyword whole strcmp yellow
keyword whole sysinfo yellow
keyword whole tf yellow
keyword whole trace yellow
keyword whole tran yellow
keyword whole transpose yellow
keyword whole unalias yellow
keyword whole undefine yellow
keyword whole unlet yellow
keyword whole unset yellow
keyword whole version yellow
keyword whole where yellow
keyword whole wrdata yellow
keyword whole write yellow
keyword whole wrs2p yellow
# control structures
keyword whole break brightred
keyword whole continue brightred
keyword whole dowhile brightred
keyword whole else brightred
keyword whole end brightred
keyword whole foreach brightred
keyword whole goto brightred
keyword whole if brightred
keyword whole label brightred
keyword whole repeat brightred
keyword whole then brightred
keyword whole while brightred
# internally predefined variables
keyword whole appendwrite white
keyword whole askquit white
keyword whole batchmode white
# FIXME: N between 0 and 22
keyword wholeleft color*\s white
keyword wholeleft color*\t white
keyword whole controlswait white
keyword whole cpdebug white
keyword whole curplot white
keyword whole curplotdate white
keyword whole curplotname white
keyword whole curplottitle white
keyword whole debug white
keyword whole device white
keyword whole diff_abstol white
keyword whole diff_reltol white
keyword whole diff_vntol white
keyword whole echo white
keyword whole editor white
keyword whole filetype white
keyword whole fourgridsize white
keyword whole gridsize white
keyword whole gridstyle white
keyword whole hcopydev white
keyword whole hcopyfont white
keyword whole hcopyfontsize white
keyword whole hcopydevtype white
keyword whole hcopyscale white
keyword whole hcopywidth white
keyword whole hcopyheight white
keyword whole hcopypscolor white
keyword whole hcopypstxcolor white
keyword whole height white
keyword whole history white
keyword whole inputdir white
keyword whole interactive white
keyword whole lprplot5 white
keyword whole lprps white
keyword whole modelcard white
keyword whole moremode white
keyword whole nfreqs white
keyword whole ngbehavior white
keyword whole ngdebug white
keyword whole ng_nomodcheck white
keyword whole no_auto_gnd white
keyword whole nobjthack white
keyword whole nobreak white
keyword whole noasciiplotvalue white
keyword whole noclobber white
keyword whole noglob white
keyword whole nolegend white
keyword whole nonomatch white
keyword whole noparse white
keyword whole noprintscale white
keyword whole nosavecurrents white
keyword whole nosort white
keyword whole nostepsizelimit white
keyword whole nosubckt white
keyword whole notrnoise white
keyword whole nounits white
keyword whole numdgt white
keyword whole num_threads white
keyword whole oscompiled white
keyword whole plainlet white
keyword whole plainplot white
keyword whole plainwrite white
keyword whole plainstyle white
keyword whole pointchars white
keyword whole polydegree white
keyword whole polysteps white
keyword whole program white
keyword whole prompt white
keyword whole rawfile white
keyword whole remote_shell white
keyword whole renumber white
keyword whole rndseed white
keyword whole rhost white
keyword whole rprogram white
keyword whole sharedmode white
keyword whole sim_status white
keyword whole sourcepath white
keyword whole specwindow white
keyword whole specwindoworder white
keyword whole spicepath white
keyword whole sqrnoise white
keyword whole strict_errorhandling white
keyword whole subend white
keyword whole subinvoke white
keyword whole substart white
keyword whole term white
keyword whole ticchar white
keyword whole ticmarks white
keyword whole ticlist white
keyword whole units white
keyword whole unixcom white
keyword whole wfont white
keyword whole wfont_size white
keyword whole width white
keyword whole win_console white
keyword whole wr_singlescale white
keyword whole wr_vecnames white
keyword whole x11lineararcs white
keyword whole xbrushwidth white
keyword whole xgridwidth white
keyword whole xfont white
keyword whole xtrtol white