aboutsummaryrefslogtreecommitdiffhomepage
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
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).
-rw-r--r--.gitmodules2
-rw-r--r--TODO1
m---------contrib/lexilla0
-rw-r--r--freebsd/pkg-plist1
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/lexers/cpp.tes2
-rw-r--r--lib/lexers/troff.tes85
7 files changed, 90 insertions, 4 deletions
diff --git a/.gitmodules b/.gitmodules
index ed91108..3636830 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,4 +7,4 @@
url = https://github.com/orbitalquark/scinterm.git
[submodule "lexilla"]
path = contrib/lexilla
- url = https://github.com/ScintillaOrg/lexilla.git
+ url = https://github.com/rhaberkorn/lexilla.git
diff --git a/TODO b/TODO
index 357044f..f3ebc5a 100644
--- a/TODO
+++ b/TODO
@@ -417,7 +417,6 @@ Features:
native Scintilla packages.
Perhaps it makes sense to be able to build against them
using --with-scintilla.
- * Write a Scintilla/Lexilla lexer for Roff
* There is an Urxvt extension 52-osc for implementing the
xterm-like clipboard control sequences.
Other emulators also support it. It is not always detectable
diff --git a/contrib/lexilla b/contrib/lexilla
-Subproject 43ea736569d52ba6cf7e7325cf39009409e7282
+Subproject ea72eee0686784f5314e5c898252889060b5e47
diff --git a/freebsd/pkg-plist b/freebsd/pkg-plist
index 106bf73..d65cbf6 100644
--- a/freebsd/pkg-plist
+++ b/freebsd/pkg-plist
@@ -80,6 +80,7 @@ man/man7/%%PROGRAM_PREFIX%%sciteco.7.gz
%%LEXILLA%%%%DATADIR%%/lib/lexers/tal.tes
%%LEXILLA%%%%DATADIR%%/lib/lexers/tcl.tes
%%LEXILLA%%%%DATADIR%%/lib/lexers/test.tes
+%%LEXILLA%%%%DATADIR%%/lib/lexers/troff.tes
%%LEXILLA%%%%DATADIR%%/lib/lexers/vala.tes
%%LEXILLA%%%%DATADIR%%/lib/lexers/vb.tes
%%LEXILLA%%%%DATADIR%%/lib/lexers/verilog.tes
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a458692..5ea3029 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -99,6 +99,7 @@ dist_lexer_DATA += lexers/verilog.tes \
lexers/python.tes \
lexers/yaml.tes \
lexers/markdown.tes \
- lexers/asciidoc.tes
+ lexers/asciidoc.tes \
+ lexers/troff.tes
endif
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]
+}