aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/lexers
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-18 18:34:16 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-18 18:48:06 +0200
commitbbcf801ddfd3eb50203518c130beb400de7ca53f (patch)
treef8d815e0417e3a490f8d58127c78dfc13cf62bb4 /lib/lexers
parent8baa631c77e2bc3b7457638df2d40e597faf879c (diff)
downloadsciteco-bbcf801ddfd3eb50203518c130beb400de7ca53f.tar.gz
added troff/nroff lexer
* This is optimized for Groff, but works for Heirloom Troff and Neatroff as well. Currently, the Heirloom and Neatroff requests are just added ontop of the Groff ones. Theoretically, we could also try to separate the keyword lists into a base K&R set with Groff, Heirloom and Neatroff ontop. * The lexer necessarily has many restrictions, as Troff is fundamentally unparseable (like classic TECO) and needs a lot of per-request knowledge. * The "*.mm" extension has been removed from the lexers/cpp.tes. I don't know what language this was for, and I prefer `*.mm` files to be considered Troff. * Temporarily changed the lexilla submodule URL. The corresponding Lexila lexer is in the process of being upstreamed. Once it is, I will probably revert the submodule to the official repository, as the "troff" branch is not stable (can be rebased).
Diffstat (limited to 'lib/lexers')
-rw-r--r--lib/lexers/cpp.tes2
-rw-r--r--lib/lexers/troff.tes85
2 files changed, 86 insertions, 1 deletions
diff --git a/lib/lexers/cpp.tes b/lib/lexers/cpp.tes
index d1acce4..5c3ce4a 100644
--- a/lib/lexers/cpp.tes
+++ b/lib/lexers/cpp.tes
@@ -12,7 +12,7 @@
:EN*.hppQ*"S -1 '
:EN*.hxxQ*"S -1 '
:EN*.ippQ*"S -1 '
- :EN*.mmQ*"S -1 '
+ !*:EN*.mmQ*"S -1 '*!
:EN*.smaQ*"S -1 '
:EN*.inoQ*
}
diff --git a/lib/lexers/troff.tes b/lib/lexers/troff.tes
new file mode 100644
index 0000000..a10d3e9
--- /dev/null
+++ b/lib/lexers/troff.tes
@@ -0,0 +1,85 @@
+!* troff/nroff *!
+
+@[lexer.test.troff]{
+ :EN*.groffQ*"S -1 '
+ :EN*.roffQ*"S -1 '
+ :EN*.meQ*"S -1 '
+ :EN*.mmQ*"S -1 '
+ :EN*.msQ*"S -1 '
+ :EN*.momQ*"S -1 '
+ :EN*.manQ*"S -1 '
+ :EN*.mdocQ*"S -1 '
+ :EN*.tmacQ*"S -1 '
+ :EN*.[12345678]Q*
+}
+
+!* Heirloom Troff specific requests *!
+[lexer.troff.heirloom]
+ bleedat breakchar brnl brpnl
+ cropat dch dwh
+ errprint
+ fallback fdeferlig feature fkern flig fp fps fspacewidth
+ hidechar hylang hylen hypp
+ index
+ kernafter kernbefore kernpair
+ lc_ctype lds letadj lhang lnr lnrf lpfx
+ mediasize minss
+ nhychar nrf
+ padj papersize psbb pshape
+ recursionlimit rhang
+ sentchar spacewidth
+ track transchar trimat
+ unwatch unwatchn
+ watch watchlength watchn
+ xflag
+!* Neatroff-specific requests *!
+[lexer.troff.neatroff]
+ << >> cl co co+ co< co> eos ff ffsc fmap
+ hycost hydash hystop in2 kn ochar pmll ssh ti2
+
+@[lexer.set.troff]{
+ ESSETILEXERtroff
+ !* Predefined requests (derived from Groff) *!
+ 0ESSETKEYWORDS
+ ab ad af aln als am am1 ami ami1 as as1 asciify
+ backtrace bd blm box boxa bp br brp break
+ c2 cc ce cf cflags ch char chop class close color composite continue cp cs cu
+ da de de1 defcolor dei dei1 device devicem di do ds ds1 dt
+ ec ecr ecs el em eo ev evc ex
+ fam fc fchar fcolor fi fl fp fschar fspecial ft ftr fzoom
+ gcolor
+ hc hcode hla hlm hpf hpfa hpfcode hw hy hym hys
+ ie if ig . in it itc
+ kern
+ lc length linetabs linetabs lf lg ll lsm ls lt
+ mc mk mso
+ na ne nf nh nm nn nop nr nroff ns nx
+ open opena os output
+ pc pev pi pl pm pn pnr po ps psbb pso ptr pvs pvs
+ rchar rd return rfschar rj rm rn rnn rr rs rt
+ schar shc shift sizes so sp special spreadwarn ss sty substring sv sy
+ ta tc ti tkf tl tm tm1 tmc tr trf trin trnt troff
+ uf ul unformat
+ vpt vs
+ warn warnscale wh while write writec writem
+ Q[lexer.troff.heirloom] Q[lexer.troff.neatroff]
+ !* Flow control requests/commands with conditionals *!
+ 1ESSETKEYWORDSif ie while
+ !* Flow control requests/commands without conditionals *!
+ 2ESSETKEYWORDSel nop
+ !* Requests and commands, initiating ignore blocks *!
+ 3ESSETKEYWORDSig
+ !* Requests and commands with end-macros.
+ Mom macros alias MAC to de. *!
+ 4ESSETKEYWORDSam am1 de de1 MAC
+
+ :M[color.keyword],1M[color.set]
+ :M[color.preproc],2M[color.set]
+ :M[color.number],3M[color.set]
+ :M[color.operator],4M[color.set]
+ :M[color.string],5M[color.set]
+ :M[color.comment],6M[color.set]
+ !*:M[color.comment],7M[color.set]*!
+ 7U.i 20<:M[color.variable],%.iM[color.set]>
+ :M[color.preproc2],17M[color.set]
+}