Re: [code] Debugging language modules

From: Robert Gieseke <rob.g.att.web.de>
Date: Sat, 26 Mar 2016 17:20:23 +0100

Hi Arnel,

Am 26/03/16 um 16:22 schrieb Arnel:
> - I have the following lines in the 'init.lua' file for the Racket module:
>
> textadept.file_types.extensions.rkt = 'racket'
> textadept.run.run_commands.racket = 'racket "%f"'
> textadept.run.error_patterns[#textadept.run.error_patterns + 1] = '^(.-):(%d+):%
> d+: (.+)$' textadept.run.syntax_commands.racket = 'racket -f "%f"'
> textadept.run.syntax_error_patterns.racket = ':(%d+):%d+: (.+)'
> textadept.editing.comment_string.racket = ";"
>
> However, if I open a Racket script and try testing the syntax checking, nothing
> happens. The 'init.lua' file is located inside the 'racket' directory inside
> '~/.textadept/modules'. If I run
>
> ui.print(textadept.file_types.extensions.rkt)
>
> from the command entry, I come up with plain 'nil'. Why is that?
>
> If I place these lines in my regular '~/.textadept/init.lua', the syntax
> checking works fine.

This works as expected, the file extension and commands are set adding
to Textadept modules tables. The first time a Racket module is detected
(via extension) Textadept will load your module.

If you submit your lexer and the extension settings once it's done you
won't have this problem anymore.

> - Is there a better way to debug lexer modules? The Racket lexer I'm working on
> was based off the Scheme lexer file provided with TA. I've read somewhere in
> the API manual that troubleshooting lexers can be tricky and it's recommended
> to run TA in the terminal to get the error messages. I tried this but I didn't
> get any. Those who have written lexers for other languages before - any
> pointers? Anything on seeing what's actually captured by the LPEG expressions
> would be great.

One option is to use Scintillua as a standalone library, there is an
example in the manual[1]. It might help to really understand and test a
single pattern.

> - Is it possible to change the background color of highlighted
> brackets and parentheses when looking for their pairs? There doesn't appear to
> be anything related mentioned in the buffer API for it.

In your properties.lua file you can overwrite Textadept's defaults, this
gives me a red box (with Solarized theme):

local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
buffer.indic_style[INDIC_BRACEMATCH] = buffer.INDIC_FULLBOX
buffer.indic_fore[INDIC_BRACEMATCH] = buffer.property_int['color.base08']
buffer:brace_highlight_indicator(not CURSES, INDIC_BRACEMATCH)

(I use a base16 theme, so you might not have other colors defined, you
could also specify a color directly.)

Cheers,
Robert

[1]
http://foicica.com/scintillua/manual.html#Using.Scintillua.as.a.Lua.Library

-- 
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 Sat 26 Mar 2016 - 12:20:23 EDT

This archive was generated by hypermail 2.2.0 : Sun 27 Mar 2016 - 06:43:12 EDT