Re: [code] [scintillua] Trying to make a Literate Haskell lexer?

From: Mitchell <m.att.foicica.com>
Date: Thu, 10 Dec 2015 10:28:13 -0500 (EST)

Hi Jeremy,

On Wed, 9 Dec 2015, Jeremy Clarke wrote:

> Hi, I'm trying to make a simple Literate Haskell lexer based on the
> existing Literate CoffeeScript one.
>
> local l = require('lexer')
> local token = l.token
> local P = lpeg.P
>
> local M = {_NAME = 'lithaskell'}
>
> local haskell = l.load('haskell')
> local start_rule = token(l.STYLE_EMBEDDED, l.starts_line(P('>')))
> local end_rule = token(l.STYLE_EMBEDDED, l.newline)
> l.embed_lexer(M, haskell, start_rule, end_rule)
>
> return M
>
>
> However, I'm having absolutely no luck in getting this to work correctly.
>
> I added the line
>
> textadept.file_types.extensions.lhs = "lithaskell"
>
>
> to my init.lua, and my .lhs files are identified as lithaskell, but there
> is no highlighting (it just looks like boring old text).
> What is the correct way to embed the Haskell highlighter into an otherwise
> ordinary text lexer?
>
> Ideally I'd like to get plain text to display as comments.
> I tried the following:
>
> local line = token(l.COMMENT, l.nonnewline^0)
> M._rules = {
> {'comment', line}
> }

You are very close. The "l.nonnewline^0" needs to be "l.nonnewline^1". (If
you're on Linux you'll see an error message when running Textadept from a
terminal.) Also, make sure the `M._rules` table is defined before you call
`l.embed()`.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 10 Dec 2015 - 10:28:13 EST

This archive was generated by hypermail 2.2.0 : Fri 11 Dec 2015 - 06:50:39 EST