Re: Next generation of lexers

From: Robert <ro....at.web.de>
Date: Sun, 25 Apr 2010 20:44:04 +0200

On Wed, Apr 21, 2010 at 6:51 PM, mitchell <mforal.n....at.gmail.com> wrote:
>> wasn't succesful. At the moment I have this:
>> local var_definition = 'Var' * l.space^1 * l.word * l.newline
>> local var = '$' * l.word
>> local variable = token('variable', var + var_definition)
>
> local ws = token('whitespace', l.space^1)
> local keyword = token('keyword', word_match { ... 'Var' ... })
> local variable = #P('Var') * keyword * ws^0 * token('variable', P('$'
> * l.word))
>
> _rules = {
>  ...
>  { 'variable', variable }
>  { 'keyword', keyword }
>  ...
> }
>
> Mitchell
>
Thank a lot for looking into this, I couldn't get it to work, however.
Maybe I explained badly what I had in mind (I did.)
Is it possible to have occurrences of variable names styled? Like
local foo = 1 -- foo gets styled as a variable
-- later
foo = 2 -- foo gets styled as a variable
print(foo, bar) -- foo gets styled as a variable, bar not
Just a question, this is probably not very important to have.

I put lexers for Markdown, NSIS and Lilypond up here:
http://bitbucket.org/rgieseke/textadept-lexers

My first attempts at a lexer (before the rewrite) were for Markdown,
because I had started a little Markdown module:
http://bitbucket.org/rgieseke/textadept-markdown/

Feel free to include the lexers, if you like, they will hopefully
improve as I use them more. I wasn't sure if a Markdown lexer is
against the point of Markdown, but then I liked it.

Some thoughts on the new docs:
I had bad experiences with other editors when a lexing style changed
theme colors so lines became impossible to read. Maybe a note could be
added to add back- and foreground colors together? The diff lexer is
an example for this, maybe the foreground color could be changed?
Another issue with the diff lexer: Lua comments are treated as
deletions. I tried some but didn't find a good solution.

Another idea for the Latex lexer, maybe it would be useful to turn
this into a Tex lexer that covers plain Tex, Latex and Context.
Currently there are quite a lot of keywords in the Latex lexer but it
is impossible to cover all packages or new ones defined with
renewcommand.
I would do a
local command = token('keyword', '\\' * l.word)
This would cover Context's keywords as well. Having Latex environments
in the lexer shouldn't be a problem.
Then I have to look some more into LuaTeX, and have the Lua lexer embedded :-)
I like their explanation for using Lua over x:
http://luatex.org/faq.html

Robert

-- 
You received this message because you are subscribed to the Google Groups "textadept" group.
To post to this group, send email to textadept.at.googlegroups.com.
To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
Received on Sun 25 Apr 2010 - 14:44:04 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:43:38 EST