Re: [code] Extending a lexer

From: Mitchell <>
Date: Sun, 18 Dec 2016 08:29:39 -0500 (EST)

Hi Michael,

On Sun, 18 Dec 2016, Michael Richter wrote:

> I'd like to add some Logtalk support to Textadept. For those not in the
> know, Logtalk is an OOP toolkit for kit-bashing OOP layers on top of
> Prolog. Syntactically it is so close to Prolog that I can just use a
> Prolog lexer and get "almost good enough" syntax highlighting.
> I'd like to improve this, however.
> What I'd like to do is basically build up on the Prolog lexer by adding
> "keywords" and library "functions" and such to it rather than copying the
> Prolog lexer and tweaking it. Unfortunately the tools for embedding parent
> or child lexers are *not* really suitable for this task: there is no clear
> "region of Logtalk" vs. "region of Prolog" code. Logtalk is essentially a
> syntax-compatible dialect of Prolog.
> How would I go about making such a beast if this is possible at all?

Textadept has a number of lexers that "extend" existing ones:

* LESS and SASS extend CSS
* CUDA and GLSL extend C++ (cpp)
* Rails extends Ruby

All you really do is `lexer.load()` the lexer to entend, modify its
`_rules` table, and set it as your lexer's own. Each of the lexers I
mentioned above does this.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 18 Dec 2016 - 08:29:39 EST

This archive was generated by hypermail 2.2.0 : Mon 19 Dec 2016 - 06:44:07 EST